EOF.
OK, in the middle of a script, I have a statement that looks like this:
$items=$items - 5;
Now, PERL interprets that 5; as the EOF thingy that indicates the end of a script. How do I make it so that it doesn't do that?
OK, in the middle of a script, I have a statement that looks like this:
$items=$items - 5;
Now, PERL interprets that 5; as the EOF thingy that indicates the end of a script. How do I make it so that it doesn't do that?
Orpheus posted this at 20:18 — 28th June 2000.
They have: 568 posts
Joined: Nov 1999
That's really weird.... could you post a bigger snippet of code?
Vorm posted this at 00:41 — 29th June 2000.
They have: 62 posts
Joined: May 2000
#!/usr/bin/perl
require "parseform.lib";
&Parse_Form;
$referer=$ENV{'HTTP_REFERER'};
$name=$formdata{'name'};
$comments=$formdata{'comments'};
$filename=$formdata{'filename};
print "Content-type:text/html\n\n";
# Get time.
@days= ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July','August','September','October','November','December');
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
$year += 1900;
$date = "$days[$wday], $months[$mon] $mday, $year at $time";
# Check referer.
if ($name ne "" && $comments ne "" && $referer=~m#www.heh.com#) {
$referercheck=1;
# Check for naughty language and SSI.
$name=~s/****/f***/g;
$name=~s/****/s***/g;
$comments=~s/****/f***/g;
$comments=~s/****/s***/g;
$comments=~s/<!--(.|\n)*-->//g;
$finalcontent= qq~
<tr><td><b>$name<b> said... (posted $date)</td></tr>
<tr><td>$comments
~;
# Get the data from the refering page.
open(ORIGIN, "</home/heh/public_html/$filename") or die "Cannot open file to read: $!";
@origin=<ORIGIN>;
close(ORIGIN);
# Find the amount of items in the origin array.
$items=@origin;
# Subtract by # of items it will take to get fan replys in the correct place. Approximently five.
$items=$items - 5;
# Splice the origin array.
splice(@origin, $items, 0, $finalcontent);
# Print the array back to the file.
open(BACK, ">/home/heh/public_html/$filename") or die "Cannot open file to write: $!";
print BACK "@origin";
close(BACK);
print <<"heh";
Thank you $name for your valuable feedback! <a href=$origin>Click here</a> to see your reply.
heh
# Finish referer check.
} elsif ($referercheck!=1) {
print "No executing this script from another server muchacho.";
} else {
print "Please fill in all the spaces.";
}
1;
That's the full script.
Orpheus posted this at 01:29 — 29th June 2000.
They have: 568 posts
Joined: Nov 1999
Not sure if this works but this is the only part of the code that looks bad
open(ORIGIN, "</home/heh/public_html/$filename") or die "Cannot open file to read: $!";
@origin=<ORIGIN>;
close(ORIGIN);
change that too
open(ORIGIN, "/home/heh/public_html/$filename") or die "Cannot open file to read: $!";
@origin=<ORIGIN>;
close(ORIGIN);
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.