|Think about Loose Coupling|
Re^3: referencing listby sauoq (Abbot)
|on Jun 06, 2012 at 10:50 UTC||Need Help??|
However if I add 'use strict;', I get the message 'Global symbol "$c" requires explicit package name ...'.
Yes, and if you named $a and $b something more reasonable, you'd hear about them too. (You only don't because they are special case variables used in sort blocks.) You can take care of that by declaring your globals though, and that's something you should be doing anyway. The following is safe under warnings and strict.
It also shows that using $a and $b is fine, despite also using them for a sort block. The problem with using $a and $b comes up when you have them declared as lexicals...
Since we all usually declare our variables as lexicals these days, the advice "don't use $a and $b" get dispensed without a lot of understanding about why it matters. Or when it doesn't.
Update: By the way, Data::Alias is a fine module and you shouldn't hesitate to use it if you can and it passes its tests. Sometimes people don't have control over what perl modules are available in their environment, particularly ones with an XS component. And sometimes modules have bugs, particularly platform specific ones, that prevent them being used. And sometimes adding a module isn't worth it when a couple extra lines of code will do. This is why I offered the old way of doing this. It's up to you to decide what is most appropriate in your situation.
"My two cents aren't worth a dime.";