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