« $&&&!$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:
- The second line of the file, unless the first line of the file consists entirely of dashes. [ I suspect this is unintentional and never happens. ]
- The line that comes after the first line of the file consisting entirely of dashes.
- The second line following a line consisting entirely of dashes, unless it or the line before it consists entirely of dashes.
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/^-+$/'
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.