Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl (http://www.velocityreviews.com/forums/f17-perl.html)
-   -   constant string in regular expression (http://www.velocityreviews.com/forums/t24161-constant-string-in-regular-expression.html)

Michael Kiermaier 07-12-2003 03:43 PM

constant string in regular expression
 
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

Eric J. Roode 07-12-2003 06:20 PM

Re: constant string in regular expression
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

michael.kiermaier@gmx.net (Michael Kiermaier) wrote in
news:72be1fd1.0307120743.17033888@posting.google.c 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-----

Eric J. Roode 07-13-2003 04:25 PM

Re: constant string in regular expression
 
michael.kiermaier@gmx.net (Michael Kiermaier) wrote in
news:72be1fd1.0307120743.17033888@posting.google.c 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


All times are GMT. The time now is 08:27 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57