[sf-perl] Unmatched [ in regex; marked by <-- HERE in m/[ <-- HERE NO/

Quinn Weaver qw at sf.pm.org
Mon Jan 15 16:14:37 PST 2007


On Mon, Jan 15, 2007 at 04:31:11PM -0700, Loo, Peter # PHX wrote:
> Hello,
>  
> I am getting the following error when I hit the following record when
> trying to m// the field "[NO".

> [...]

Hi, Peter,

I can't replicate your problem using the code you posted.  For me, it
works with or without the "|| $field =~ m/\W+/)" part.  (Without
it, the regex doesn't match, but it doesn't die with a compilation
error.)

I suspect you may have a syntax error.  Check your code carefully.
It may be that you've accidentally chopped off the / that ends the
regex, or something.  The code should look like this:

Variant 1:

> elsif ($field =~ m/^[0-9]*\s+[0-9]$/ || $field =~ m/\W+/) {

Variant 2:

> elsif ($field =~ m/^[0-9]*\s+[0-9]$/) {

If that doesn't help, please post more of the surrounding code, and
we'll have another crack at it.

Thanks,

--
qw (Quinn Weaver); #President, San Francisco Perl Mongers
=for information, visit http://sf.pm.org/weblog =cut


More information about the SanFrancisco-pm mailing list