Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Perl Python Partial Polyglot

by kschwab (Vicar)
on Nov 23, 2018 at 13:42 UTC ( #1226225=note: print w/replies, xml ) Need Help??


in reply to Perl Python Partial Polyglot

$ perl t1 Experimental keys on scalar is now forbidden at t1 line 25.
Grrr, deprecation. Now I have to figure out how to fix it.

Replies are listed 'Best First'.
Re^2: Perl Python Partial Polyglot
by BrowserUk (Pope) on Nov 23, 2018 at 18:39 UTC

    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
      Thanks...what ended up working was changing:
      perl(split/\n/,(keys(${{}))[0])
      to
      perl(split/\n/,(keys(%{${{}}))[0])

      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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2019-09-19 07:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (240 votes). Check out past polls.

    Notices?