Split string on multiple character delimeters

A

Aaron DeLoach

I am trying to split a string based on a multiple character delimiter and
place it into a hash. After a few hours I came up with the following:

my $str = "color%=red%;lang%=engl";
my %hash = split /%;|%=/, $str, -2;

It works, but I would like to know if it's the right method :)
 
A

Anno Siegel

Aaron DeLoach said:
I am trying to split a string based on a multiple character delimiter and
place it into a hash. After a few hours I came up with the following:

my $str = "color%=red%;lang%=engl";
my %hash = split /%;|%=/, $str, -2;

It works, but I would like to know if it's the right method :)

The right method would largely depend on what data it is likely to
encounter, what's at stake if it fails, and a lot more things we know
nothing about. There's nothing obviously wrong with it.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top