Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Cannot read in multiple lines

by tachyon (Chancellor)
on Nov 04, 2002 at 10:19 UTC ( #210150=note: print w/ replies, xml ) Need Help??


in reply to Re: Cannot read in multiple lines
in thread Cannot read in multiple lines

We don't need the close - the filehandle will automatically be closed when it falls out of scope.

Actually that is wrong. FILE globs are not locally scoped.

C:\>type test.pl sub open_file_handle { open FILE, ">c:/test.txt" or die $! } open_file_handle(); print FILE "This file handle is not closed!" or die $! C:\>perl test.pl C:\>type test.txt This file handle is not closed! C:\>

If you really feel that not explicitly closing your filehandles is good programming practice and want to depend on Perl doing it for you you need to use

open my $fh, $file or die $!;

From memory this is only valid for Perl 5.6+

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


Comment on Re: Re: Cannot read in multiple lines
Select or Download Code
Re^3: Cannot read in multiple lines
by adrianh (Chancellor) on Nov 07, 2002 at 03:04 UTC

    Quite correct. Me very very foolish. Bad Adrian.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://210150]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2015-07-03 22:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls