What is the "xxx: script" syntax in perl?

Viewed 75

I have a script like this, and it runs:

#!/usr/bin/env perl
error: print 0x41

I'm expecting the error: part to trigger an syntax error, but it didn't. Does anyone know this syntax?

1 Answers

It's a label.

For example,

OUTER:
for my $x (qw( a b c )) {
   for my $y (1..3) {
      say "$x$y";
      last OUTER if $x eq 'b';
   }
}

Output:

a1
a2
a3
b1
Related