On Wed, May 27, 2009 at 06:45, sanket vaidya <sanket.vai...@patni.com> wrote:
> Hi all,
>
> Kindly look at the code below:
>
> use warnings;
> use strict;
>
> $_ = 'Welcome to openSUSE 11.0 (X86-64) - Kernel \r (\l).';
>
> my @numbers = split /\D+/;
snip
> Why the first element of @numbers is 'blank'? Kindly explain with example.
snip

For the same reason ",1,2,3" when split with /,/ produces ("", 1, 2,
3).  The regex you pass to split is the field separator.  The fact
that it finds a field separator before it finds a field data means the
first field is empty.  You may find that what you want is a normal
regex like

my @numbers = /(\d+)/g;



-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
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