On Fri, Jul 08, 2005 at 01:52:38PM -0500, Jay Strauss wrote:
> sub parse {
>       my $str = $_[0];
> 
>       # Capture the parts, leading alpha, followed by n digits,
>       # followed optionally by alphas
>       $str =~ /([a-zA-Z]+)(\d+)([a-zA-Z]+)?/;
>       
>       my @str = ($1,$2,$3);   # put the matches back into an array

Of course, this could have been:

  my (@str) = $str =~ /([a-zA-Z]+)(\d+)([a-zA-Z]+)?/;

eliminating the need to refer specifically to the positional variables.

>       $str[1] =~ s/^0+//;     # strip leading 0s from digit portion

Personally, I typically use $str[1] += 0, but obviously that's a style
thing.
> 
>       return @str;
> }

-- 
Micah J. Cowan
[EMAIL PROTECTED]
_______________________________________________
vox-tech mailing list
[email protected]
http://lists.lugod.org/mailman/listinfo/vox-tech

Reply via email to