-----Original Message-----
From: Chris Devers [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 22, 2005 3:17 PM
To: Bret Goodfellow
Cc: Perl Beginners List
Subject: Re: finding needle in a haystack
On Wed, 22 Jun 2005, Bret Goodfellow wrote:
> All right, I know how to do this in REXX because there is a word()
> function, but how do I do this in Perl.
The split() function is what you're looking for.
$ perldoc -f split
The perldoc gives this example:
A pattern matching the null string (not to be confused with a
null pattern "//", which is just one member of the set of pat-
terns matching a null string) will split the value of EXPR into
separate characters at each point it matches that way. For
example:
print join(':', split(/ */, 'hi there'));
produces the output 'h:i:t:h:e:r:e'.
It shouldn't be hard to adapt this example to your needs.
--
Chris Devers
Thanks Chris,
This is what I actually did to resolve my issue:
@words = split(/ * /, $line)
Print "the third word is: $words[2]\n";
Bret Goodfellow
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>