Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Odd splice behavior between perl/OS versions (undefined)

by tye (Sage)
on Oct 28, 2016 at 19:14 UTC ( #1174913=note: print w/replies, xml ) Need Help??


in reply to Odd splice behavior between perl/OS versions

The behavior depends on the order in which different parts of the operation are done. If this were C code, then it would be labeled "undefined behavior". Since it is Perl code, the strict meaning of that phrase from the C standard doesn't quite apply. But it is the type of behavior that is the most likely to end up changing when mundane maintenance is done on Perl's source code, including optimizations.

I believe the crux of the difference is whether you get the value of $#stuff passed to the outer instance of splice from before or after the inner instance of splice has removed $stuff[3]. Though I can also imagine more complex ways that a simple optimization, bug fix, or just reworking of Perl's code could cause your code to behave differently.

Avoid changing @stuff in multiple ways in a single expression and using values like $#stuff from within an expression where that value is changed.

- tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2020-09-27 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (142 votes). Check out past polls.

    Notices?