Subject: | calc() doesn't clear symbol table! |
what should this print? i would expect
joe
sam
red
blue
but it prints
joe
sam
sam
sam
very popular guy, sam!
the problem is that calc() doesn't clear the symbol table!
use Data::CTable;
$ct1 = Data::CTable->new( );
$ct2 = Data::CTable->new( );
$ct1->col('name', [qw(joe sam)]);
$ct2->col('color', [qw(red blue)]);
$ct2->calc( sub{
package main;
no strict 'vars';
if( defined($name) ){
print "$name\n";
}else{
print "$color\n";
}
});
$ct1->calc( sub{
package main;
no strict 'vars';
print "$name\n";
});