Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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 studying the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found