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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |