Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
for(my $index=0; $index<=$#ARR1; $index++) {
my $var1 = $ARR1[$index];
my $var2 = $ARR2[$index];
# Use them here .....
}
$array_length=@ARRAY1;
for($x=0; $x<$array_length; ++$x){
$ITEM1=$ARRAY1[$x];
$ITEM2=$ARRAY2[$x];
}
Range Operators
Binary ".." is the range operator, which is really two different operators depending on the context. In list context, it returns a list of values counting (up by ones) from the left value to the right value. If the left value is greater than the right value then it returns the empty list. The range operator is useful for writing foreach (1..10) loops and for doing slice operations on arrays. In the current implementation, no temporary array is created when the range operator is used as the expression in foreach loops, but older versions of Perl might burn a lot of memory when you write something like this:
for (1 .. 1_000_000) {
# code
}
I figured I could use the old standard index method but being a perl novice I thought there might be a more elegant perlish method.