I'm looking for an easy way to check for a correct number of command line parameters, displaying a usage message if an error occurs and then immediately exit.
I thought of something like
if (@ARGV < 3) { print STDERR "Usage: $0 PATTERN [FILE...]\n"; exit 1; }
Is this a valid pattern?
Yes, it is fine. @ARGV contains the command-line arguments and evaluates in scalar context to their number.
@ARGV
(Though it looks like you meant @ARGV < 2 or < 1 from your error message.)
@ARGV < 2
< 1