And don't worry, I always use () with & so as not to get strange behavior.
& also disables prototypes.
use strict;
use warnings;
sub my_splice(\@$;$@) {
my ($array, $start, $length, @insert) = @_;
return splice(@$array, $start, $length, @insert);
}
{
my @array = qw( a b c );
splice(@array, 1, 1, qw( d e ));
print(@array, "\n"); # adec
}
{
my @array = qw( a b c );
my_splice(@array, 1, 1, qw( d e ));
print(@array, "\n"); # adec
}
{
my @array = qw( a b c );
&my_splice(@array, 1, 1, qw( d e ));
print(@array, "\n"); # Can't use string ("a") as an ARRAY ref whil
+e "strict refs" in use at !.pl line 6.
}
Now, you could argue that prototypes should be avoided, but they are used by many modules.
|