Mailing List Archive

Perl5.001m - Cannot dup DATA filehandle
Should it be possible to dup the DATA filehandle in Perl5.001m?

I've tried the following (crude example, but it illustrates my point), which
produces no output. The dup seems to work (no error message), but the read from
<INPUT> returns nothing.

Sample runs:

% load file
this is a file
% load __DATA__
%

Perl source:

--- snip ---
#!/usr/bin/perl

&load($ARGV[0]);

sub load {
local($file) = $_[0];
if ( $file eq '__DATA__' ) {
open(INPUT,"<&DATA") || die "$0: Can't open filehandle for $file - $!\n";
}
else {
open(INPUT,$file)|| die "Argh! Cannot load $file - $!\n";
}
print $_ while <INPUT>;
close(INPUT)
}

__DATA__
This is from the DATA section
of the program.
--- snip ---

Output from myconfig:

Summary of my perl5 (patchlevel 1) configuration:
Platform:
osname=freebsd, osver=2.0.5-release, archname=i386-freebsd
uname='freebsd bsd4me.dmacc.cc.ia.us 2.0.5-release freebsd 2.0.5-release
#0: fri sep 29 11:10:20 cdt 1995
cfr@bsd4me.dmacc.cc.ia.us:usrsrcsyscompilemykernel i386 '
hint=previous
Compiler:
cc='cc', optimize='-O', ld='ld'
cppflags='-DDEBUGGING'
ccflags ='-DDEBUGGING'
ldflags =''
stdchar='char', d_stdstdio=undef, usevfork=true
voidflags=15, castflags=0, d_casti32=undef, d_castneg=define
intsize=4, alignbytes=4, usemymalloc=y, randbits=31
Libraries:
so=so
libpth=/usr/lib /usr/local/lib
libs=-lm -lc -lcrypt
libc=/usr/lib/libc.so.2.1
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=define
cccdlflags='-DPIC -fpic', ccdlflags=' ', lddlflags='-Bshareable '

Thanks,
-Randy


--
Charles F. Randall E-mail: crandall@dmacc.cc.ia.us
UNIX Systems Programmer Voice: (515) 965-7057 FAX: (515) 965-7305