develooper Front page | perl.beginners | Postings from October 2009

Question about split

Thread Next
From:
sanket vaidya
Date:
October 23, 2009 20:00
Subject:
Question about split
Message ID:
C71A933D25854F229A4F936BCC171B45@patni.com
Hi,

 

Consider the code below:

 

use warnings;

use strict;

my $string = '100955 BLow-Gomez,Joseph MMEX.AMER. QHUTC012';

 

my ($id) = split(/\s/,$string);

 

print "id = $id";

 

Output:

 

100955

 

Now remove brackets surrounding $id like as under:

 

use warnings;

use strict;

my $string = '100955 BLow-Gomez,Joseph MMEX.AMER. QHUTC012';

 

my $id = split(/\s/,$string);

 

print "id = $id";

 

Output:

4

 

This is the no. of elements in the array generated by split.

 

Why in first case (when brackets are used) it prints correct id?

 

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 netadmin@patni.com and delete this mail.
_____________________________________________________________________

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About