Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Perl Code Changes Behavior if Two Subroutine definitions are swapped

by rkabhi (Acolyte)
on Jul 28, 2016 at 05:36 UTC ( [id://1168706]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl Code Changes Behavior if Two Subroutine definitions are swapped
in thread Perl Code Changes Behavior if Two Subroutine definitions are swapped

Hi Athanasius,

Thanks for your response.

Regarding the empty string. I tried running your example code using perl 5.10.1 and got following output:

OUTPUT WITH EXAMPLE CODE:
abc: matches 'bc' def: matches 'de' ghi: no match found

So, somehow we get different outputs. Not sure why. Since in my case it tries to match with $_ when nothing is specified in switch(), I could not identify any issue with such use of switch and therefore I continued using it.

Thanks for mentioning things to take care as best practice about using empty arguments and next statements. I will try your suggestions and get back if the main issue persists. For now I am not going to use switch as it is not necessary for my code.

Best Regards,
Abhishek

Replies are listed 'Best First'.
Re^3: Perl Code Changes Behavior if Two Subroutine definitions are swapped
by Athanasius (Archbishop) on Jul 28, 2016 at 09:57 UTC
    I tried running your example code using perl 5.10.1 and got following output...

    Interesting. Experimenting with the Strawberry Perl versions I have on my system, it appears the change occurred between Perl 5.12.3 and 5.14.4. Running with -MO=Deparse reveals only one difference:

    &Switch::switch(); # v5.12.3 vs. &Switch::switch(()); # v5.14.4

    And calling switch explicitly with an empty list — switch(()) — under 5.12.3 gives the same result as calling switch() under 5.14.4.

    I’ve skimmed through the deltas, but so far haven’t found a plausible explanation. Possibly related to the change in handling the (;$) prototype,1 since that is the prototype of sub switch in the Switch module, but I don’t see how that would account for the observed behaviour. :-/

    1See “Change in parsing of certain prototypes” in perl5140delta.

    Cheers,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      Isnt switch noncore? I doubt perl version plays any part, aside from deparse version
Re^3: Perl Code Changes Behavior if Two Subroutine definitions are swapped
by Cow1337killr (Monk) on Aug 02, 2016 at 00:44 UTC

    Welcome, rkabhi.

    Is there any particular reason why you are not running the latest version of Perl?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-29 00:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found