Skip to content

Commit

Permalink
perldiag: update "You need to quote X" %SIG diagnostic
Browse files Browse the repository at this point in the history
The old description was clearly written for perl 4 programmers.

- change "Perl 5" to just "Perl"
- recommend foo() to call subroutines (instead of &foo)
- mention the option of putting a subroutine reference in %SIG
  • Loading branch information
mauke committed Apr 17, 2024
1 parent be3876f commit d150bda
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pod/perldiag.pod
Original file line number Diff line number Diff line change
Expand Up @@ -8255,11 +8255,19 @@ set-id, your best bet is to put a set-id C wrapper around your script.

=item You need to quote "%s"

(W syntax) You assigned a bareword as a signal handler name.
Unfortunately, you already have a subroutine of that name declared,
which means that Perl 5 will try to call the subroutine when the
assignment is executed, which is probably not what you want. (If it IS
what you want, put an & in front.)
(W syntax) You assigned a bareword as a signal handler name:

$SIG{...} = foo;

However, this will not make C<sub foo> the signal handler. Instead, Perl
will call the subroutine when the assignment is executed and use the
returned value as the signal handler, which is probably not what you want.
(If it I<is> what you want, put C<()> after the subroutine name to avoid
the warning.)

To register the subroutine as the signal handler, take a reference to it:

$SIG{...} = \&foo;

=item Your random numbers are not that random

Expand Down

0 comments on commit d150bda

Please sign in to comment.