W
werwer
Here are two files that demonstrate the 'my' eval problem. "x.pl"
call two subs in "HPLC.pm". When the array @note is
'my'd, the sayNotes() eval creates no note array output.
The eval works without my, AND with 'our' or 'local'
As written below, 'my @note', the eval fails.
What's up? What'd I do wrong?
active 5.8.8, xp
#--------------------------- x.pl
use HPLC;
HPLC::demofill();
HPLC::sayNotes();
#--------------------------- HPLC.pm
package HPLC;
my $bug = 0;
$bug = 1;
BEGIN {
use Exporter ();
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
$VERSION = 1.02;
@ISA = qw(Exporter);
@EXPORT = qw();
%EXPORT_TAGS = ();
@EXPORT_OK = qw();
}
our @EXPORT_OK;
@reagent;
@created;
@type;
@type2;
my @note;
@line_items;
sub
demofill {
$note[0] = "Note one.";
$note[1] = "Note two.";
$note[2] = "Note three.";
$note[3] = "Note four.";
}
#
------------------------------------------------------------------------
sub
sayNotes {
foreach my $n (qw(reagent created type type2 note)) {
$bug and print qq/array name: "$n"\n/;
foreach my $val (eval "\@$n") {
print qq/Value of notes $n is $val\n\n/;
}
}
print $note[0] . "\n";
#print $note[1] . "\n";
#print $note[2] . "\n";
#print $note[3] . "\n";
}
call two subs in "HPLC.pm". When the array @note is
'my'd, the sayNotes() eval creates no note array output.
The eval works without my, AND with 'our' or 'local'
As written below, 'my @note', the eval fails.
What's up? What'd I do wrong?
active 5.8.8, xp
#--------------------------- x.pl
use HPLC;
HPLC::demofill();
HPLC::sayNotes();
#--------------------------- HPLC.pm
package HPLC;
my $bug = 0;
$bug = 1;
BEGIN {
use Exporter ();
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
$VERSION = 1.02;
@ISA = qw(Exporter);
@EXPORT = qw();
%EXPORT_TAGS = ();
@EXPORT_OK = qw();
}
our @EXPORT_OK;
@reagent;
@created;
@type;
@type2;
my @note;
@line_items;
sub
demofill {
$note[0] = "Note one.";
$note[1] = "Note two.";
$note[2] = "Note three.";
$note[3] = "Note four.";
}
#
------------------------------------------------------------------------
sub
sayNotes {
foreach my $n (qw(reagent created type type2 note)) {
$bug and print qq/array name: "$n"\n/;
foreach my $val (eval "\@$n") {
print qq/Value of notes $n is $val\n\n/;
}
}
print $note[0] . "\n";
#print $note[1] . "\n";
#print $note[2] . "\n";
#print $note[3] . "\n";
}