Re: ignore first 9 lines...

2006-04-12 Thread Alan_C
Hi, > Just to muddy the waters a little more (and hopefully answer a > question I've had for a while): how does the "flip-flop" operator > function here: > > while (<>) { > next if 1..9; > # the rest of the code > } Since I (used to) try to turn stuff into Rocket Science, I

Re: ignore first 9 lines...

2006-04-12 Thread Tom Phoenix
On 4/12/06, Bryan R Harris <[EMAIL PROTECTED]> wrote: > Does the "next if 1..9" do something interesting? In scalar context, the ".." ("dotdot") operator does indeed do something quite interesting. And the fact that its operands are constants matters, too. See perlop for the full and somewhat com

Re: ignore first 9 lines...

2006-04-12 Thread Bryan R Harris
> "Jay> while (<>) { > "Jay> next if 1..9; > "Jay> # the rest of the code > "Jay> } Huh? I think I missed something here... Does the "next if 1..9" do something interesting? To me it seems like it'd evaluate "1..9" as "true" and do a next every time... - B -- To

Re: ignore first 9 lines...

2006-04-12 Thread Randal L. Schwartz
> ""Jay" == "Jay Savage" <[EMAIL PROTECTED]> writes: >> There. Happy? No more tests. And now you'll complain about the >> subroutine call. :) "Jay> Just to muddy the waters a little more (and hopefully answer a "Jay> question I've had for a while): how does the "flip-flop" operator "Jay> f

Re: ignore first 9 lines...

2006-04-12 Thread Jay Savage
On 10 Apr 2006 17:55:24 -0700, Randal L. Schwartz wrote: > > ""Charles" == "Charles K Clarkson" <[EMAIL PROTECTED]> writes: > > "Charles> Dr.Ruud wrote: > "Charles> : Bryan R Harris schreef: > "Charles> : > "Charles> :: for (1..9) { <>; } > "Charles> : > "Charles> : while (<>) > "Charles>

Re: ignore first 9 lines...

2006-04-12 Thread tom arnall
the following code: #!/usr/bin/perl -w use strict; use POSIX qw(locale_h); my ($f,@f,$g); setlocale(LC_COLLATE, "es_ES.ISO-8859-1"); @f = qw(oval óvalo zurrir); print "before sort:@f "; @f = sort @f; $f = setlocale(LC_

Re: ignore first 9 lines...

2006-04-10 Thread Randal L. Schwartz
> "Chad" == Chad Perrin <[EMAIL PROTECTED]> writes: Chad> The $meat = sub { . . . } bit creates an anonymous subroutine, and Chad> assigns a reference to it to the $meat variable. This allows you to Chad> effectively pass around code within a variable, to be dereferenced when Chad> you need i

Re: ignore first 9 lines...

2006-04-10 Thread Chad Perrin
On Mon, Apr 10, 2006 at 08:38:22PM -0500, Charles K. Clarkson wrote: > Randal L. Schwartz wrote: > > : my $meat; > : $meat = sub { > : $meat = sub { real body of loop here } if $. >= 9; > : }; > : > : $meat->() while <>; > : > : There. Happy? > > Smiling? Yes. Happy? No. > > > : No mor

RE: ignore first 9 lines...

2006-04-10 Thread Charles K. Clarkson
Randal L. Schwartz wrote: : my $meat; : $meat = sub { : $meat = sub { real body of loop here } if $. >= 9; : }; : : $meat->() while <>; : : There. Happy? Smiling? Yes. Happy? No. : No more tests. And now you'll complain about the : subroutine call. :) Are you kidding? I barely un

Re: ignore first 9 lines...

2006-04-10 Thread Chad Perrin
On Mon, Apr 10, 2006 at 12:29:55PM -0700, Bryan R Harris wrote: > > > On 4/10/06, Bryan R Harris <[EMAIL PROTECTED]> wrote: > > > > Unless you're writing Perl poetry, playing Perl golf, or paying extra > > for each byte of source code, I recommend that you write code in the > > most straghtforwar

Re: ignore first 9 lines...

2006-04-10 Thread Randal L. Schwartz
> ""Charles" == "Charles K Clarkson" <[EMAIL PROTECTED]> writes: "Charles> Dr.Ruud wrote: "Charles> : Bryan R Harris schreef: "Charles> : "Charles> :: for (1..9) { <>; } "Charles> : "Charles> : while (<>) "Charles> : { "Charles> : next if $. < 10; "Charles> : ... "Charles> :

Re: ignore first 9 lines...

2006-04-10 Thread Bryan R Harris
> On 4/10/06, Bryan R Harris <[EMAIL PROTECTED]> wrote: > >> I need to discard the first 9 lines of input before I get to the data I'm >> interested in... >> >> I'm using: >> >> for (1..9) { <>; } >> >> ... but that feels a little wordy. > > You're right: That superfluous punctuation makes

Re: ignore first 9 lines...

2006-04-10 Thread Tom Phoenix
On 4/10/06, Bryan R Harris <[EMAIL PROTECTED]> wrote: > I need to discard the first 9 lines of input before I get to the data I'm > interested in... > > I'm using: > > for (1..9) { <>; } > > ... but that feels a little wordy. You're right: That superfluous punctuation makes it look like the sup

RE: ignore first 9 lines...

2006-04-10 Thread Charles K. Clarkson
Dr.Ruud wrote: : Bryan R Harris schreef: : :: for (1..9) { <>; } : : while (<>) : { : next if $. < 10; : ... : } So a billion line file will require a billion tests instead of 9. That doesn't seem like a good idea. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 9

Re: ignore first 9 lines...

2006-04-10 Thread D. Bolliger
Bryan R Harris am Montag, 10. April 2006 20.44: > >> for (1..9) { <>; } > > > > while (<>) > > { > > next if $. < 10; > > ... > > } > > That's no good, it's even more wordy! <> for 1..9; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTE

Re: ignore first 9 lines...

2006-04-10 Thread Bryan R Harris
>> for (1..9) { <>; } > > while (<>) > { > next if $. < 10; > ... > } That's no good, it's even more wordy! - B -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: ignore first 9 lines...

2006-04-10 Thread Dr.Ruud
Bryan R Harris schreef: > for (1..9) { <>; } while (<>) { next if $. < 10; ... } -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]