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:
Nested string splitting using multiple separators ?

 



hozzi.fozzi
New User

Jan 4, 2012, 8:24 AM

Post #1 of 3 (1064 views)
Nested string splitting using multiple separators ? Can't Post

Hi,

I'm looking for a smart way to split up a string in an nested manner using multiple field separators. An example of a string I would like to split is:

$string = "flintstones,jetstones,#fred,barney,wilma,dino#";

The split patterns I would like to use for this example are [#,]. The split should be executed using the specified patterns in preceeding order.

The resulting array should contain 3 elements and should look like:

@a = ("flintstones", "jetstones", "fred,barney,wilma,dino");

Thank you in advance for your help!!


FishMonger
Veteran / Moderator

Jan 4, 2012, 9:22 AM

Post #2 of 3 (1060 views)
Re: [hozzi.fozzi] Nested string splitting using multiple separators ? [In reply to] Can't Post

Use Text::CSV
http://search.cpan.org/~makamaka/Text-CSV-1.21/lib/Text/CSV.pm


hozzi.fozzi
New User

Jan 5, 2012, 4:35 AM

Post #3 of 3 (1042 views)
Re: [hozzi.fozzi] Nested string splitting using multiple separators ? [In reply to] Can't Post

Hi FishMonger,

Great! This does the job! Many Thanks!

 
 


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

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