perl exit loop
# Basic syntax:
last;
# Where last is analogous to break in Python, Bash, R, etc
# Example usage:
for my $i (0 .. 5) {
print "index is $i\n";
# Exit the for loop if the index equals 3
if ($i == 3) {
last;
}
}
perl exit loop
# Basic syntax:
last;
# Where last is analogous to break in Python, Bash, R, etc
# Example usage:
for my $i (0 .. 5) {
print "index is $i\n";
# Exit the for loop if the index equals 3
if ($i == 3) {
last;
}
}
perl exit loop example
my $counter = 1;
foreach $foo (sort {$importHash{$b} <=> $importHash{$a}} (keys %importHash))
{
# push the string $foo onto the @tags array
push @tags, $foo;
# break out of our perl loop when the counter reaches 10
last if ($counter++ == 10);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us