Perl substr Application
Use encode;
$ STR = decode ('gbk', "test text ");
Print encode ('gbk', substr ($ STR, 0, 1 ));
========================================================== =====
Command: substr
Syntax: substr ($ string, offset, length)
Offset indicates the position of the starting character. Length indicates the length of the referenced string. If length is omitted, it indicates the length of the last character from the starting value to the string. If offset is a negative value, it specifies a character from the right of the string.
Example:
$ S = substr ("perl5", 2,2); # $ S = "RL ";
$ S = substr ("perl5", 2); # $ S = "rl5 ";
$ S = substr ("perl5",-2, 2); # $ S = "L5 ";
========================================================== ============
Syntax
Substr expr, offset, Len, replacement
Substr expr, offset, Len
Substr expr, offset
==============================================
Http://www.perlmeme.org/howtos/perlfunc/substr.html
Http://www.tutorialspoint.com/perl/perl_substr.htm