U
usaims
Hello:
I'm trying to write code in a 'Perlish' way. I want the sum of the same
element of two arrays. Everytime I want to run this code, it will have
different results in the arrays, so I want to simply the code to
accomondate that. Below is what I want to see in the long un-perlish
way, I'm sure there is an easier way to write this. Please excuse my
inexperience in coding, also I looked in the camel book and the
cookbook, didn't see anything related. TIA
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
my @array = (1, 2, 3 );
my @testarray = (2, 3, 4);
my $test1 = $array[0] + $testarray[0];
my $test2 = $array[1] + $testarray[1];
my $test3 = $array[2] + $testarray[2];
print "$test1\n";
print "$test2\n";
print $test3;
usaims
I'm trying to write code in a 'Perlish' way. I want the sum of the same
element of two arrays. Everytime I want to run this code, it will have
different results in the arrays, so I want to simply the code to
accomondate that. Below is what I want to see in the long un-perlish
way, I'm sure there is an easier way to write this. Please excuse my
inexperience in coding, also I looked in the camel book and the
cookbook, didn't see anything related. TIA
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
my @array = (1, 2, 3 );
my @testarray = (2, 3, 4);
my $test1 = $array[0] + $testarray[0];
my $test2 = $array[1] + $testarray[1];
my $test3 = $array[2] + $testarray[2];
print "$test1\n";
print "$test2\n";
print $test3;
usaims