in reply to Creating Arrays on the Fly

Try using
while ($response=<$remote>){ #manipulate response here }

or if you want it in array form for later processing, something similar to :

while ($foo=<DATA>){chomp $foo;push @ary, $foo}; print "@ary"; __DATA__ foo bar baz quud quux

Question : why doesn't 1 while {push @ary,<DATA>} do what's expected?That is, take a line from <DATA> and push it onto @ary. I seem to get stuck in a infinite loop... What behavior of <DATA> am I missing?

Replies are listed 'Best First'.
Re: Re: Creating Arrays on the Fly(boo)
by chromatic (Archbishop) on Sep 11, 2001 at 21:51 UTC
Re:x2 Creating Arrays on the Fly(boo)
by grinder (Bishop) on Sep 12, 2001 at 10:46 UTC

    Try this:

      perl -le 'print push @foo, undef'

    It will return 1, the number of elements successfully pushed onto the array. And undef is what you get when you try to read from an exhausted file handle, hence, your push is always true, at least until you run out of swap space...

    --
    g r i n d e r