in reply to Re^2: substr outside of string
in thread substr outside of string

Your my is rather useless inside the "then" clause. May I recommend the following variation:
my $s = (length($str) < $index ? substr($str, $index, 1) : '' # or undef, or die, or ... );

Replies are listed 'Best First'.
Re^4: substr outside of string
by hgolden (Pilgrim) on Sep 09, 2006 at 19:29 UTC
    Good point. I'd copied that line out of the original code and hadn't thought about it. Thanks for the catch.

    Hays