Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 imbibing at the Monastery: (5)
As of 2024-09-13 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (18 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.