...

View Full Version : Writing to a Log



ObiwanJebroni
07-03-2002, 01: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 " ==================================================
===============================\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.

ObiwanJebroni
07-03-2002, 04: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]))
{
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?
}

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

Good luck

Mzzl, Chris

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum