Skip to main content


This "Useless use" message can be easily made by just having a statement with only a string literal inside. The message reads interestingly and rather high context -- meaning: readers need to learn at least a little bit about the concept of context in Perl programming language, to be able to understand that no words in that message are useless or void.

# perl x.pl
Useless use of a constant ("forty-two") in void context at x.pl line 3.

# cat x.pl
use v5.36;

"forty-two";

#perl
#context

in reply to gugod

The best part is that ending a module this way was mandatory for 30 years lol
in reply to EndlessMason

@EndlessMason In a module, it's not in void context so you don't get the warning. 😀

Also, most modules use 1, which is specifically exempt from this warning anyway:

use warnings;<br>1;<br>2;<br>3;<br>
Useless use of a constant (2) in void context at - line 3.<br>Useless use of a constant (3) in void context at - line 4.<br>
in reply to EndlessMason

@EndlessMason 1 is a special value that's different from anything else "forty-two". Also running code as script.pl never required a return value but always warned about useless use of constant because only modules use()d or files require()d were required to return a true value to indicate successful loading.
#perl