Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Specifying main:: scope

by wog (Curate)
on Dec 05, 2001 at 03:16 UTC ( #129473=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://129473]
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: (3)
As of 2022-12-06 20:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found