Re: "my" variables and recursive regexp strangeness
From: Anno Siegel (anno4000_at_lublin.zrz.tu-berlin.de)
Date: 05/13/04
- Next message: Jack Challen: "Re: Perl binary distribution with threads support"
- Previous message: Ian: ""my" variables and recursive regexp strangeness"
- In reply to: Ian: ""my" variables and recursive regexp strangeness"
- Next in thread: Gunnar Hjalmarsson: "Re: "my" variables and recursive regexp strangeness"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 13 May 2004 14:00:55 GMT
Ian <ijnetnews@hotmail.com> wrote in comp.lang.perl.misc:
> I have something strange happening with a recursive regexp compiled
> with qr//x; It is a regular expression to match individual single
> double and un-quoted strings, i.e. "string", 'string' and string.
>
> It works fine when the sub parts of it are global variables, or
> "local" variables, but if I change them to "my" variables, suddenly
> they stop matching correctly (or at least start matching differently).
>
> Anybody have any ideas why changing to "my" variables would affect it
> this way?
It isn't the fact that they're lexical, but you apparently tried
to declare the variables in the same statement that uses them,
as in
my $dStringData = qr/
([^"\\]|\\.)+ (??{$dStringData})
|
"
/x;
You can't use a lexical in the same statement that declares it.
Use an extra "my" statement, and it works.
It would have been better to post the erroneous code, instead of
saying "if I change this, it doesn't work anymore". That way
we wouldn't have to guess your error.
Anno
- Next message: Jack Challen: "Re: Perl binary distribution with threads support"
- Previous message: Ian: ""my" variables and recursive regexp strangeness"
- In reply to: Ian: ""my" variables and recursive regexp strangeness"
- Next in thread: Gunnar Hjalmarsson: "Re: "my" variables and recursive regexp strangeness"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|