XP is just a number | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
This is really more a question of aesthetics and coding practice than whether it works or not. Should "my" just be thrown into the middle of the code, where it's nearest to where the variable is needed, or stated at the top, where it's easier to see all your variables and where the "my" doesn't cause things to potentially not line up? For instance, if you were doing something like this:
Personally, I like declaring at the top, especially if a variable is used several times, but others prefer declaring at the point at which the variable is first used. I still haven't figured out which method is really superior. Here's a few more samples of interesting things you can do with arrays: Using the standard output variable instead of declaring a new one:
Cycling through the array, method 1 (each value is put in standard output variable in turn):
Cycling through the array, method 2 ($# represents the subscript of the last item in the array): In reply to Re: Is it ok to assign a popped value to a variable as shown.
by TJPride
|
|