Now that is an easy one ;-)

Your variable is called @actuali, but you want to print a variable called @actual outside the loop.

Rata

PS.: please use code-tags for formatting your code!

OOps ... I got confused by the [] not shown due to missing code-tags :-(

Now here is some code (yours, however modified) with comments - and it works :-)

use strict; # use this always. + no excuses. use warnings; # same with this. my @params; my @charam; my @actual; # declare all your + variables!! my $i; my $j; # declare all your + variables!! open FILE, "params.txt" or die "unable to open\n"; for($i=1,$j=1; <FILE>; $i++, $j++) { chomp; (@params[$i], @charam[$j]) = split(':'); # use $i and $j here, +not i and j!!! $actual[$i]=$charam[$j]; # better use $actual[$ +i] instead of @actual[$i] (same on line above!) print "inside $actual[$i]\n"; } print "out side @actual\n"; # it works, but gi +ves an error as $actual[0] is undefined close(FILE);

In reply to Re: array print outside loop by Ratazong
in thread array print outside loop by shivakumar.balur

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.