> Not getting back line #11 with
 perl -ne 'print if $. =~ /\b[3 2 5 11]\b/' test_lines.txt

Right, as the char class contains <space>, 1, 2, 3 and 5. I guess alternatives
 perl -ne 'print if $. =~ /\b(1|5|3|11)\b/' /tmp/lines.txt
line: 1
line: 3
line: 5
line: 11



________________________________
From: William Michels <w...@caa.columbia.edu>
Sent: Monday, August 31, 2020 10:28 AM
To: Brian Duggan <bdug...@matatu.org>
Cc: Andy Bach <andy_b...@wiwb.uscourts.gov>; perl6-users <perl6-us...@perl.org>
Subject: Re: print particular lines question

How would P5 handle line numbers > 10 ? Not getting back line #11 with
the P5 examples below:

$ raku -ne '.say if ++$ == 3|2|5|11' test_lines.txt
Line 2
Line 3
Line 5
Line 11

~$ perl -ne 'print if $. =~ /\b[3 2 5 11]\b/' test_lines.txt
Line 1
Line 2
Line 3
Line 5

~$ perl -ne 'print if $. =~ /\b[3,2, 5, 11]\b/' test_lines.txt
Line 1
Line 2
Line 3
Line 5

On Mon, Aug 31, 2020 at 8:17 AM Brian Duggan <bdug...@matatu.org> wrote:
>
> On Monday, August 31, Andy Bach wrote:
> > >  raku -ne '.say if $++ == 3|2|5' Lines.txt
> >
> > OT, maybe, but is
> > perl -ne 'print if $. =~ /\b[325]\b/' Lines.txt
> >
> > or
> > perl -ne 'print if $c++ =~ /\b[436]\b/' Lines.txt
> >
> > the best you can do in P5?
>
> I can't think of anything better :-)
>
> Brian

Reply via email to