Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: delete(), but for arrays

by vladb (Vicar)
on May 16, 2002 at 18:55 UTC ( #167076=note: print w/replies, xml ) Need Help??


in reply to delete(), but for arrays

vaevictus askth:

What should I do to maintain each of my goals: backward compatibility to 5.005x, readability, and performance?

My answer would be if your sole goal is to assure backward compatibility, then you've really got no other option than stick with coding practices that are accaptable in both newer and older versions of Perl. This means, unfortunately, you'll have to leave slice($array, $index, 1) alone ;).

If, on the other hand, you are not worried about backward compatibility, I consider it a wholesome pursuit to improve readability and performance of one's code. In this regard, do whichever thou art deems appropriate! Therefore, if you consider delete($ARRAY[2]); as a 'cleaner' alternative to the use of splice(), stick with the former. Indeed, this is a matter of taste and pleasing the audience (whoever will come to look at your code etc.)

cheers,

UPDATE: expanded on my initial thought...

_____________________
$"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+) +-.*)$/;$_=&#91"ps -e -o pid | "," $2 | "," -v "," "]`@$_`?{print" ++ $1"}:{print"- $1"}&&`rm $1`;print"\n";}

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2022-05-24 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?