Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: split based upon string

by arc_of_descent (Hermit)
on Feb 04, 2010 at 10:06 UTC ( #821347=note: print w/ replies, xml ) Need Help??


in reply to split based upon string

Also read the documentation for the split function. You can pass a regex or a string as the delimiter.

my @parts = split 'DELIMITING_TEXT', $entire_string;

--
Rohan


Comment on Re: split based upon string
Download Code
Re^2: split based upon string
by almut (Canon) on Feb 04, 2010 at 10:54 UTC
    You can pass a regex or a string

    Just keep in mind that using single quotes around the pattern (instead of /.../) does not make it a plain string — it's still a regex.  Although this is not relevant here, it might make a difference in other cases:

    #!/usr/bin/perl -l my $s = 'xABCxACxABBCxAB*Cx'; print join(' - ', split('AB*C', $s)); # x - x - x - xAB*Cx

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://821347]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2015-07-03 00:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls