I created a module from which I want to forcibly export a variable and optionally export a function. Problem is I seem to be able to either export forcibly (@EXPORT) or optionally (@EXPORT_OK) but not both.
package testpack ;
use strict ;
use Exporter ;
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, $xyz) ;
$VERSION = 0.99 ;
@ISA = qw(Exporter) ;
@EXPORT = qw($xyz) ;
@EXPORT_OK = qw(&rtine) ;
$xyz = 888 ;
sub rtine {
$xyz = 999 ;
print "I\'m in the su-ub ! and xyz = $xyz \n" ;
}
1;
Heres the importing script :
use strict ;
BEGIN{$Exporter::Verbose=1}
use testpack ('&rtine') ;
print "I\'m before the sub and xyz = $xyz \n" ;
&rtine ;
print "I\'m after the sub and xyz = $xyz \n" ;
When I run it, it doesn't import $xyz..
Exporter::import('testpack', '&rtine') called at E:\Sites\packnew\cgi-
+bin\test.pl
No matter how I twist and turn, I can't export forcibly the variable and optionally the function. Been at this for a day and a half.
Anyone have a tip for me ?
Phil.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.