Perl: Pattern Matching a HASH variable

Hi All,

I'm trying to test a Hash variable but it's not working. Here is my code - can anyone tell me if the test is valid?

for (keys %enabled_yn) {

  if ($enabled_yn{$1} =~ m/\s+Y/) {

      $html =~ s/%(\w+)%/\<b\>\<font color\=orange\>$enabled_yn{$1}\<\/font\>\<\/b\>/g;

      } else {

      $html =~ s/%(\w+)%/$enabled_yn{$1}/g;

  }
}

If the variable contains a Y (there is some leading white space hence the \s) then it should output it in bold orange (to a place holder %%). Anything else just gets put into its relevant place holder.

Any ideas on how I can do this?

Many thanks,

pondlife.

I don't think $1 will contain the key name..... may be you can try with $_

replace $enabled_yn{$1} with $enabled_yn{$_}

or you can declare a variable to be more clear

for my $k1 (keys %enabled_yn) {

if ($enabled_yn{$k1} =~ m/\s+Y/) {

  $html =~ s/%\(\\w\+\)%/\\&lt;b\\&gt;\\&lt;font color\\=orange\\&gt;$enabled_yn\{$k1\}\\&lt;\\/font\\&gt;\\&lt;\\/b\\&gt;/g;

  \} else \{

  $html =~ s/%\(\\w\+\)%/$enabled_yn\{$k1\}/g;

}
}

I have not tested... try