Mailing List Archive

embPerl and Readonly module issue
Using embPerl 2.5.0, porting an application from Ubuntu 12.04, perl 5.14,
Readonly 2.0.0 to Ubuntu 18.04, perl 5.26, Readonly 2.05

If I have a Readonly hash like this:

[.-
use Readonly;

Readonly our %LETTERS => {
"A" => "Letter A",
"B" => "Letter B",
"C" => "Letter C"
}
-]

and I try to use it like this:

[$ foreach $letter (keys %LETTERS) $]
[+ $LETTERS{$letter} +]
[$ endforeach $]

That works with the older versions and doesn't with the newer. With the
newer version nothing is output. If I do something to force it to be
evaluated, like:

[$ foreach $letter (keys %LETTERS) $]
[+ eval { $LETTERS{$letter} } +]
[$ endforeach $]

It does output "LETTER A", etc. in both versions.

Any explanation of what's happening or suggestions on how to best deal with
it?
Re: embPerl and Readonly module issue [ In reply to ]
Hi,

that could be the same issue mentioned some time ago on the list regarding output of udat or using functions like substr in [+ +] blocks. Maybe Readonly does some magic in the background.

Please look at the archive for more information.

Our fix: [+ do { $udat{foo} } +]

With best regards,

Dirk Melchers
/// IT/Software-Entwicklung ///

--
NUREG GmbH ///
Dorfäckerstraße 31 | 90427 Nürnberg | Germany
Tel. +49-911-32002-256 | Fax +49-911-32002-299
Mobil +49-172-9354670 | www.nureg.de
Nürnberg HRB 22653 | USt.ID DE 814 685 653
Geschäftsführer: Michael Schmidt, Stefan Boas

> Am 17.09.2019 um 17:22 schrieb Chuck Zumbrun <chuck.zumbrun@gmail.com>:
>
> Using embPerl 2.5.0, porting an application from Ubuntu 12.04, perl 5.14, Readonly 2.0.0 to Ubuntu 18.04, perl 5.26, Readonly 2.05
>
> If I have a Readonly hash like this:
>
> [.-
> use Readonly;
>
> Readonly our %LETTERS => {
> "A" => "Letter A",
> "B" => "Letter B",
> "C" => "Letter C"
> }
> -]
>
> and I try to use it like this:
>
> [$ foreach $letter (keys %LETTERS) $]
> [+ $LETTERS{$letter} +]
> [$ endforeach $]
>
> That works with the older versions and doesn't with the newer. With the newer version nothing is output. If I do something to force it to be evaluated, like:
>
> [$ foreach $letter (keys %LETTERS) $]
> [+ eval { $LETTERS{$letter} } +]
> [$ endforeach $]
>
> It does output "LETTER A", etc. in both versions.
>
> Any explanation of what's happening or suggestions on how to best deal with it?
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
AW: embPerl and Readonly module issue [ In reply to ]
What is happing if you write "$LETTERS{$letter}", i.e. us quotes instead of
eval?



Regards



Gerald



Von: Chuck Zumbrun [mailto:chuck.zumbrun@gmail.com]
Gesendet: Dienstag, 17. September 2019 17:22
An: embperl@perl.apache.org
Betreff: embPerl and Readonly module issue



Using embPerl 2.5.0, porting an application from Ubuntu 12.04, perl 5.14,
Readonly 2.0.0 to Ubuntu 18.04, perl 5.26, Readonly 2.05



If I have a Readonly hash like this:



[.-
use Readonly;

Readonly our %LETTERS => {
"A" => "Letter A",
"B" => "Letter B",
"C" => "Letter C"
}
-]


and I try to use it like this:


[$ foreach $letter (keys %LETTERS) $]
[+ $LETTERS{$letter} +]
[$ endforeach $]



That works with the older versions and doesn't with the newer. With the
newer version nothing is output. If I do something to force it to be
evaluated, like:



[$ foreach $letter (keys %LETTERS) $]
[+ eval { $LETTERS{$letter} } +]
[$ endforeach $]



It does output "LETTER A", etc. in both versions.



Any explanation of what's happening or suggestions on how to best deal with
it?








--
This message has been checked by Libra Esva and is found to be clean.
Mark it as spam
<http://srvmailgw3.i.ecos.de/cgi-bin/learn-msg.cgi?id=D925740090.A4277>
Blacklist sender
<http://srvmailgw3.i.ecos.de/cgi-bin/learn-msg.cgi?blacklist=1&id=D925740090.A4277>
Re: embPerl and Readonly module issue [ In reply to ]
Wrapping it in double quotes causes it to output, and seems like a better
solution than using eval.

Thanks all!

On Wed, Sep 18, 2019 at 5:43 AM Gerald Richter - ECOS Technology <
gerald.richter@ecos.de> wrote:

> What is happing if you write "$LETTERS{$letter}", i.e. us quotes instead
> of eval?
>
>
>
> Regards
>
>
>
> Gerald
>
>
>
> *Von:* Chuck Zumbrun [mailto:chuck.zumbrun@gmail.com]
> *Gesendet:* Dienstag, 17. September 2019 17:22
> *An:* embperl@perl.apache.org
> *Betreff:* embPerl and Readonly module issue
>
>
>
> Using embPerl 2.5.0, porting an application from Ubuntu 12.04, perl 5.14,
> Readonly 2.0.0 to Ubuntu 18.04, perl 5.26, Readonly 2.05
>
>
>
> If I have a Readonly hash like this:
>
>
>
> [.-
> use Readonly;
>
> Readonly our %LETTERS => {
> "A" => "Letter A",
> "B" => "Letter B",
> "C" => "Letter C"
> }
> -]
>
>
> and I try to use it like this:
>
>
> [$ foreach $letter (keys %LETTERS) $]
> [+ $LETTERS{$letter} +]
> [$ endforeach $]
>
>
>
> That works with the older versions and doesn't with the newer. With the
> newer version nothing is output. If I do something to force it to be
> evaluated, like:
>
>
>
> [$ foreach $letter (keys %LETTERS) $]
> [+ eval { $LETTERS{$letter} } +]
> [$ endforeach $]
>
>
>
> It does output "LETTER A", etc. in both versions.
>
>
>
> Any explanation of what's happening or suggestions on how to best deal
> with it?
>
>
>
>
>
>
>
>
> --
> This message has been checked by Libra Esva and is found to be clean.
> Mark it as spam
> <http://srvmailgw3.i.ecos.de/cgi-bin/learn-msg.cgi?id=D925740090.A4277>
> Blacklist sender
> <http://srvmailgw3.i.ecos.de/cgi-bin/learn-msg.cgi?blacklist=1&id=D925740090.A4277>
>