--On Freitag, 24. August 2001 09:54 -0700 "Randal L. Schwartz" 
<[EMAIL PROTECTED]> wrote:
> That's too much there...
>
>   /add_\w+/ and print("Yippie!\n"), last while $_ = each %hash;
>
> "scalar each" is underutilized. :)
>
I'm impressed, thanks a lot!

Further question: Someone mentioned a module that allows for regexps as 
hash keys. Could you please repost that, I inadvertently deleted the 
message ...

Yet further question:

my %this = ('A' => 'valueA', 'B' => 'valueB');
my %is = ('A' => 'othervalueA', 'B' => 'othervalueB');
my @array = ('this', 'is');
my $string = "this";#will actually be user input, might also be "is"
my $data = "A and B";
foreach my $array (@array) {
        if ($string eq $array) {
        $data =~ s/A/$array{A}/g;#just as an example, there'll be more string 
conversions to follow, probably done with regexps
        }
}

Is this clear? I want to carry out replacement operations on string $data 
depending on the value of $string. There are different types of replacement 
routines, stored in hashes %this and %is. I'm looking for a way to condense 
code that does that for all available hashes, instead of doing single 
conditions like:

if ($string eq "this") { $data =~ s/A/$this{A}/g;}

I don't suppose $array{A} in the above code is what I want it to be: the 
value for the key "A" from that particular hash to which the scalar $array 
refers - it would be the value for the key "A" in %array, which doesn't 
exist in my script.
But how can I turn it into what I want it to be?


Birgit Kellner






        


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to