Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: When do filehandles close?

by pg (Canon)
on Jul 23, 2004 at 00:04 UTC ( [id://376761]=note: print w/replies, xml ) Need Help??


in reply to Re: When do filehandles close?
in thread When do filehandles close?

Missed one little thing;-) as the OP already pointed out, reopen implicitly close a file handler.

However in this case $. (current line number for the last filehandle accessed) is not reset. I would prefer explicit close all the time simply because of this.

Update

Just add a piece of code for demon (name this script a.pl):

use strict; use warnings; open(SCRIPT, "<", "a.pl"); <SCRIPT>; <SCRIPT>; print $., "\n"; #close(SCRIPT); open(SCRIPT, "<", "a.pl"); <SCRIPT>; print $., "\n";

Try to comment or uncomment that close. If it is commented, print out:

2 3

If it is not commented:

2 1

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found