Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: When do filehandles close?

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.