From: Ilya Zakharevich on
On 2010-06-26, C.DeRykus <derykus(a)gmail.com> wrote:
> () = <>;

Try to do it with a terabyte file...

Yours,
Ilya
From: John Kelly on
On Fri, 25 Jun 2010 22:08:54 -0700 (PDT), "C.DeRykus"
<derykus(a)gmail.com> wrote:

>> > � �my $data;
>> > � �while (<>) {
>> > � � � �chomp;
>> > � � � �length or next;
>> > � � � �$data = $_;
>> > � � � �last;
>> > � �}
>> > � �{
>> > � � � �local $/ = \2048;
>> > � � � �1 while <>;
>> > � �}
>>
>> >Ben
>>
>> That looks interesting, �I get the first part, the rest will give me
>> something to chew on ...
>>
>
>But, this'll just read/toss 2048 byte chunks
>till EOF. Alternatively, if you want to toss
>the entire stream after exiting the loop, a
>single statement:
>
> <>;
>
>does what you want due to the list context. I
>suspect there's little to gain by changing $/.

That doesn't look like list context to me. Testing a small data set
containing:

>
>
>
>one
>two
>
>three
>
>four
>

with this code:

-----------------------

#!/usr/bin/perl

use strict;
use warnings;

my $data = '';

while (<>) {
chomp;
/^\s*$/ and next;
$data = $_;
print "data=\"$data\"\n";
last;
}

<> or die "1 EOF\n";
<> or die "2 EOF\n";
<> or die "3 EOF\n";
<> or die "4 EOF\n";
<> or die "5 EOF\n";
<> or die "6 EOF\n";
<> or die "7 EOF\n";
<> or die "8 EOF\n";
<> or die "9 EOF\n";

close STDIN;


--------------------------------

produces output:

>data="one"
>6 EOF


Which seems to prove that a bare <> is scalar context.



--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php

From: C.DeRykus on
On Jun 25, 11:16 pm, Ilya Zakharevich <nospam-ab...(a)ilyaz.org> wrote:
> On 2010-06-26, C.DeRykus <dery...(a)gmail.com> wrote:
>
> >       () = <>;
>
> Try to do it with a terabyte file...
>

Hm, sounds like I need to look more closely...

So a humongous temp array gets built with only
the resulting assignment being optimized away...?

--
Charles DeRykus

perl -MO=Concise -e "()=<>"
8 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
7 <2> aassign[t3] vKS ->8
- <1> ex-list lK ->6
3 <0> pushmark s ->4
5 <1> readline[t2] lK/1 ->6
4 <#> gv[*ARGV] s ->5
- <1> ex-list lK ->7
6 <0> pushmark s ->7
- <0> stub lPRM* ->-
From: John Kelly on
On Sat, 26 Jun 2010 06:16:29 +0000 (UTC), Ilya Zakharevich
<nospam-abuse(a)ilyaz.org> wrote:

>On 2010-06-26, C.DeRykus <derykus(a)gmail.com> wrote:
>> () = <>;
>
>Try to do it with a terabyte file...

Aim gun at foot. Pull trigger. Not my concept of fun.


--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php

From: John Kelly on

Thanks for the ideas, wrong ones too. They taught me more Perl, and got
me pointed in the right direction.


--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php