[Israel.pm] Replace with Variable content

Omer Zak omerz at actcom.co.il
Wed Oct 12 15:49:00 PDT 2005

On Wed, 2005-10-12 at 13:47 +0200, ik wrote:

> I would like to do the following:
> ....
> use strict;
> ....
> my $allowedChars = "a-zA-Z\x{50D}";
> $line =~ s/[^$allowedChars]//gs;
> Now as you can see, this code will not be allowed to be used. So my
> question is how can I do something in this idea ?
> I wish to have one "place" that I define what I allow, that may be
> changed at any given time, so instead going over my entire code over
> and over again, I would like to have the ability to use a "constant"
> like idea...

1. Try to use eval (see: "Programming Perl", 2nd edition, pg. 76).
2. Define a short function, which accomplishes the desired operation and
is called wherever you need the regular expression.
3. The natural way to accomplish the deletion is to use tr///d

                                                   --- Omer
One does not make peace with enemies.  One makes peace with former
My own blog is at http://www.livejournal.com/users/tddpirate/

My opinions, as expressed in this E-mail message, are mine alone.
They do not represent the official policy of any organization with which
I may be affiliated in any way.
WARNING TO SPAMMERS:  at http://www.zak.co.il/spamwarning.html

More information about the Perl mailing list