perlnub has asked for the wisdom of the Perl Monks concerning the following question:
first.pl:#!/usr/bin/perl package subs::utils; use strict; use warnings; BEGIN { require Exporter; # set the version for version checking our $VERSION = 1.00; # Inherit from Exporter to export functions and variables our @ISA = qw(Exporter); # Functions and variables which are exported by default # exported only if fully qualified our @EXPORT_OK = qw($henky); } our $henky = "henky_init"; END { } 1; # return a true value, standard module behaviour
second.pl (called by first.pl):use subs::utils; print "now1: " . $subs::utils::henky . "|\n"; $subs::utils::henky = "spanky"; print "now2: " . $subs::utils::henky . "|\n";
gives output:use subs::utils; print "now3: " . $subs::utils::henky . "\n";
If I look at the output of 'use' I think I understand this doesnt work:now1: henky_init| now2: spanky| now3: henky_init
How to get: 'now3: spanky|' in second.pl ?? Many thanks, the perl newb,BEGIN { require "My/Module.pm"; My::Module->import(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: global module variable are imported copies?
by kennethk (Abbot) on Sep 17, 2012 at 14:17 UTC | |
|
Re: global module variable are imported copies?
by tobyink (Canon) on Sep 17, 2012 at 19:29 UTC | |
by perlnub (Initiate) on Sep 18, 2012 at 07:18 UTC | |
by kennethk (Abbot) on Sep 18, 2012 at 15:30 UTC | |
|
Re: global module variable are imported copies?
by Anonymous Monk on Sep 17, 2012 at 19:14 UTC | |
|
Re: global module variable are imported copies?
by BillKSmith (Monsignor) on Sep 17, 2012 at 15:33 UTC |