This and other RFCs are available on the web at
http://dev.perl.org/rfc/
=head1 TITLE
Shell Style Redirection
=head1 VERSION
Maintainer: David Nicol <[EMAIL PROTECTED]>
Date: 8 Aug 2000
Version: 1
Mailing List: [EMAIL PROTECTED]
Number: 66
=head1 ABSTRACT
The C<use redirect> pragma or a new C<redirect> keyword is introduced
to allow redirection of streams of any kind into each other.
The keyword may not be really needed, as when does it make any
sense to do a lt or gt comparison with a file handle?
=head1 SUMMARY
sub callfritz{
local STDIN < $InputData;
local STDOUT > PREVIOUSLY_OPENED_HANDLE;
eval `cat fritz.pl`;
};
is proposed as an alternative to doing the same thing
with a variety of open2 calls.
with different semantics of global variables.
=head1 DESCRIPTION
I think we've got file re-opening already, some how; this
proposal overloads the less than and greater than operators
in order that subsequent statements,
particularly external routines that will be looking to
a file descriptor table for their file handles, will get from
and give to where we want them to.
The redirection is affected by the scoping operators like
any other variable which alters the situation.
It will also provide another way to capture STDERR from
within backticks.
sub ToolErrorsFirst{
# place to hold the output
my $tooloutput;
# place to hold the errors
my $errors;
# use redirect: very similar to shell redirection
my use redirect STDOUT > $tooloutput ;
# alternately, FILE > $scalar is obviously a redirect
# (if we accept the overload of >)
# so no additional keywords are required
my STDERR > $errors ;
$tooloutput = `tool @_`;
return $errors . $tooloutput;
};
Currently we have to do this kind of thing by using the
file system as temporary storage.
=head1 IMPLEMENTATION
This system was proposed within RFC 61 as an implementation detail,
it would impact the file handle team.
=head2 Compatibility with legacy code
Code that compares file handles, or compares file handles
with scalars, will break.
=head1 REFERENCES
http://dev.perl.org/rfc/39.pod
http://dev.perl.org/rfc/61.pod