> Newbie answer here - if you change the line
>
> my $string = 'I love c++';
The problem is the single quotes I think.
Try double quotes.
Also are you actually hardcoding the strings in there or getting them from input?
If 'from input' try this:
use CGI qw(:standard);
my $string = param('string');
And feed it input of I love c++ as the string paramater and
that'd be a more acurate test of the regex in actual usage conditions.
C:\SCRIPTS\test>perl lovec.pl 'string=I love c++'
See how that comes out.
HTH
DMuey
>
> 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]
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]