$ perl -wE 'if (0) { label: say 1 }; goto label'
Can't find label label at -e line 1.
$ perl -wE 'if (1) { label: say 1;}; goto label'
Use of "goto" to jump into a construct is deprecated at -e line 1.
1
Use of "goto" to jump into a construct is deprecated at -e line 1.
1
^C # aborted, because it loops
####
#!/usr/bin/perl
use strict;
use warnings;
use 5.014;
sub f {
my $arg = shift;
if ($arg == 0) {
label:
say 'here';
}
elsif ($arg == 1) {
# don't execute a branch with 'label:'
}
else {
goto label
}
}
f($_) for 0..2;
__END__
here
here
####
$ perl -wE 'sub g() { label: say "here" }; g; goto label'
here
Can't find label label at -e line 1.