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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.