Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Perl Python Partial Polyglot

by BrowserUk (Pope)
on Nov 23, 2018 at 18:39 UTC ( #1226240=note: print w/replies, xml ) Need Help??


in reply to Re: Perl Python Partial Polyglot
in thread Perl Python Partial Polyglot

Assuming the offending code looks something like this:

my $hashref = { .... }; my $keysCount = keys $hashref;

Then add a dereference:

my $keysCount = keys ${ $hashref };

Or just:

my $keysCount = keys $$hashref;

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

Replies are listed 'Best First'.
Re^3: Perl Python Partial Polyglot
by kschwab (Vicar) on Nov 23, 2018 at 21:07 UTC
    Thanks...what ended up working was changing:
    perl(split/\n/,(keys(${{}))[0])
    to
    perl(split/\n/,(keys(%{${{}}))[0])
Re^3: Perl Python Partial Polyglot
by 1nickt (Abbot) on Nov 24, 2018 at 14:48 UTC

    Ahem, both of those snippets are non-working:

    $ perl -Mstrict -wE 'my $h = {foo=>"bar"}; my $c = keys ${$h};' Experimental keys on scalar is now forbidden at -e line 1. Type of arg 1 to keys must be hash or array (not scalar dereference) a +t -e line 1, near "};" Execution of -e aborted due to compilation errors.
    $ perl -Mstrict -wE 'my $h = {foo=>"bar"}; my $c = keys $$h;' Experimental keys on scalar is now forbidden at -e line 1. Type of arg 1 to keys must be hash or array (not scalar dereference) a +t -e line 1, near "$h;" Execution of -e aborted due to compilation errors.
    ... presumably you meant:
    $ perl -Mstrict -wE 'my $h = {foo=>"bar"}; my $c = keys %{$h};'
    $ perl -Mstrict -wE 'my $h = {foo=>"bar"}; my $c = keys %$h;'

    Aside: how odd that your post continues to garner upvotes (rep up three since I posted this); you don't suppose people vote based on the author's reputation without really reading the post, do you!?


    The way forward always starts with a minimal test.
      Nevermind, thought this was in reply to my reply.
      Ahem, both of those snippets are non-working

      And yet, somehow, my post prompted the OP to both find his own solution and post code demonstrating the original problem. Clever huh?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
      In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

        Even knowing your high self-esteem I am amazed that you would claim that your erroneous contribution was so "clever" that it deserves the credit here. Most people would have said "oops."


        The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1226240]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2019-10-15 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?