Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Anno's scratchpad

by Anno (Deacon)
on Feb 14, 2006 at 13:04 UTC ( [id://530108]=scratchpad: print w/replies, xml ) Need Help??

# to call the subroutine you now do this: # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # log_file($logfile, "I want to append this text to the file"); #This subroutine creates a time stamp.. when i print it outside the su +broutine it prints out nicely, when i put print "$file"; sub get_timestamp { my($sec,$min,$hour,$mday,$mon,$year) = localtime(time) +; if ($mon < 10) { $mon = "0$mon"; } if ($hour < 10) { $hour = "0$hour"; } if ($min < 10) { $min = "0$min"; } if ($sec < 10) { $sec = "0$sec"; } $year=$year+1900; return $year . '_' . $mon . '_' . $mday . '_' . $hour . '_' . $min . ' +_' . $sec; } my $unique_filename = '' . get_timestamp(); my $file = $unique_filename; my $logfile = '../' . FOLDER . "/$file"; #when i print logfile it gives a path.. it works fine. sub log_file{ #error says i can't open logfile or invalid use of concatenation my $logfile = shift; open (LOGFILE, ">>$logfile") or die "cannot open logfil +e for append: $!"; print LOGFILE join(" ",@_,"\n"); }
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-18 22:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found