perl - How can I import global variables from a base module? -
I created a module Foo :: prototype with the global variable $ A and $ B. I want the package Foo :: Bar which uses the Foo :: prototype as a base to import global variables $ A and $ B I do not understand how to do this.
I understand that using global variables is not a good practice in general, but in this situation I want to use them.
The code looks like this:
Package Foo: prototype; My ($ A, $ B); Our @EXPORT = qw ($ A $ B); Sub New {[...] $ A = 1; $ B = 2; } 1; Package Fu: Bar; Use Base Fu: Prototype QW ($ A $ B); Sub-trial {print $ A, "\ n"; Print $ B, "\ n"; } 1; # Test.pl Foo: Bar- & gt; new (); Foo: Bar-> testing ();
Edit:
I want to write Compact Foo :: Prototype sub class as possible for other people. Instead of writing $ self-> {A} -> foo (), I want to let people write $ a-> foo ().
Comments
Post a Comment