mkaiser67 has asked for the wisdom of the Perl Monks concerning the following question:
I have an interesting issue with 'eval'.
I am using cgi Perl webpages looping throught parameters in a url, with an eval structure, to determine whether the parameter string is a json structure or not; if not then we have a need to encode the the parameter values:
{paraphrased code}
my @keys = %urlparams; foreach my $key (@keys) { eval { my $temp = from_json($urlparams{$key}); } or do { $input{$key} = HTML::Entities::encode($input{$key}); }; }
A URL like: https://mywebserver.edu/the.cgi?param_one=file.jpg|fileid|no_file¶m_two=1|1|2|2 is expected to die on the json pyre and be encoded, which is fine, but it consistently leaks the JSON error message to STDERR on the last parameter, no matter the order of the parameters or number of them. That's not so cool.
we're using Perl 5.30, CGI::Carp,utf8,Text::Unidecode,HTML::Entities,JSON
Clearly i would like to know what's going on..
Any ideas? a memory leak of somekind?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl evals and JSON
by choroba (Cardinal) on Mar 17, 2022 at 15:43 UTC | |
|
Re: Perl evals and JSON
by hippo (Archbishop) on Mar 17, 2022 at 15:47 UTC | |
|
Re: Perl evals and JSON (CGI::Carp / updated)
by LanX (Saint) on Mar 17, 2022 at 15:40 UTC | |
|
Re: Perl evals and JSON
by cavac (Prior) on Mar 21, 2022 at 15:50 UTC |