Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-20 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found