|
|
|
Your skill will accomplish what the force of many cannot |
|
| PerlMonks |
Re: regex extracting textby GrandFather (Cardinal) |
| on Apr 29, 2012 at 04:17 UTC ( #967891=note: print w/ replies, xml ) | Need Help?? |
|
Often instead of using the non-greedy ? to modify .*, use a negated character class:
which makes the nature of the match clearer ("I want everything except '.'") and generally leads to fewer surprise matches. Note too that you should always use strictures (use strict; use warnings;) and (almost) never use prototypes. Assigning parameters to explicitly named variables helps make their use clearer, the nature of the parameters and use of the sub clearer, and avoids accidentally altering the variables passed into the sub (the elements in @_ are aliases to the parameters passed in).
True laziness is hard work
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||