in reply to help with this snippet: if($.==2||$&&&!$s++)

« $&&&!$s++ » is « $& && !($s++) ».


!$s++ is a neat construct. It's true the first time it is evaluated, and only the first time it is evaluated.

$ perl -E'say !$s++ ? 1 : 0 for 1..5;' 1 0 0 0 0

It's often used to remove duplicates.

$ perl -E'say grep !$seen{$_}++, split //, "abracadabra";' abrcd

As for $&, it is set by the match operator. The only match operator in the code is /^-+$/, so $& will be false until the first time that matches, and it will always be true afterwords.


The code prints the following lines:


I'm surprise the person who wrote that doesn't know about -n. He also left in unneeded spaces and parens despite his golfing attempt.

svmon -Pt15 | perl -e 'while(<>){print if($.==2||$&&&!$s++);$.=0 if(/^ +-+$/)}' | v svmon -Pt15 | perl -ne'print if$.==2||$&&&!$s++;$.=0if/^-+$/' svmon -Pt15 | perl -nlE'say if$.==2||$&&&!$s++;$.=0if/^-+$/'