chb has asked for the wisdom of the Perl Monks concerning the following question:
It gives me#! /usr/bin/perl -w use FileHandle; $fh=FileHandle->new(">blarg"); open(STDOUT, ">&$fh") or die "Argh: $!"; print "foo bar\nbaz\n"; $fh->close();
After intense manual study I came across this solution:Argh: Invalid argument at chb.pl line 6.
It works, but it looks really ugly. My Question is: is there a cleaner way to do this ? Have I missed some manpage ?#! /usr/bin/perl -w use FileHandle; $fh=FileHandle->new(">blarg"); open(STDOUT, sprintf(">&=%d", $fh->fileno())); print "foo bar\nbaz\n"; $fh->close();
|
---|