Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^4: Yet another array problem

by revdiablo (Prior)
on Jul 29, 2005 at 17:37 UTC ( #479487=note: print w/replies, xml ) Need Help??

in reply to Re^3: Yet another array problem
in thread Yet another array problem

My point was really that using named variables is usually more clear (to me at least) than using no variable, relying in the default of either $_ or @_ in the function.

This depends highly on the situation. You later say that your coding style is "situational," so I don't understand why you'd make a sweeping generalization like this. There are many cases where relying on $_ greatly enhances readability.

@_ is a completely different matter, because -- as blazar says -- it's not just a "default" that you can avoid using. You use it to get subroutine parameters, and that's all there is to it. (Unless you're talking about using @_ as the default target for split, but I certainly hope you're not.)

I've been coding Perl for 10 years now.

I don't know enough about you personally to comment on your experience, but the length of time knowing how to use something is only a rough indicator of skill level. Consider how many people have been driving a car for decades, and are still terrible at it. :-)

I initialize when I declare as a matter of habit, to avoid "uninitialized" warnings.

You might as well just turn off the "uninitialized" warnings, if that's the case. Usually I start out with my variables all uninitialized, but use an algorithm that should initialize them before I use them. If that initialization doesn't happen, then I get a warning, and I know my algorithm is funky. It can be very helpful.

I wasnt aware that line wasn't blazar-approved ... If you have a recommendation for the "newbies", you might want to actually write out some alternate code

It's not just blazar's opinion. The standard way to get iterator behavior in Perl is a while loop. A filehandle is best used as an iterator. This is common practice.

Replies are listed 'Best First'.
Re^5: Yet another array problem
by kwaping (Priest) on Jul 29, 2005 at 18:08 UTC
    Good feedback, thanks.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2020-05-31 16:04 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (175 votes). Check out past polls.