Sto cercando di usare un'istruzione break
in un ciclo for
, ma dal momento che sto usando anche le subs strict nel mio codice Perl, sto ottenendo un errore che dice:
Bareword "break" non consentito mentre "strict subs" in uso in ./final.pl linea 154.
C'è un workaround per questo (oltre a disabilitare gli strict subs)?
Il mio codice è formattato come segue:
for my $entry (@array){
if ($string eq "text"){
break;
}
}
Dati aggiuntivi (nel caso in cui abbiate altre domande):
FOO: {
for my $i ( @listone ){
for my $j ( @listtwo ){
if ( cond( $i,$j ) ){
last FOO; # --->
# |
} # |
} # |
} # |
} # <-------------------------------
Su una grande iterazione mi piace usare gli interrupt. Basta premere Ctrl + C per uscire:
my $exitflag = 0;
$SIG{INT} = sub { $exitflag=1 };
while(!$exitflag) {
# Do your stuff
}