-----Original Message----- From: Chas. Owens [mailto:chas.ow...@gmail.com] Sent: Wednesday, May 27, 2009 4:52 PM To: sanket vaidya Cc: beginners@perl.org Subject: Re: Question about split
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; Got it. Thanks Chas -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. _____________________________________________________________________ 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/