perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
Below is, what I think is the pertinent code, -- I'm trying to divide an old prog into modules/packages.
It was all global vars all over the place, and trying to tighten up the interfaces is causing a few problems....
Like the following -- am trying to export the vars and necessary routines in EXPORT, and use Exporter...
But the import in the next package doesn't work.
Now I've tried it with a plain 'import Debug' (no qw), and with/without the following BEGIN -- why that doesn't work is beyond me.
Am beginning to think perl 5.14 is broken...
So many progs that worked under 5.12 won't work under 5.14... what a disaster!..
That's been happening at each of the last few releases
5.8->5.10 broke several (including this one, which was why I decided to rewrite it...but haven't ever gotten it working again...and am now up to 5.14...).
5.10->5.12 -- more progs broke, 5.12->5.14 -- more progs broke...
Seems like one can't upgrade perl and expect any stability these days ;-/.
Anyway, line with debug @ 119 is marked below...
For those that want complete code. I'll post it in a followup, but wanted to post the snippet that was most relevant (I thought), here so this post wouldn't be overwhelming...
I'm clueless when it comes to using Exporter except how documented in the perldoc -- and EXPORT isn't even documented anymore... (?!?)...
*sigh*....
How am I supposed to export vars and subs out of 1 routine to another?
Thanks!
-linda
It was all global vars all over the place, and trying to tighten up the interfaces is causing a few problems....
Like the following -- am trying to export the vars and necessary routines in EXPORT, and use Exporter...
But the import in the next package doesn't work.
Now I've tried it with a plain 'import Debug' (no qw), and with/without the following BEGIN -- why that doesn't work is beyond me.
Am beginning to think perl 5.14 is broken...
So many progs that worked under 5.12 won't work under 5.14... what a disaster!..
That's been happening at each of the last few releases
5.8->5.10 broke several (including this one, which was why I decided to rewrite it...but haven't ever gotten it working again...and am now up to 5.14...).
5.10->5.12 -- more progs broke, 5.12->5.14 -- more progs broke...
Seems like one can't upgrade perl and expect any stability these days ;-/.
Anyway, line with debug @ 119 is marked below...
For those that want complete code. I'll post it in a followup, but wanted to post the snippet that was most relevant (I thought), here so this post wouldn't be overwhelming...
I'm clueless when it comes to using Exporter except how documented in the perldoc -- and EXPORT isn't even documented anymore... (?!?)...
*sigh*....
How am I supposed to export vars and subs out of 1 routine to another?
Thanks!
-linda
The above gives: </code> > cnvWav2Flac Variable "$Filename2Fields" is not imported at ./cnvWav2Flac line 119.package Debug;{ use Readonly; sub RO(\[$@%]@) {goto &Readonly}; use Exporter 'import'; our @ISA = qw (Exporter); our @EXPORT=qw( Debug DEBUG_OPS $Filename2Fields $Halt_on_Error); my %dop = ( Filename2Fields => 1, HaltOnError => 2, ); sub _flagval { return $dop{$_[0]} } our $Filename2Fields = $dop{Filename2Fields}; our $HaltOnError = $dop{HaltOnError}; our $DEBUG_OPS = 0 | $Filename2Fields | $HaltOnError ; sub Debug($$) { my ($what, $str)=@_; if ($what & $DEBUG_OPS) { print STDERR $str; } } } ; package Transcode_plug;{ import Debug qw{Filename2Fields}; BEGIN {*Filename2Fields = \$Debug::Filename2Fields;} import Vars; use Exporter; our @ISA = qw(Exporter); our @EXPORT=qw( album album_artist artist freeDB_DiskID genre trknum trktitle year push_ar +ginfo get_bin_path ); sub get_fieldAR_from_filename($) { my $file=$_[0]; Debug($Filename2Fields,"get_fieldAR_from_filename($file)\n"); + <<---------- # line 119 my ($trknum, $trktitle, $artist, $album_artist, $genre, $year,$freeDB_DiscID); my ($rest,$tt_a, $aa_g_y);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: can't import using exporter
by chromatic (Archbishop) on Mar 12, 2012 at 07:05 UTC | |
by tobyink (Canon) on Mar 12, 2012 at 09:31 UTC | |
by perl-diddler (Chaplain) on Jun 25, 2012 at 01:00 UTC | |
by Anonymous Monk on Jun 26, 2012 at 05:16 UTC | |
by perl-diddler (Chaplain) on Jun 28, 2012 at 00:27 UTC | |
| |
by perl-diddler (Chaplain) on Mar 12, 2012 at 17:52 UTC | |
by tobyink (Canon) on Mar 12, 2012 at 18:20 UTC | |
by perl-diddler (Chaplain) on Mar 12, 2012 at 21:10 UTC | |
| |
Re: can't import using exporter
by Corion (Patriarch) on Mar 12, 2012 at 21:20 UTC | |
by perl-diddler (Chaplain) on Mar 12, 2012 at 23:08 UTC | |
by chromatic (Archbishop) on Mar 13, 2012 at 01:04 UTC | |
by perl-diddler (Chaplain) on Mar 13, 2012 at 02:52 UTC | |
by chromatic (Archbishop) on Mar 13, 2012 at 05:31 UTC | |
| |
by Anonymous Monk on Mar 13, 2012 at 04:46 UTC |
Back to
Seekers of Perl Wisdom