Hello
use strict; my ($row, $col) = (0, -1); my %TABLE; my @COLUMNS = ('Period', 'Code', 'Name', 'Handle', 'Date', 'From', 'To +'); my @VARIABLES = qw/$colPeriod $colCode $colName $colHandle $colDate $c +olFrom $colTo/; my %Header = ( columns => \@COLUMNS, variables => \@VARIABLES, table => \%TABLE, heading => 'true', row => $row, column => $col, ); BuildHeader(\%Header); sub BuildHeader { my ($header_ref) = @_; my $TABLE = $header_ref->{table}; my $row = $header_ref->{row}; my $col = $header_ref->{column}; #columns and variables array must be equal if ( scalar @{$header_ref->{columns}} != scalar @{$header_ref->{va +riables}} ) { return; } foreach ( @{$header_ref->{columns}} ) { $TABLE{table}[$row][++$col]{value} = $_; $TABLE{table}[$row][$col]{heading} = $header_ref->{heading}; #Populate each variable in @variables with $col value ++$col; #return the variables } }
In the above I've declared VARIABLES array. when I run the script it is not giving any errors (may be because I declared under qw operator).
I need to get all the variables back populated with $col value. I mean i need to include the scoping for all the variables with 'my'. How can i achieve that?
In reply to Populate variables with values by kalyanrajsista
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |