I have a bit of a strange problem... I have consulted the very useful assistance haukex and others provided on Re^9: Preparing data for Template.
The problem is dereferencing an entry in a hash. At first, I thought it was the trouble I always seem to run into when using references. So, I built some test code to check what I was doing and it works as expected.
The output is exactly as expected.use strict; my $val = 'A'; my $vars = { 'test' => $val }; reftest('testing', $vars); sub reftest { my ($value, %vars) = @_; print "$value\n"; print $$vars{'test'}."\n"; } C:\Users\ian\Perl>perl dereference.pl testing A
But the code on the webserver is structured the same. The only difference is that the subroutine is a method in a blessed object...could this really make a difference?
The calling code...
my $vars = { 'testpage' => $data{'testpage'} }; $html->process('index', $vars);
And the method within the $html object...
The output is <h1></h1> only.sub process { my ($self, $disp, %v) = @_; my $testpage = $$v{'testpage'}; print "<h1>".$testpage."</h1>\n"; }
I have checked the $data{'testpage'} contains the expected data of either 'A' or 'B'.
What is causing the lack of dereferencing or what else could I try to debug this problem?
In reply to Dereferencing in blessed object by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |