Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Creating "Lexical" Symbol Table Aliases (a la "use vars") From The Same Package

by OneTrueDabe (Acolyte)
on May 08, 2014 at 16:50 UTC ( #1085478=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
       use strict 'vars';
       Variable "@foo" is not imported at line 10.
       Global symbol "@foo" requires explicit package name at line 
    +10. had compilation errors.
  2. or download this
       use strict 'vars';
       package main;
          print "Foo: (@foo)\n";
  3. or download this
       use strict 'vars';
       package pkg;
          print "Foo: (@foo)\n";
  4. or download this
       use strict 'vars';
       package pkg;
          BEGIN { *pkg::foo = \@pkg::foo }
          print "Foo: (@foo)\n";
  5. or download this
        package pkg;
        sub BEGIN {
            *foo = \@foo;
  6. or download this
       use strict 'vars';
       Foo: ()

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1085478]
Front-paged by Corion
[james28909]: but then you have the others as well
[Lady_Aleena]: Renaming things like get_THAC0 to just THAC0 was easy. These are harder.
[james28909]: consolidate the three subs into one
[Lady_Aleena]: Um, what?
[james28909]: check is is data or hash or array and do tasks then return needed data
[Lady_Aleena]: james28909, you might want to look at the other two on my scratchpad.
[james28909]: after you send to a sub, you can check if it is array or ref ect with ref

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2017-05-24 04:48 GMT
Find Nodes?
    Voting Booth?