Home > Archive > PERL Beginners > November 2005 > help parsing a string
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
help parsing a string
|
|
| maxdavinci@gmail.com 2005-11-18, 6:57 pm |
| hi,
i have a string
$str="hi|i|am|a|perl|script";
i want to extract the words that are separeated by a '|' into an array.
i tried using the split() function, but it worked for cases where the
'|' was replaced bya another char like say a ':'
can anyone help me in this regard?
| |
| usenet@DavidFilmer.com 2005-11-18, 6:57 pm |
| maxdavinci@gmail.com wrote:
> i have a string
> $str="hi|i|am|a|perl|script";
> i want to extract the words that are separeated by a '|' into an array.
my @words = split /\|/, $str;
> i tried using the split() function, but it worked for cases where the
> '|' was replaced bya another char like say a ':'
I don't know how you worded your split, but split is the correct
function (as shown above).
|
|
|
|
|