View Full Version : Writing to a Log

07-03-2002, 02:25 PM
I'm using some PERL script to write some data about a user who uses my website. The script is supposed to write the data about the user to a file after retrieving some form data and then getting a few other tidbits of information as well.

Here's my code for what I THINK should do the trick (even though it doesn't). The text file isn't expected to do anything but sit there for the administrator to view at his leisure.

$currenttime = localtime;
$record = "c:/abyss/htdocs/logs/dl-log.txt";
open(DLRECORD, "<< $record");
print DLRECORD "$currenttime \n";
print DLRECORD " ==================================================
print DLRECORD "User $FORM{last_name}, $FORM{first_name} requested download. Information given includes:\n";
print DLRECORD "ADDRESS: $FORM{address}\n";
print DLRECORD "CITY, STATE ZIP:$FORM{city}, $FORM{state} $FORM{zip}\n\n";
print DLRECORD "EMAIL: $FORM{email}\n";
print DLRECORD " ==================================================
close (DLRECORD);

Please ignore some of the line-breaks. Semicolons end each line.

07-03-2002, 05:15 PM
Wait, never mind. I just have the wrong operators.

I have a different question now though. I'm writing an email validation script in PERL and I was wondering if PERL subs allow the returning of some boolean value? My code looks something like this:

if(char_find(@string, $tofind) && is_char($string[1]) && is_char($string[2]))

sub char_find (@string, $tofind)
foreach $string(@string)
if($string eq $tofind)
return ; #is there something like "true" or something that I can put there?
return ; #false

sub is_char($finder)
if ($finder eq '_' || /$finder/i eq 'a' || /$finder/i eq 'b...)
return ; #true?
return ; #false?

07-04-2002, 08:22 AM
Use these:
return 1; #true
return 0; #false

Good luck

Mzzl, Chris

07-05-2002, 02:26 PM
Okay. Thanks, works great.