in reply to RE: Re: Perl Safety
in thread Perl Safety

Use package as a buffer.
Write a package of wrappers around his functions, and then only export those functions from the wrapper. There is no way for a module's code to run over yours if you don't import it into your package. Most of us (well, me anyway) use the main package without bothering to name it. Java doesn't let you get away with this, but since you argued for using Java, maybe you should adopt this habit. Then don't import anything into your named package that you didn't write.

Does this make sense or is my blood sugar too low?

Replies are listed 'Best First'.
RE: RE: RE: Re: Perl Safety
by gaspodethewonderdog (Monk) on Aug 25, 2000 at 23:45 UTC
    Well... I am getting at his module via:
    use Package Package::get_data();
    yet mysteriously in my code after I call Package::get_data() all of a sudden I have variables $x, $y, $z that are defined... now I would have expected theses variables to be Package::x Package::y Package::z, but there they are. I asked the engineer about this and he said that there wasn't any other way to pass multiple variables back through a return... when I suggested a hash he was particularly receptive to the idea...
      untested psuedo-code
      use strict; # To make sure you use the right package names. package My_Wrapper; sub My_get_data { local $x, $y, $z; # I had 'my', but [tilly] is right. # Thats why I said, "I think." here. get_data( @_ ); return ( $x, $y, $z ); } package My_main my ( $x, $y, $z ) = My_Wrapper::My_get_data;
      That's a stab in the dark. I'm tired and I don't feel like taking the time to construct your situation for testing. But I think that is the direction to go. My_Wrapper will collect ugly globals, but they shouldn't propogate to My_main.
        thanks Adam, I'll play around with that and local and see if I can't beat something into submission... it certainly isn't a very attractive way to do it, but if it works I guess I can't complain too much...
        That has to be a local, the my is not visible to get_data. (Which is kinda the idea...) Possible gotcha. He may assume that some globals are set later.

        BTW if you will have to work with this kind of idiocy and cannot get relief, I suggest finding a more congenial workplace. They may take finding, but they do exist...