i believe if split's first argument is not a regexp, a warning should
be emitted.
------- Forwarded Message
Date: Wed, 25 Oct 95 08:44:27 PDT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: re: regular expression / split help
To: tchrist@mox.perl.com
Newsgroups: comp.lang.perl.misc
Subject: Re: [Help] Regular expression / split question
Summary:
Expires:
References: <465lsg$idg@dolphin.pst.cfmu.eurocontrol.be> <DGrA5u.7H@bcstec.ca.boeing.com> <46
jj06$hej@csnews.cs.colorado.edu>
Sender:
Followup-To:
Distribution:
Organization: The Boeing Company
Keywords:
Cc:
In article <46jj06$hej@csnews.cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>:-> In comp.lang.perl.misc, ced@bcstec.ca.boeing.com (Charles DeRykus) writes:
>: @f = split("|");
>
>That's not going to work right. Split takes a regexp as its first argument:
>
> @f = split /\|/;
>
>mistakenly using a quoted string or a variable does *NOT*
>absolve you from the stringent requirement to escape things
>that would otherwise affect a regular expression, like a pipe
>symbol for pattern alternation.
>
Ooh, I was sloppy. You'd have to do something like:
@f = split "\\\|";
or
@f = split q{\|};
Not formatting split's 1st arg as a /PATTERN/ makes it easy
to forget you're dealing with a regexp and the need to escape
metacharacters... and it can grow ugly with backslashitis..
I see the light.
- -
Charles DeRykus
ced@carios2.ca.boeing.com
------- End of Forwarded Message
be emitted.
------- Forwarded Message
Date: Wed, 25 Oct 95 08:44:27 PDT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: re: regular expression / split help
To: tchrist@mox.perl.com
Newsgroups: comp.lang.perl.misc
Subject: Re: [Help] Regular expression / split question
Summary:
Expires:
References: <465lsg$idg@dolphin.pst.cfmu.eurocontrol.be> <DGrA5u.7H@bcstec.ca.boeing.com> <46
jj06$hej@csnews.cs.colorado.edu>
Sender:
Followup-To:
Distribution:
Organization: The Boeing Company
Keywords:
Cc:
In article <46jj06$hej@csnews.cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>:-> In comp.lang.perl.misc, ced@bcstec.ca.boeing.com (Charles DeRykus) writes:
>: @f = split("|");
>
>That's not going to work right. Split takes a regexp as its first argument:
>
> @f = split /\|/;
>
>mistakenly using a quoted string or a variable does *NOT*
>absolve you from the stringent requirement to escape things
>that would otherwise affect a regular expression, like a pipe
>symbol for pattern alternation.
>
Ooh, I was sloppy. You'd have to do something like:
@f = split "\\\|";
or
@f = split q{\|};
Not formatting split's 1st arg as a /PATTERN/ makes it easy
to forget you're dealing with a regexp and the need to escape
metacharacters... and it can grow ugly with backslashitis..
I see the light.
- -
Charles DeRykus
ced@carios2.ca.boeing.com
------- End of Forwarded Message