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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|