Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

split delimiters

by Anonymous Monk
on Mar 27, 2001 at 01:21 UTC ( #67334=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Although I have worked on Perl for a few months, I am quite the major rookie. I am working on a script where I need to split lines of a report into fields and I am having problems using ( and [ as delimiters. There is really no other way to split this and I have no clue what to do..can you help me please!!!!! My deadline is approaching?!??!??!?!?!

Replies are listed 'Best First'.
Re: split delimiters
by busunsl (Vicar) on Mar 27, 2001 at 01:26 UTC
    Since ( and [ are special characters in regular expressions, you have to escape them:
    split /\(/, 'some(odd(string'; split /\[/, 'next[odd[string';
      Or, just in case both of these delimiters should be used for one split...

      split /[\[\(]/, 'some(next[really(really(odd[string';
        Well, in that case you don't have to escape them, because they are in sqare brackets:
        split /[([]/, 'some(wierd[string';
Re: split delimiters
by myocom (Deacon) on Mar 27, 2001 at 01:24 UTC

    This would be infinitely easier if you were to post your script (make sure to enclose it in <code> tags!), some sample data, the expected output, and what you're getting now.

Re: split delimiters
by wardk (Deacon) on Mar 27, 2001 at 01:25 UTC

    there is going to be a number of ways to slay this dragon.

    Please provide a couple of data records as an example of the actual data, and if you have some, post the code that currently isn't making it happen for you...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://67334]
Approved by root
help
Chatterbox?
[Eily]: someday FF will start posting back messages where you tell to ignore the previous message
[Eily]: and Hilarity Ensues
Eily says, while failing to write a link properly
[Your Mother]: Goodbye Fancy Feast! Hello Friskies!!!
[LanX]: CB sidebar auto-expansion problem
[Eily]: "tail: warning: following standard input indefinitely is ineffective". I can't help but feel that tail is judging me...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2017-03-27 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.