On Aug 20, Darren Edgerton said:

>my $i = () = $str =~ /^\s/;
>print $i;

Your regex doesn't match globally, which is what you assumed, methinks.

You could do:

  my $leading = () = $str =~ /\G\s/g;

but that's more effort than I think you should need.  You can just use:

  my $leading = length( ($str =~ /(\s*)/)[0] );

or, a bit more drawn out:

  $str =~ /\s*/;
  my $leading = length $1;

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to