Noah Garrett Wallach wrote:

Okay I am having troubles finding this. in the perldoc modules.
Is there a slicker way to write the following?

        if ($line =~ /(Blah1)(.*)/) {

At this point we know that the pattern matched so $1 will contain the string "Blah1" and $2 will contain a string of zero or more non-newline characters.

         $blah = $1 if $1;

The test is redundant because we already know that "Blah1" is true.

             $blah2 = $2 if $2;

This only assigns the string in $2 to $blah2 if it is not "" or "0".

}


John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to