Hi - I was updating this script at work in a totally different section to add an exception. When I went to test run it, I received an error: Experimental keys on scalar is now forbidden at line 339. I went to that part of the script and fixed it by dereferencing.
my @result = keys $results->{$ip}; changed to
my @result = keys %{$results->{$ip}};
However, when I re-ran the script, I got the error: Can't use an undefined value as a SCALAR reference at line 335.
I then tried to change that part of the code by removing the
${} that surrounded
$client->do_task(...) based on a suggestion from someone else. I have no idea about json and using it, and I have no idea about what this part of the code does. When I re-ran the script again, I then got the error: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at line 334.
I am now not sure if I fixed the Experimental Keys error correctly or not as I am not understanding why the other stuff is breaking when fixing it.
Original code, without any fixes, is below
329 print "\nRunning isok on ip $ip\n";
+
+
330
+
+
331 my $client = Gearman::Client->new;
+
+
332 $client->job_servers('<location>');
+
333
+
+
334 my $results = decode_json(
+
+
335 ${ $client->do_task(
+
+
336 'isok_production', encode_json({ isok_payload => $ip
+ })
+
337 )}
+
+
338 );
+
+
339 my @result = keys $results->{$ip};
Any help in understanding these errors and how to correct would be appreciated. Thanks
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.