It just strikes me that as substr is a built-in, it could accept undef as a legitimate parameter.Actually, it's only build-ins (be them functions or operators) that trigger this warnings. Which you have to actually enable to see them.
Why shouldn't this warn, but any of the following should:
The warning is to catch cases like:$x = 3 + undef; printf "%s", undef; undef =~ /./;
One could argue that using a literal undef shouldn't trigger the warning (after all, then the programmer is explicit), but I don't think that information is easily available at the moment the warning is triggered. And the programmer may as well write "" or 0 anyway, saving some keystrokes.$x = expression unexpectedly returning undef. substr $y, 1, 2, $x;
In reply to Re^3: Use of uninitialized value in substr
by JavaFan
in thread Use of uninitialized value in substr
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |