On 1/30/2009 12:59 AM, thebarn...@gmail.com wrote:
Hi I run this command and pipe the output to a perl one liner. not quite sure how it parses the data: svmon -Pt3 | perl -e 'while(<>){print if($.==2 || $& && !$x++); $.=0 if (/^--+$/)}' i understand that it resets the line count every time it sees a line of "----" and it then will print line 2 which is the summary line we are looking for. not sure what this part does "($.==2 || $& && !$x+ +)"
Technically, $. is a line number in the input file. Since the oneliner reset it for every line made of dashes ("---"), it becomes a sort of counter. $& is "last match", and !$x++ is "$x is false and then increment it. Since in Perl, undef and 0 are false statues, you can read it as "if the line number is 2, or if there was no match and $x (which will be incremented) is undefined or 0) this part is what gets you the lines that were not printed due to the $.=2 part.
-- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/