develooper Front page | perl.perl6.language | Postings from May 2001

Re: Apoc2 - <STDIN> concerns

From:
David L. Nicol
Date:
May 10, 2001 16:54
Subject:
Re: Apoc2 - <STDIN> concerns
Message ID:
3AFB294C.AA74110E@kasey.umkc.edu

how to pull the next four lines out of a file handle in
way new syntax,

Larry Wall wrote:
> 
> Dave Storrs writes:
> : < QUOTE LARRY >
> : Dave Storrs writes:
> :     @foo = $STDIN * 4;
> :
> : Larry


What's wrong with old-fashioned autoextending array slices that
now DWIM

	splice @foo,@foo,4,readline(STDIN);

Getting splice to coerce that reference that @foo is returning
into it's length method is all behind-the-scenes;  this is
a toenail-trimming incremental improvement which would break
any very strange code which did exactly that and expected readline
in an array context to wipe out the rest of the stream.  I've
got $2.37 for the first person to produce a piece of code not
contrived as an example where a slurp in a splice is used.



-- 
                      David Nicol 816.235.1187 dnicol@cstp.umkc.edu
                                                     # die smiling;




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About