CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
SPLIT | delimited text

 



ZD
New User

Sep 4, 2002, 5:44 PM

Post #1 of 2 (598 views)
SPLIT | delimited text Can't Post

Hi,

I am having trouble splitting text strings with | delimiters using the SPLIT function.

Example

Troy|Mary|Jose|Tim

Can anyone guide me,

ZD


thebitch
User

Sep 4, 2002, 9:50 PM

Post #2 of 2 (596 views)
Re: [ZD] SPLIT | delimited text [In reply to] Can't Post

the "split" function requires a regexp pattern
on which to spilit on

split '|', 'Troy|Mary|Tim'
will not split on |, because | is a metacharacter,
and has special meaning in regular expressions

you'll be wanting to escape it, as in
split /\|/, 'Troy|Mary'

you'll be wanting to read
perldoc perlre

as well as
perldoc perlop
cause you could also say

split /\Qany old character[][][][]][\E/, $word

and that would split on the literal string

any old character[][][][]][

even though [] is a metacharacter

you also wanna read perldoc -f quotemeta

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives