B
bpatton
I'm trying to get this function to work. It's a snippett of my
original code, but functional. I'm at home and don't have my perl
book with me to look it up.
Here's the code.
package foo;
use strict;
use warnings;
use Data:
umper;
use vars qw ( $BY $INTO $VALUE );
my %input = ( by => 'by' ,
into => 'into' ,
value => 'value',
);
setKnownVariables(\%input);
print "by = $::BY\n";
print "into = $::INTO\n";
print "value = $::VALUE\n";
sub setKnownVariables($) {
my ($input) = @_;
my ($var,$uvar);
foreach $var (
'allow45',
'by',
'coincidenceOK',
'comment',
'filter',
'into' ,
'layer',
'lineEnd',
'lpad',
'lpadRedundant',
'metalSys' ,
'overlap',
'overlapOK',
'process' ,
'ruleGroupNumber' ,
'ruleName',
'sideLength',
'sideSpace',
'square',
'technology' ,
'touching',
'value',
'width',
) {
no strict 'refs';
$uvar = $var;
$uvar =~ tr/[a-z]/[A-Z]/;
if (exists $input->{$var}) {
$::${$uvar} = $input->{$var};
delete $input->{$var};
} else {
$::{$var} = undef;
}
}
}
original code, but functional. I'm at home and don't have my perl
book with me to look it up.
Here's the code.
package foo;
use strict;
use warnings;
use Data:
use vars qw ( $BY $INTO $VALUE );
my %input = ( by => 'by' ,
into => 'into' ,
value => 'value',
);
setKnownVariables(\%input);
print "by = $::BY\n";
print "into = $::INTO\n";
print "value = $::VALUE\n";
sub setKnownVariables($) {
my ($input) = @_;
my ($var,$uvar);
foreach $var (
'allow45',
'by',
'coincidenceOK',
'comment',
'filter',
'into' ,
'layer',
'lineEnd',
'lpad',
'lpadRedundant',
'metalSys' ,
'overlap',
'overlapOK',
'process' ,
'ruleGroupNumber' ,
'ruleName',
'sideLength',
'sideSpace',
'square',
'technology' ,
'touching',
'value',
'width',
) {
no strict 'refs';
$uvar = $var;
$uvar =~ tr/[a-z]/[A-Z]/;
if (exists $input->{$var}) {
$::${$uvar} = $input->{$var};
delete $input->{$var};
} else {
$::{$var} = undef;
}
}
}