Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
"be consistent"
 
PerlMonks  

Re: Can I write and close a file in a subroutine?

by choroba (Abbot)
on Nov 15, 2012 at 08:18 UTC ( #1003954=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub test_and_write {
        my ($TWR, $condition) = @_;
        print $TWR "True\n" if $condition;
    }
    
  2. or download this
    open my $OUT, '>', 'output.txt' or die "Cannot open output.txt: $!";
    test_and_write($OUT, int rand 2);
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2014-04-18 05:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (461 votes), past polls