On Fri, 7 Sep 2001, eric wang wrote:

> how do i split on underscore?( _ ) and on hyphen? ( - )?
>
> i tried split(/\_/, $var) but didn't work
> and I also tried split ('_', $var) but didn't work also.

You should be able to split directly on _ and - :

$ perl -e '$str =q(a_string); foreach (split /_/, $str) { print "$_\n"}'

a
string

$ perl -e '$str = q(a-string); foreach (split /-/, $str) { print "$_\n"}'

a
string

-- Brett
                                          http://www.chapelperilous.net/
------------------------------------------------------------------------
All phone calls are obscene.
                -- Karen Elizabeth Gordon


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to