Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Anno's scratchpad

by Anno (Deacon)
on Feb 14, 2006 at 13:04 UTC ( #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? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-06-26 11:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (85 votes). Check out past polls.

    Notices?