Web Analytics Made Easy -
StatCounter Writing to a Log - CodingForum

Announcement

Collapse
No announcement yet.

Writing to a Log

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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

    Comment


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

      Good luck

      Mzzl, Chris
      My Website
      010100010011110101110100011011110111000001101000

      Comment


      • #4
        Okay. Thanks, works great.
        -Obiwan Jabroni
        May the Schwartz be With You

        Comment

        Working...
        X