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

Hi,

Why do you close STDOUT. You can use select instead.
I don't see why you use seek in your code when you open one filehandle for input and one for output. If you whould have used +> instead, you would need the seek. (see perldoc perlopentut).

use POSIX; use strict; my $TRAP=POSIX::tmpnam(); print "TMPFILE is $TRAP\n"; open(TMPFILE, "+> $TRAP") or die $!; select TMPFILE; eval { print 'Waka Waka' }; seek(TMPFILE,0,0); my $input=<INFILE>; close(INFILE>; select STDOUT; print $input;

This works fine for me.
---------------------------
Dr. Mark Ceulemans
Senior Consultant
IT Masters, Belgium

Replies are listed 'Best First'.
Re: Re: codeopen(INPUT, "INPUT") gives INPUT opened only for output
by belg4mit (Prior) on Nov 16, 2001 at 22:08 UTC
  • mce As tilly says select only handles prints without a specified handle but not explicit STDOUT.
  • mce I *did* originally have an open with >+ which s why that seek is still there.
  • -- perl -p -e "s/(?:\w);(<A HREF="/index.pl?node=st&lastnode_id=2437">st< +/A>)/'\$1/mg"