Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

lexical vs. local file handles

by jo37 (Pilgrim)
on Apr 18, 2020 at 18:26 UTC ( #11115734=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    open FH, '<', 'myfile';
    print FH, "something\n";
    
  2. or download this
    No comma allowed after filehandle at ...
    
  3. or download this
    open my $fh, '<', 'myfile';
    print $fh, "something\n";
    
  4. or download this
    open local *FH, '<', 'myfile';
    while (<FH>) {
        # do something
    }
    close FH;
    
  5. or download this
    #!/usr/bin/perl
    
    ...
    is \@bar, [$bar], 'good: got $bar';
    
    done_testing;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://11115734]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2020-09-22 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (127 votes). Check out past polls.

    Notices?