Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Is using $#array Frowned on?

by eyepopslikeamosquito (Chancellor)
on Feb 14, 2014 at 21:06 UTC ( #1075003=note: print w/ replies, xml ) Need Help??

in reply to Is using $#array Frowned on?

An example of where you should avoid the $#array notation is when counting from the end of an array (see Perl Best Practices, chapter 5, "Use negative indices when counting from the end of an array"). For example, you should replace:

$frames[$#frames ] = $active{top}; $frames[$#frames-1] = $active{prev}; $frames[$#frames-2] = $active{backup};
$frames[-1] = $active{top}; $frames[-2] = $active{prev}; $frames[-3] = $active{backup};
because it is easier on the eye and avoids the undesirable repetition of the frames variable name (DRY).

Comment on Re: Is using $#array Frowned on?
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2015-07-29 03:12 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (260 votes), past polls