Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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 rifling through the Monastery: (12)
As of 2014-09-22 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls