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.
# Method 1
foreach $Item (@Array) {
if ($Item == $Value) { # Numeric comparison
# if ($Item eq $Value) { # String comparison
do something
}
}
# Method 2
@Match = grep /^$Value$/, @Array;
if ($#Match >= 0) {
do something
}
@Sorted = sort {$a <=> $b } @Array; # Ascending order
print "The largest value is $Sorted[$#Sorted]\n";
print "The smallest value is $Sorted[0]\n";
$Largest = $Array[0];
$Index = 0;
for ($i=1; $i<=$#Array; $i++) {
if ($Array[$i] > $Largest) {
$Largest = $Array[$i];
$Index = $i;
}
}
print "The largest value $Largest is at index $Index\n";
@Sorted = sort {$b <=> $a } @Array; # Descending
if ($Sorted[0] == $Known) {
$Largest = $Sorted[1]; # Ignore known value
} else {
$Largest = $Sorted[0];
}