hi
eh, how do i in fact use variables that really are variable in a regexp?

in the below script i just want to get this out:
first value: 33  sec value: 44
however i get:
first value: 33 sec value: <xml2>first value: <xml1> sec value: 44

i dont see another way right now than calling a function with the
variables, but then i have a problem everytime i call the function. in
this case it prints the return string twice. i know about the /o
modifier so i guess this is possible and probably quite easy:-)

thanks
allan


#!/usr/bin/perl -w

%hash = ("<xml1>", 33, "<xml2>", 44);

$string = "first value: <xml1> sec value: <xml2>";

while (($key,$value) = each %hash) {
        $output = perlFunction($string, $key, $value);
        print $output; 
}

#should output first value: 33  sec value: 44

sub perlFunction() {
                $strFromAsp = shift(@_);
                $perl_inputstring = $strFromAsp;
                $perl_inputstring =~ s/$key/$value/i;
                return $perl_inputstring;
}

Reply via email to