my @buttons = (0, 123, 0, 0);
foreach my $button (@buttons) {
if ($button > 0) {
# Do something
}
else {
# Do something
}
}
или
my @buttons = (0, 123, 0, 0);
for (my $i=0; $i<scalar @buttons; $i++) {
if ($buttons[$i] > 0) {
# Do something
}
else {
# Do something
}
}
Или
my @buttons = (0, 123, 0, 0);
foreach (@buttons) {
if ($_ > 0) {
# Do something
}
else {
# Do something
}
}