Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: A "strange" behaviour, at least to me :)

by Kenosis (Priest)
on Apr 13, 2013 at 17:35 UTC ( #1028539=note: print w/ replies, xml ) Need Help??


in reply to A "strange" behaviour, at least to me :)

It's evident that you're encountering a Perl parsing issue which can be addressed by changing:

@values = sort arraynosort( Values => \@orig_values );

to this

@values = sort ( arraynosort( Values => \@orig_values ) );

Using B::Deparse, we can see how Perl parses your original line using my:

perl -MO=Deparse -p -e 'my @values = arraynosort( Values => \@orig_val +ues );'

Partial output:

my(@values) = arraynosort('Values', \@orig_values);

Now with the sort:

perl -MO=Deparse -p -e '@values = sort arraynosort( Values => \@orig_v +alues );'

Partial output:

@values = (sort arraynosort 'Values', \@orig_values);

Note that Perl is not 'seeing' the clustering represented by parentheses, and this produces the issue your encountering. However, if you group using parentheses, Perl 'sees' it the way you likely expected it to work:

perl -MO=Deparse -p -e '@values = sort ( arraynosort( Values => \@orig +_values ) );'

Partial Output:

@values = sort(arraynosort('Values', \@orig_values));

Hope this helps!


Comment on Re: A "strange" behaviour, at least to me :)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-12-28 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls