in reply to Re: Square the array values.
in thread Square the array values.
use strict; use warnings; use Data::Dumper; my @array=(1,2,3); print Dumper \@array; my $len=$#array; while($len>=0) { $array[$len]=$array[$len]*$array[$len]; $len--; } print Dumper \@array;
my @array=(1,2,3); foreach (@array) { $_=$_*$_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Square the array values.
by chromatic (Archbishop) on Mar 18, 2010 at 15:32 UTC |