Perl Programming/Keywords/substr

The substr keyword
The substr command extracts and returns a substring out of EXPRESSION, where the first character is at OFFSET 0. If OFFSET is negative, it starts to count from the end of the string. If LENGTH is negative, it leaves that much characters from the string's end.

substr can also be used as an lvalue, if <tt>EXPRESSION</tt> is also an lvalue. By an assignment larger or shorter than <tt>LENGTH</tt>, the string will grow or shrink respectively to accommodate it.

If <tt>OFFSET</tt> and <tt>LENGTH</tt> specify a substring partly outside the string, only the part within the string is returned. If it is beyond both ends, <tt>undef</tt> is returned, and an exception is raised, if it is an lvalue.

Examples
The code