[Reply to perl6-language-io as this is an I/O
related.]

Michael Mathews wrote:
> 
> Here's a thought. Wouldn't this be cool (see below)?
The idea is that in
> Perl 6 you should be able to read from a file handle
one character or one
> line at a time (just like you can in Perl 5) BUT if
you just go ahead and
> use the filehandle, directly, in a scalar context
then perl will read it in
> as a string most efficiently, and allow you to
perform your rgex, or
> whatever without creating a temporary variable just
to hold the contents of
> that file.

This is what the angle brackets do currently, unless I
misunderstand you.  I don't like the no-operator
syntax you propose, because it hides the file
operation.  I'd rather have a filehandle stringify to
the filename instead.

> open FH, $filepath;
> ($found) = FH =~ /pattern/; 
> print $found;

open FH, $filepath;
($found) = <FH> =~ /pattern/; # or print <FH> =~
/pattern/;
print $found;

> #or just
> 
> print FH;

print <FH>;
 
> #or, for example
> 
> @things = split /delimiter/, FH;

@things = split /delimiter/, <FH>;
 
> And how would s// work, I wonder? Hmmm... something
to think about! Anyone
> one smarter than me (includes nearly all of you)
have a thought on this?

<FH> =~ s/pattern/replacement/; # dies in current Perl

Perhaps this behaviour should be changed for files
opened '+<'?

Jon

__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/

Reply via email to