Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Printing to a File from Sub

by Corion (Patriarch)
on Aug 26, 2010 at 17:51 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found