M. Kristall wrote:
> John W. Krahn wrote:
>> Chad Perrin wrote:
>>> On Fri, Apr 21, 2006 at 12:48:51PM -0700, John W. Krahn wrote:
>>>> print/.*/g,$"while<>
> Yeah, that's it.
>>> Woah, that's pretty short.
>>
>> You can make it even shorter:
>>
>> print/.*/g,$"for<>
> They aren't quite the same though. 'while' loops if the condition is
> still true (scalar context). 'for' loops if there are more items in the
> array (array context).

"array context"??  There is no "array context".

$ cd /usr/lib/perl5/5.8.6/pod
$ egrep -c '\<array context' *.pod | grep ':[1-9]'
$ egrep -c '\<list context' *.pod | grep ':[1-9]'
perl5004delta.pod:1
perl561delta.pod:8
perl56delta.pod:6
perl571delta.pod:1
perl572delta.pod:1
perl58delta.pod:4
perlapi.pod:2
perlcall.pod:4
perldata.pod:9
perldebtut.pod:1
perldebug.pod:2
perldiag.pod:3
perlembed.pod:2
perlfaq4.pod:3
perlfaq5.pod:1
perlfaq7.pod:3
perlform.pod:1
perlfunc.pod:22
perlop.pod:16
perlrequick.pod:2
perlretut.pod:3
perlsub.pod:6
perltoc.pod:4
perltrap.pod:6


> while (<>) gets a little extra magic than just the normal <>.
> while (<>) is the same as while (local $_ = readline (ARGV))
> for (<>) is the same as for (readline (ARGV))

local??  There is no local.

$ echo "one
two
three" | perl -e'
while ( local $_ = <> ) {
    print;
    last if /three/;
    }
print;
'
one
two
three
$ echo "one
two
three" | perl -e'
while ( <> ) {
    print;
    last if /three/;
    }
print;
'
one
two
three
three




John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to