On Mon, Jul 30, 2001 at 04:40:56PM -0400, Casey West wrote:
: On Mon, Jul 30, 2001 at 02:19:00PM -0700, Paul wrote:
: :
: : --- Casey West <[EMAIL PROTECTED]> wrote:
: : > Yes, I imagine it would be a fun thing for beginners to see. Some
: : > might try hard to understand them. A teaser would b
On Mon, Jul 30, 2001 at 02:19:00PM -0700, Paul wrote:
:
: --- Casey West <[EMAIL PROTECTED]> wrote:
: > Yes, I imagine it would be a fun thing for beginners to see. Some
: > might try hard to understand them. A teaser would be fine but, the
: > entirety of a one-liner thread most likley doesn't
--- Casey West <[EMAIL PROTECTED]> wrote:
> Yes, I imagine it would be a fun thing for beginners to see. Some
> might try hard to understand them. A teaser would be fine but, the
> entirety of a one-liner thread most likley doesn't belong on the
> beginners lists[*]. Not to mention, Fun With P
--- David Blevins <[EMAIL PROTECTED]> wrote:
> Truly astounding.
lol
> From: Paul [mailto:[EMAIL PROTECTED]]
> > --- David Blevins <[EMAIL PROTECTED]> wrote:
> > > > perl -nle 'print if !$seen{$_}++'
> > >
> > > $seen{$_}
> > >
> > > Tries to lookup the line in the hash of lines we've alr
On Mon, Jul 30, 2001 at 02:16:42PM -0600, Canavan, John wrote:
: Hopefully, at least some beginners would find this playful and entertaining
: enough that they'd be willing to work a little harder to understand the
: code. When I'm learning a new language, I enjoy reading playful but hard
: code
Truly astounding.
From: Paul [mailto:[EMAIL PROTECTED]]
>
> --- David Blevins <[EMAIL PROTECTED]> wrote:
> > > perl -nle 'print if !$seen{$_}++'
> >
> > $seen{$_}
> >
> > Tries to lookup the line in the hash of lines we've already seen.
> >
> > $seen{$_}++
> >
> > This is a complete guess, I c
>It is beautiful, but I fear it could scare a beginner away. I'd rather
>such brilliance were directed to the Fun With Perl list than exposed to
>people many of whom are no doubt still wondering whether Perl is a
>write-only language.
>Which might be a cue for Tim Maher to pipe up and talk ab
--- David Blevins <[EMAIL PROTECTED]> wrote:
> > perl -nle 'print if !$seen{$_}++'
>
> The dash n (-n) puts the command 'print if !$seen{$_}++' in a while
> (<>) { ... } loop. So we get:
>
> while (<>) {
> print if !$seen{$_}++
> }
>
> $seen{$_}
>
> Tries to lookup the line in the hash
At 12:21 PM 7/30/01 -0700, I wrote:
>It is beautiful, but I fear it could scare a beginner away. I'd rather
>such brilliance were directed to the Fun With Perl list than exposed to
>people many of whom are no doubt still wondering whether Perl is a
>write-only language.
Harrumph, I wasn't cau
Yikes! This is what I was talking about. Amazing.
Let me take a crack at the first one -- should be entertaining for everyone
;)
From: Jeff 'japhy/Marillion' Pinyan
>
> Here's a one-liner:
>
> perl -nle 'print if !$seen{$_}++'
The dash n (-n) puts the command 'print if !$seen{$_}++' in a wh
At 02:47 PM 7/30/01 -0400, Jeff 'japhy/Marillion' Pinyan wrote:
>On Jul 30, Paul said:
>
> >--- Jeff 'japhy/Marillion' Pinyan <[EMAIL PROTECTED]> wrote:
> >> perl -pe '$_ x= !$seen{$_}++' (attributed to some of Larry's genius)
> >
> >LOL!!! Twistedly brilliant!
> >
> >Ok, lemme see if I can parse
> >--- Jeff 'japhy/Marillion' Pinyan <[EMAIL PROTECTED]> wrote:
> >> perl -pe '$_ x= !$seen{$_}++'
> >>(attributed to some of Larry's genius)
> >
> >LOL!!! Twistedly brilliant!
> >
> >Ok, lemme see if I can parse this.
> [correct prognosis snipped]
> >Is that right?
>
> Yes. I attribut
On Jul 30, Paul said:
>--- Jeff 'japhy/Marillion' Pinyan <[EMAIL PROTECTED]> wrote:
>> perl -pe '$_ x= !$seen{$_}++' (attributed to some of Larry's genius)
>
>LOL!!! Twistedly brilliant!
>
>Ok, lemme see if I can parse this.
[correct prognosis snipped]
>Is that right?
Yes. I attribute that
--- Jeff 'japhy/Marillion' Pinyan <[EMAIL PROTECTED]> wrote:
> perl -pe '$_ x= !$seen{$_}++' (attributed to some of Larry's genius)
LOL!!! Twistedly brilliant!
Ok, lemme see if I can parse this.
perl -pe says print each line after the -e code has been executed.
"$_ x= !$seen{$_}++" say
On Jul 30, Paul said:
>> while (){
>>if (not $seen{$_}) {
>>$seen{$_} = 1;
>> print OUTFILE;
>> }
>> else {
>> }
>> }
Here's a one-liner:
perl -nle 'print if !$seen{$_}++'
and here's another:
perl -pe '$_ x= !$seen{$_}++' (attributed to some of Larry's g
--- Carl Rogers <[EMAIL PROTECTED]> wrote:
> One word of caution it looks to me like this will catch
> duplicates lines, just as long as the duplicate lines follow each
> other. . . .
I posted a one-liner that does the same as the code below. =o)
>
> while (){
>if (not $seen{$_}) {
>
One word of caution it looks to me like this will catch duplicates
lines, just as long as the duplicate lines follow each other. You may want
to do some kind of a sort process prior to running this line of code.
Only reason I bring this up... I've been bitten by this same problem in the
pas
--- David Blevins <[EMAIL PROTECTED]> wrote:
> Here is a one-liner I just wrote to delete duplicate lines in a file.
>
> perl -ni.bak -e 'unless ($last eq $_){print $_};$last=$_;' theFile
That requires that it be sorted, doesn't it?
> Going with the TMTOWTDI credo, I was just curious if anyone
Here is a one-liner I just wrote to delete duplicate lines in a file.
perl -ni.bak -e 'unless ($last eq $_){print $_};$last=$_;' theFile
Going with the TMTOWTDI credo, I was just curious if anyone knew of a better
way.
Thanks,
David
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
19 matches
Mail list logo