Front page | perl.beginners |
Postings from January 2002
RE: split and extraction
Thread Previous
|
Thread Next
From:
Nikola Janceski
Date:
January 30, 2002 07:26
Subject:
RE: split and extraction
Message ID:
1449413DA482D311B67000508B5A12F50592DC3B@nyexchange01.summithq.com
try
$abc = ( split /\s+/ )[8];
you can use the parenth with any function that returns an array, and just
pop a [] on the end.
FYI if you want the last element (not knowing what place it's in) just use
[$#_]
This only works if you are not using @_ (or $_ I think). Use caution
for [$#_].
-----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
----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.
Thread Previous
|
Thread Next