in reply to Why isn't this subroutine working?

$$rowRef{'$rowName'}
Are you sure fetchrow_hashref returns a hash with the name $rowName? Perhaps you want to lose the quotes.

Replies are listed 'Best First'.
Re^2: Why isn't this subroutine working?
by northwestdev (Acolyte) on May 20, 2009 at 12:35 UTC
    Yes, I'm sure. I tried it with, and without the quotes. As for elsf and elsif, I know I've been up most of the night, but I am not hallucinating, eclipse tells me I have a syntax error when I use elsif. Could it be one of the modules I'm using? (I'm using strict, HTTP::Date, XML::DOM, CGI). PS: I am using eclipse on Windows Vista, but the programs run on a Linux server. I have not figured out, yet, how to run and debug perl on the Eclipse IDE on Vista

      It might have gone by you - JavaFan's question was more rhetorical, as the differences in output of the following code show you:

      use strict; my $rowRef = { foo => 'foo value', bar => 'bar value', }; my $rowName = 'bar'; for my $rn ($rowName, '$rowName') { my $rowValue; if (exists $rowRef->{$rn}) { $rowValue = $rowRef->{$rn} } else { $rowValue = '<does not exist>'; }; print "rowRef for '$rn' is '$rowValue'\n"; };
        OK, pick on the newbie :-) I was using it without quotes, but then I decided to try it with quotes (I use those for Perl-embedded MySQL code), and that's what I copied and pasted. In any case, even without the quotes, it still does not work.

      Then you are misinterpreting the error message. For example,

      >perl -e"while ($x) { if ($y) { } } elsif ($z) { } }" syntax error at -e line 1, near "} elsif" Execution of -e aborted due to compilation errors. >perl -e"while ($x) { if ($y) { } elsif ($z) { } }" >

      Replacing elsif with random words is not a suitable bug fix.

      A reply falls below the community's threshold of quality. You may see it by logging in.