> 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 <[email protected]> Sent: Monday, August 31, 2020 10:28 AM To: Brian Duggan <[email protected]> Cc: Andy Bach <[email protected]>; perl6-users <[email protected]> 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 <[email protected]> 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
