perl people, help plz?

Discussion in 'OT Technology' started by skelm, Sep 27, 2006.

  1. skelm

    skelm New Member

    Joined:
    Jan 9, 2006
    Messages:
    868
    Likes Received:
    0
    Location:
    Australia
    Hi guys, I'm coding a modulated IRC bot (yeah stone ages) but I'm having some problems with logging. See: http://nomorepasting.com/paste.php?pasteID=69224

    For some reason I can't create the file if it doesn't already exist but I can open a file that already exists... any help would be apreachiated.
     
  2. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Shouldn't you be calling open(LOGFILE, ">>$filename") ?

    The API is:

    open(FH, $FilePath, permissions);

    But you're using: open(LOGFILE1,'>>',$filename)

    Which is incorrect.

    Alternatively, you can replace the comma between '>>' and $filename with a . like this to join the strings and it should work: open(LOGFILE1,'>>' . $filename)
     
  3. skelm

    skelm New Member

    Joined:
    Jan 9, 2006
    Messages:
    868
    Likes Received:
    0
    Location:
    Australia
    I have open(LOGFILE,'>>',$filename) ?

    ... It works the same.
     
  4. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Does it? Because that is not the API. I edited my post. Did you try it?
     
  5. skelm

    skelm New Member

    Joined:
    Jan 9, 2006
    Messages:
    868
    Likes Received:
    0
    Location:
    Australia
    I'll try it now :)
     
  6. skelm

    skelm New Member

    Joined:
    Jan 9, 2006
    Messages:
    868
    Likes Received:
    0
    Location:
    Australia
    :(

    $filename = $filestart . "$type/$type.$time[5].$time[4].$time[3].log";
    # open(LOGFILE3,'>>',$filename) or print "LOGFILE3 FAILED";
    open(LOGFILE3,$filename,'>>') or print "LOGFILE3 FAILED";
    print LOGFILE3 $msg . "\n";
    close(LOGFILE3);[/QUOTE]
     
  7. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Why the fuck did you put >> after? IT IS IN THE SAME STRING AS THE FILENAME.

    Do what I said. If the filename is /etc/bob, then it should be: open(BOB, '>>/etc/bob');

    Get it?
     
  8. GOGZILLA

    GOGZILLA Double-Uranium Member

    Joined:
    Jan 16, 2003
    Messages:
    10,760
    Likes Received:
    3
    Location:
    Plantation, FL
    holy shit :rofl:
     
  9. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    I give him two fixes and he ignores both.
     
  10. o2

    o2 Witty Title Here OT Supporter

    Joined:
    Oct 4, 2005
    Messages:
    16,099
    Likes Received:
    11
    Location:
    Toronto
    Perl is so :greddy:
    Php is :buttsex:
     
  11. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    PHP is an ugly, pathetic piece of dog shit that successfully combines the worst features of C and Perl.
     
  12. o2

    o2 Witty Title Here OT Supporter

    Joined:
    Oct 4, 2005
    Messages:
    16,099
    Likes Received:
    11
    Location:
    Toronto
    Perl is the Windows 95 of the programming language world, but you gotta keep up with the times.
    :hs:
     
  13. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    LOL, if all you know about programming languages is fads, then that is true. Perl is SO yesterday. But then, so is PHP, and it is also a piece of crap language. Python is yesterday too. Ruby is where its at. :rolleyes:

    On the other hand if you need to actually create solutions that scale, are maintainable, etc. then Perl is superior to PHP in every single way.
     
  14. o2

    o2 Witty Title Here OT Supporter

    Joined:
    Oct 4, 2005
    Messages:
    16,099
    Likes Received:
    11
    Location:
    Toronto
    When I had the option to choose what I should learn, I looked at perl, and went like... :ugh: Its so messy.

    So I chose php. 70% of sites don't use php because its bad.
     

Share This Page