develooper Front page | perl.beginners | Postings from January 2002

RE: split and extraction

Thread Previous | Thread Next
From:
Hanson, Robert
Date:
January 30, 2002 07:34
Subject:
RE: split and extraction
Message ID:
11A304418ECBAB498FBF10ABCEA5E499D1CD92@hq2kax1.nj.aptegrity.com

Actually it was "[split /\s+/]->[8]" not "split[/\s+/]->[8]", and you only
need to do it like that if you are using it in a "print" statement (I
couldn't get it to work otherwise).  Otherwise you can use the method Nikola
explained or using the method you use below (the one that works).

Rob


-----Original Message-----
From: Dhiraj P Nilange [mailto:dhiraj_nilange@rediffmail.com]
Sent: Wednesday, January 30, 2002 10:19 AM
To: beginners@perl.org
Subject: split and extraction



Hi there

I want to extract some word after space from some string.
Somebody from the mailing list had given me above
command.

suppose I wanto extract 8th word...

#suppose $abc  has the string;
$abc=split[/\s+/]->[8];   #somebody told me like this.

but it doesnt work. if i use some array in the split function like:-

@array=split(/\s+/,$abc);
print $array[8];

this way it works. But I dont want to use array. Its newbie question
actually.

pls help.

Thanks
-Dhiraj
 


-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

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