Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In Perl, you can't give a variable a specific type to ensure that it's able to store only particular kinds of values (integer, string, reference, and so on). That's usually not a problem, because Perl's automatic type conversions paper over most of the cracks very neatly [13]
Except when it comes to references.
It's an all-too-common mistake to put a reference into a scalar, and then subsequently forget to use the all-important dereferencing arrow:
sub pad_str {
my ($text, $opts) = @_;
my $gap = $opts{cols} - length $text; # Oops! Should be: opts->{cols}
my $left = $opts{centred} ? int($gap/2) : 0; # Should be: opts->{centred}
my $right = $gap - $left;
return $SPACE x $left . $text . $SPACE x $right;
}