Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.



    Code:
    $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.
    -Obiwan Jabroni
    May the Schwartz be With You

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    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?
    }
    -Obiwan Jabroni
    May the Schwartz be With You

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    the Netherlands
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use these:
    return 1; #true
    return 0; #false

    Good luck

    Mzzl, Chris

  • #4
    New Coder
    Join Date
    Jun 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay. Thanks, works great.
    -Obiwan Jabroni
    May the Schwartz be With You


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •