in reply to Specifying main:: scope
To say that $a and $b are in main:: you can use something like:
package main; our($a,$b); package RealPackage; # ...
However, I think you are doing something that is not a good idea. Since you seem to have perl >=5.6, I would reccommend using a function with a prototype of ($$) as your sort routine:
sub directories_first ($$) { my ($a,$b) = @_; # ... }
Otherwise, if your function is to work should you want to use it in a package besides main you're going to need to do something to use the correct package's variable, such as dynamically generating the function on export or using symbolic references.
|
---|
In Section
Seekers of Perl Wisdom