On Tuesday, May 14, 2002, at 11:38 , Adam Morton wrote:

> Since this is a beginners list, I guess someone (i.e. me) should point out
> that perhaps the simplest way to read an array from STDIN is to do 
> something
> like:
>
> @theseLines = <STDIN>;
>
> This will by default add one array entry per line of user input until the
> user enters a cntrl-d.

one of the reasons we advocate not doing this is
that it is a bad habit to get out of once started.

so yes, while simple - I still fear it is more of a 'feature'
that should be used sparingly, if at all....

Also as one meanders along, one will need to deal
with 'arbitrarily large' files which would BLOAT
out one's code in core to fill that @theseLines
in one Gulp - which you probably wanted to do some
of the basic filtering along the way anyway.

        while(<STDIN>) {
                next if /^\s*$/ ;       #throw away the blank lines.
                ....                            # what we do with the input to make 
output
                print $output ;
        }

would be the general format for an inline filter...

Also, as you notice - given that much of the 'read from STDIN'
is about munging the input for specific details - then why
not munge in line and then go on.


ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to