Helpful Information
 
 
Category: Perl/ CGI
Writing to a Log

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 " ==================================================
===============================\n";
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 " ==================================================
===============================\n\n";
close (DLRECORD);


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

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]))
{
blablah;
}

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?
}

Use these:
return 1; #true
return 0; #false

Good luck

Mzzl, Chris

Okay. Thanks, works great.










privacy (GDPR)