G
grocery_stocker
The following code is taken from perltooc
#!/usr/bin/perl -w
package Some_Class;
use strict;
our %ClassData = (
CData1 => "",
CData2 => "",
);
print "keys: " , keys %ClassData , "\n";
for my $datum (keys %ClassData) {
print "Datum values are: $datum \n";
print "Shit in global array: @_ \n";
no strict "refs";
*datum = sub {
#shift;
my $class = shift;
print "The class is: $class \n";
print "The value of datum is now: $datum \n";
$ClassData{$datum} = shift if @_;
print "values:" , $ClassData{$datum} , "\n";
print "The glob is: ", *datum , "\n";
print "The value of datum again is: ", $datum , "\n";
return $ClassData{$datum};
}
}
#print "The glob is: ", *datum , "\n";
package main;
no strict "refs";
#$Some_Class::CData1 = "test";
#my $first_value = Some_Class->datum("test");
#print "The value in main is: $first_value \n";
1)When I run the code; I get the following:
keys: CData2CData1
Datum values are: CData2
Shit in global array:
Datum values are: CData1
Shit in global array:
Subroutine Some_Class::datum redefined at ./att.pl line 33.
I'm not too sure how the subroutine gets redefined.
2)How do I invoke the method?
There are a few other things that are murky, but these are the two
major issues.
Chad
#!/usr/bin/perl -w
package Some_Class;
use strict;
our %ClassData = (
CData1 => "",
CData2 => "",
);
print "keys: " , keys %ClassData , "\n";
for my $datum (keys %ClassData) {
print "Datum values are: $datum \n";
print "Shit in global array: @_ \n";
no strict "refs";
*datum = sub {
#shift;
my $class = shift;
print "The class is: $class \n";
print "The value of datum is now: $datum \n";
$ClassData{$datum} = shift if @_;
print "values:" , $ClassData{$datum} , "\n";
print "The glob is: ", *datum , "\n";
print "The value of datum again is: ", $datum , "\n";
return $ClassData{$datum};
}
}
#print "The glob is: ", *datum , "\n";
package main;
no strict "refs";
#$Some_Class::CData1 = "test";
#my $first_value = Some_Class->datum("test");
#print "The value in main is: $first_value \n";
1)When I run the code; I get the following:
keys: CData2CData1
Datum values are: CData2
Shit in global array:
Datum values are: CData1
Shit in global array:
Subroutine Some_Class::datum redefined at ./att.pl line 33.
I'm not too sure how the subroutine gets redefined.
2)How do I invoke the method?
There are a few other things that are murky, but these are the two
major issues.
Chad