Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
There's more than one way to do things
 
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 examining the Monastery: (7)
As of 2014-04-20 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls