Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > constant string in regular expression

Reply
Thread Tools

constant string in regular expression

 
 
Michael Kiermaier
Guest
Posts: n/a
 
      07-12-2003
hello!

i am new to perl. i searched the online documentation for this
problem, but i didn't find an answer.

here is a part of my code:

[...]
use constant _GROUP => "gruppe";
[...]
if ($configLine =~ /^\s*_GROUP\s+(.+?)\s*$/) {
[...]

of couse in the regexp the character sequence _GROUP does not get
replaced, but i want that it is regarded as the name of the constant
and therefore replaced by "gruppe".

i hope that my post is understandable enough.

many thanks in advance,

~michael
 
Reply With Quote
 
 
 
 
Eric J. Roode
Guest
Posts: n/a
 
      07-12-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

http://www.velocityreviews.com/forums/(E-Mail Removed) (Michael Kiermaier) wrote in
news:(E-Mail Removed) om:

> here is a part of my code:
>
> [...]
> use constant _GROUP => "gruppe";
> [...]
> if ($configLine =~ /^\s*_GROUP\s+(.+?)\s*$/) {
> [...]
>
> of couse in the regexp the character sequence _GROUP does not get
> replaced, but i want that it is regarded as the name of the constant
> and therefore replaced by "gruppe".


Use the Readonly module instead:

use Readonly;
Readonly::Scalar my $_GROUP => "gruppe";
....
if ($configLine =~ /\s*$_GROUP\s+(.+?)\s*$/) {
....

- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPxBRcGPeouIeTNHoEQKZ+ACgwwaPHeGVyuvsaUQvDI2ZaK eVj/AAn10a
/JHas78d/UX1jVjAPOz9NpTD
=7rut
-----END PGP SIGNATURE-----
 
Reply With Quote
 
 
 
 
Eric J. Roode
Guest
Posts: n/a
 
      07-13-2003
(E-Mail Removed) (Michael Kiermaier) wrote in
news:(E-Mail Removed) om:

> hello!
>
> i am new to perl. i searched the online documentation for this
> problem, but i didn't find an answer.
>
> here is a part of my code:
>
> [...]
> use constant _GROUP => "gruppe";
> [...]
> if ($configLine =~ /^\s*_GROUP\s+(.+?)\s*$/) {
> [...]
>
> of couse in the regexp the character sequence _GROUP does not get
> replaced, but i want that it is regarded as the name of the constant
> and therefore replaced by "gruppe".


Use the Readonly module instead:

use Readonly;
Readonly::Scalar my $_GROUP => "gruppe";
....
if ($config




--
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
"error C2057: expected constant expression", "error C2466: cannot allocate an array of constant size 0". Why doesn't my simple program work??? hn.ft.pris@gmail.com C++ 13 01-22-2007 02:03 PM
Conditional constant in regular expression Fritz Bayer Perl Misc 7 04-10-2005 09:43 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments