>From my understanding, the splitter always associated with two parts, the
front part and back part, in your example, the first splitter is "Welcome to
openSUSE ", whose front part is blank, so the first element of @numbers
should be empty.

You can try a simpler example as follows:

$_ = ":0";
my @numbers = split /:/;

which has a similar output.

HTH

Gene Hu

(Sorry, forgot the list in the previous mail)
2009/6/8 Ajay Kumar <ajay.kum...@synopsys.com>

> Because first element of the array is empty
>
>
> -----Original Message-----
> From: sanket vaidya [mailto:sanket.vai...@patni.com]
> Sent: Wednesday, May 27, 2009 4:16 PM
> To: beginners@perl.org
> Subject: Question about split
>
> 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+/;
>
>
>
> for (0..$#numbers)
>
> {
>
> print "$_ : $numbers[$_]\n";
>
> }
>
>
>
> Output:
>
> 0 :
>
> 1 : 11
>
> 2 : 0
>
> 3 : 86
>
> 4 : 64
>
>
>
> Why the first element of @numbers is 'blank'? Kindly explain with example.
>
>
>
>
>
> Thanks & Regards,
>
> Sanket Vaidya
>
>
>
>
> _____________________________________________________________________
>
> This e-mail message may contain proprietary, confidential or legally
> privileged information for the sole use of the person or entity to whom this
> message was originally addressed. Any review, e-transmission dissemination
> or other use of or taking of any action in reliance upon this information by
> persons or entities other than the intended recipient is prohibited. If you
> have received this e-mail in error kindly delete this e-mail from your
> records. If it appears that this mail has been forwarded to you without
> proper authority, please notify us immediately at netad...@patni.com and
> delete this mail.
> _____________________________________________________________________
>
> --
> 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