Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Encapsulate function and variables

by gaal (Parson)
on Jun 19, 2007 at 11:46 UTC ( #621996=note: print w/replies, xml ) Need Help??

in reply to Encapsulate function and variables

For most practical purposes, you can treat a namespace exactly as if it were a hash.

sub capsule { my($capsule_name, $file) = @_; my $src = slurp $file; eval "package $capsule_name; \n#line 1\n$src" or die $@; } [...] capusle("Foo", ""); print $Foo::{text};

An alternative is to load everything into a dummy package with a throwaway name, then to export everything out of it. Of course, both these proposals break if switches namespaces itself, and that's hard to catch.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://621996]
[LanX]: I don't get it
[LanX]: do I need to activate JS to see Trump loosing his wig?
[LanX]: aha ...
LanX Finally, there is a certain order or choreography to the greetings, which Kornhauser-Duda appears to have been following. First, the two heads of state shake hands, while the two first ladies do the same
[LanX]: FAKE NEWS , erix, so sad! Fired!

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2018-03-22 20:11 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (285 votes). Check out past polls.