Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Printing to a File from Sub

by Corion (Patriarch)
on Aug 26, 2010 at 17:51 UTC ( #857524=note: print w/replies, xml ) Need Help??


in reply to Printing to a File from Sub

In Perl, you do it the same.

my $logfile = 'file.txt'; open my $log_fh, '>>', $logfile or die "Couldn't open '$logfile': $!"; sub print_sub { my ($log) = @_; print {$log} "Starting work\n"; }; ... print_sub($log_fh);

But maybe you want Log::Log4perl?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://857524]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2022-12-02 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?