Newbie answer here - if you change the line 

my $string = 'I love c++';

to be

my $string = 'I love c\++';

it runs, but, you also get this output :

C:\SCRIPTS\test>perl lovec.pl
some compare string does not contain I love c\++

DerekB

-----Original Message-----
From: John W. Krahn [mailto:[EMAIL PROTECTED]
Sent: 25 June 2003 20:03
To: [EMAIL PROTECTED]
Subject: Re: Regex problem


"Beau E. Cox" wrote:
> 
> Hi All -

Hello,

> This script:
> 
> use strict;
> use warnings;
> 
> my $string = 'I love c++';
> my $compare = 'some compare string';
> if ($compare =~ /$string/) {
>     print "$compare contains $string\n";
> } else {
>     print "$compare does not contain $string\n";
> }
> 
> gives this error:
> 
> Nested quantifiers in regex; marked by <-- HERE in m/I love c++ <-- HERE /
> at t.pl line 6.
> 
> It's the '+'s. I've tried escaping them '\+' but then
> the regex matches on '\+'. I don't understand what is
> happening.
> 
> This is occuring in a script that's manipulating
> files; file names with '+'s fail on this error. Is there any
> way I can fix this before I fall back to substrings and
> 'eq'/'ne' compares (ugh).

It's obvious!  Anyone who claims to "love" C++ is in deep trouble.  :-)


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


************************************************************************
Meteor web site http://www.meteor.ie
************************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to