|
|
| We don't bite newbies here... much | |
| PerlMonks |
Re: help with this snippet: if($.==2||$&&&!$s++)by ikegami (Pope) |
| on Nov 30, 2011 at 22:48 UTC ( #940963=note: print w/ replies, xml ) | Need Help?? |
|
« $&&&!$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.
It's often used to remove duplicates.
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.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||