cont'd: Dereferencing SCALAR references correctly

Warren Smith <wsmith-KfBRzk3UKwrYd54FQh9/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Organization Platinumtel Wireless
Message-ID <1090267663.32342.6.camel@wsmithbox>
grr. silly email client......



if you do this:

template.html
-------------
<div petal:content="vals/var1"></div>

program.pl
----------
$var1 = "Hello";
$var2 = "Hello2";

%vals = ( var1=>\$var1, var2=>\$var2);
$tpl = new Petal(...);
echo $tpl->process({vars => \@vals});

Hello and Hello2 are not set. you see SCALAR references.

Changing the last part of Petal/Hash/Var.pm to

    # return '' unless (defined $current);
    # $current = "$current" if (defined $current);
    return $$current if isa($current, 'SCALAR');
    return $current;
}
                                                                                                    
fixes this.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.