Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: codeopen INPUT opened only for output

by Anarion (Hermit)
on Nov 16, 2001 at 16:28 UTC ( [id://125806]=note: print w/replies, xml ) Need Help??


in reply to codeopen(INPUT, "<INPUT") gives INPUT opened only for output



Your trying to open a non defined filehandle, if you want to retore the output, you have to save it before closing it.
Try printing fileno(STDOUT).
#!/usr/bin/perl -lw use POSIX; my $TRAP = POSIX::tmpnam(); print STDERR "STDOUT= ".fileno(STDOUT); close(STDOUT); print STDERR "STDOUT= ".fileno(STDOUT); open(STDOUT, ">$TRAP") || die("$!: $TRAP"); #+> didn't work eval "print 'Waka waka!'"; seek(STDOUT, 0, 0); print STDERR "STDOUT= ".fileno(STDOUT); close(STDOUT); open(STDOUT, ">-"); print STDERR "STDOUT= ".fileno(STDOUT); open(INPUT, "<$TRAP") || die("$!: $TRAP"); $chldoutput = <INPUT>;

Theres no errors or warnings, perhaps you want to save STDOUT before closing it
open(MYSTDOUT, ">&STDOUT");

and later restore it with
open(STDOUT, ">&MYSTDOUT");


$anarion=\$anarion;

s==q^QBY_^=,$_^=$[x7,print

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://125806]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2025-07-20 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.