Front page | perl.perl5.porters |
Postings from August 2001
Can't localize *FH, then tie it
Thread Next
From:
Ken Williams
Date:
August 1, 2001 22:04
Subject:
Can't localize *FH, then tie it
Message ID:
20010802000519-r01010700-98ec3021-0910-010c@10.0.0.2
Hi,
I just ran the following test program under 5.6.1:
==========================================
#!/usr/bin/perl -l
{
local *foo;
tie %foo, 'Blah';
}
print tied %foo ? 'not ok 1' : 'ok 1';
{
local *bar;
tie @bar, 'Blah';
}
print tied @bar ? 'not ok 2' : 'ok 2';
{
local *BAZ;
tie *BAZ, 'Blah';
}
print tied *BAZ ? 'not ok 3' : 'ok 3';
package Blah;
sub TIEHANDLE {bless {}}
sub TIEHASH {bless {}}
sub TIEARRAY {bless {}}
__END__
==========================================
The output is:
ok 1
ok 2
not ok 3
It seems like there's no way to let a filehandle revert to its former
state after exiting the block in which it was tied, though this can be
done with other data types. I consider it a bug, what do others think?
The only semi-relevant entry in bugs.perl.org was this one:
http://bugs.perl.org/_perlbug.cgi?req=bug_id&bug_id=19991103.009
Please point me to TFM if necessary.
Perhaps needless to say, I want to do this so that I can tie STDOUT in a
certain scope without clobbering a previous tie.
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=darwin, osvers=1.3.7, archname=darwin
uname='darwin localhost 1.3.7 darwin kernel version 1.3.7: sat jun 9
11:12:48 pdt 2001; root:xnuxnu-124.13.obj~1release_ppc power macintosh powerpc
'
config_args='-des -Dfirstmakefile=GNUmakefile'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='cc', ccflags ='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE
-fno-strict-aliasing -I/usr/local/include',
optimize='-O3',
cppflags='-pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing
-I/usr/local/include'
ccversion='', gccversion='Apple DevKit-based CPP 6.0alpha', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib
libs=-lm -lc
perllibs=-lm -lc
libc=/System/Library/Frameworks/System.framework/System, so=dylib,
useshrplib=true, libperl=libperl.dylib
Dynamic Linking:
dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined suppress -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under darwin
Compiled at 07/18/01 21:47:28
@INC:
/System/Library/Perl/darwin
/System/Library/Perl
/Library/Perl/darwin
/Library/Perl
/Library/Perl
/Network/Library/Perl/darwin
/Network/Library/Perl
/Network/Library/Perl
.
------------------- -------------------
Ken Williams Last Bastion of Euclidity
ken@forum.swarthmore.edu The Math Forum
Thread Next
-
Can't localize *FH, then tie it
by Ken Williams