G'day vinoth.ree,
After reading this in your OP:
"... read the first 50 characters ..."
these two lines in your code grabbed my attention:
... my $oshort_line = substr( $oline, 0, 49 ); ... my $nshort_line = substr( $nline, 0, 49 ); ...
I don't know if you thought that's an inclusive range, or something else. See the substr documentation:
"substr EXPR,OFFSET,LENGTH"
To get the first 50 characters from a string, you need OFFSET==0 and LENGTH==50. Here's an example of what you have and one of what you probably want:
$ perl -E 'my $x = "X" x 49 . "Y" x 49; say substr $x, 0, 49' XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $ perl -E 'my $x = "X" x 49 . "Y" x 49; say substr $x, 0, 50' XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXY
— Ken
In reply to Re^3: Best way to compare range of characters in two text files
by kcott
in thread Best way to compare range of characters in two text files
by vinoth.ree
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |