For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > simultaneous delimiters









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author simultaneous delimiters
Luba Pardo

2006-10-20, 3:58 am

Dear all:

I wonder if it is possible to split a line with more than one delimiter at
the same time.
I have a file which delimiter is < and >, but if I only split by either <
or > I got a new line, which I do not need.


the sentece I have is something like this: @a1_s=split/\</,$line; . I tried
to incorporate someting like: @a1_s=split/\<,\s+/,$line;
but it does not work.
Does anybody have an idea how to work it out?
regards,
Luba

John W. Krahn

2006-10-20, 3:58 am

Luba Pardo wrote:
> Dear all:


Hello,

> I wonder if it is possible to split a line with more than one delimiter at
> the same time.
> I have a file which delimiter is < and >, but if I only split by either <
> or > I got a new line, which I do not need.
>
> the sentece I have is something like this: @a1_s=split/\</,$line;


@a1_s = split /[<>]/, $line;


John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
nobull67@gmail.com

2006-10-20, 6:56 pm



On Oct 20, 9:22 am, lubapa...@gmail.com (Luba Pardo) wrote:
> Dear all:
>
> I wonder if it is possible to split a line with more than one delimiter at
> the same time.
> I have a file which delimiter is < and >, but if I only split by either <
> or > I got a new line, which I do not need.
>
> the sentece I have is something like this: @a1_s=split/\</,$line; . I tried
> to incorporate someting like: @a1_s=split/\<,\s+/,$line;
> but it does not work.


Why did you think that splitting on < immedaitely followed by a comma
and one or more whitespace characters would help?

> Does anybody have an idea how to work it out?


Obviously splitting on /[<>]/ or /<|>/ would do what you say you want
but I suspect this is XY[1] (i.e. you don't really want to split at
all).

What is it you actually want to achieve?

[1] You want to do some unspecifed thing "X" you think this is achived
by doing "Y" (using split) so you ask how to do "Y".

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com