in reply to Must have CLI of Perl's sed's n command

Your formatting is kind of terrible, but you can check $. and skip if the first line (next if $. == 1). Another option might be to use the trick of using -M and a version to get something to run before the magical while wrapping the -n does. Use something like -M5.010’;scalar <>;’ to have the first line read (and discarded).

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: Must have CLI of Perl's sed's n command
by LanX (Saint) on Jun 30, 2022 at 02:34 UTC
    > Your formatting is kind of terrible,

    yep, that's one way to express it.

    > skip if the first line (next if $. == 1)

    If that's the goal (???) $.-1 is false for the first line only, he could && it with the flip-flop's start condition.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Re^2: Must have CLI of Perl's sed's n command
by abdan (Acolyte) on Jun 30, 2022 at 02:10 UTC
    seems we to conclude there's none, as
    next if $_ == ...
    is different; costlier & less eff. - i got/knew it in first place
      $_ and $. are not the same thing.

      Could you show the sed example you're trying to mimic? I'm not sure I understand.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]