Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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

by choroba (Cardinal)
on Nov 15, 2012 at 08:18 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1003954]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-03-28 17:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found