$ perl -we'sub foo { print $_[0] } eval { foo(substr "abc", 4, 1); 1} or die "croak: $@"' croak: substr outside of string at -e line 1.