mkmcconn has asked for the wisdom of the Perl Monks concerning the following question:
Why does this work?
This will read the _closed_ directory handle, without an error, if invoked as % perl test_file (where test_file) contains the above code.#!/usr/bin/perl -w use strict; opendir (TOPDIR,"$ENV{HOME}") or die "Thus shall ye likewise perish: $!"; close TOPDIR; while ($_=readdir(TOPDIR)){ print "$_\n"; }
But, I just discovered that if I chmod 0755 test_file, the code fails without a warning when invoked directly. So, I'm more confused than ever. What is happening here?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: read closed directory handle?
by KM (Priest) on Jan 27, 2001 at 02:41 UTC | |
Re: read closed directory handle?
by lemming (Priest) on Jan 27, 2001 at 02:42 UTC | |
Re: read closed directory handle?
by mkmcconn (Chaplain) on Jan 27, 2001 at 03:01 UTC |
Back to
Seekers of Perl Wisdom