summaryrefslogtreecommitdiff
path: root/lib/File
diff options
context:
space:
mode:
authorchromatic <chromatic@wgz.org>2002-02-21 07:17:35 -0700
committerJarkko Hietaniemi <jhi@iki.fi>2002-02-21 21:06:54 +0000
commit83716b1ec25b41f24c18a3bf323e7910d4cadf90 (patch)
treefa82a88267bf77b09c707db5f9837686b2f2b4e3 /lib/File
parent97f88e98ef11d37351fa5dff900a7233f5a4d2ff (diff)
downloadperl-83716b1ec25b41f24c18a3bf323e7910d4cadf90.tar.gz
Find Filehandles Fully (was Re: [ID 20020221.004] [PATCH] File/stat.pm , Perl 5.6.1)
Message-ID: <20020221211823.80922.qmail@onion.perl.org> p4raw-id: //depot/perl@14819
Diffstat (limited to 'lib/File')
-rw-r--r--lib/File/stat.pm2
-rw-r--r--lib/File/stat.t18
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/File/stat.pm b/lib/File/stat.pm
index 0c479d21f4..af75befe85 100644
--- a/lib/File/stat.pm
+++ b/lib/File/stat.pm
@@ -53,7 +53,7 @@ sub stat ($) {
local $!;
no strict 'refs';
require Symbol;
- $fh = \*{Symbol::qualify($arg)};
+ $fh = \*{ Symbol::qualify( $arg, caller() )};
return unless defined fileno $fh;
}
return populate(CORE::stat $fh);
diff --git a/lib/File/stat.t b/lib/File/stat.t
index 0487b8b51a..0c2f22d45f 100644
--- a/lib/File/stat.t
+++ b/lib/File/stat.t
@@ -16,10 +16,10 @@ BEGIN {
$hasst = 0 unless $Config{'i_sysstat'} eq 'define';
unless ($hasst) { plan skip_all => "no sys/stat.h"; exit 0 }
our @stat = stat "TEST"; # This is the function stat.
- unless (@stat) { print "1..0 # Skip: no file TEST\n"; exit 0 }
+ unless (@stat) { plan skip_all => "1..0 # Skip: no file TEST"; exit 0 }
}
-plan tests => 16;
+plan tests => 19;
use_ok( 'File::stat' );
@@ -56,6 +56,20 @@ is( $stat->blksize, $stat[11], "IO block size in position 11" );
is( $stat->blocks, $stat[12], "number of blocks in position 12" );
+SKIP: {
+ local *STAT;
+ skip(2, "Could not open file: $!") unless open(STAT, 'TEST');
+ ok( File::stat::stat('STAT'), '... should be able to find filehandle' );
+
+ package foo;
+ local *STAT = *main::STAT;
+ main::ok( my $stat2 = File::stat::stat('STAT'),
+ '... and filehandle in another package' );
+ close STAT;
+
+ main::is( "@$stat", "@$stat2", '... and must match normal stat' );
+}
+
local $!;
$stat = stat '/notafile';
isn't( $!, '', 'should populate $!, given invalid file' );