Sorry for the controversy - not my intent. I should've said something
different or omitted that entirely.
I use Perl often to process all kinds of text reports. By far and away,
the most common tools that I use are: a)split and b)match global combined with
c) regex. In my typical application, speed doesn't matter, but flexibility does.
It is very seldom that I encounter a fixed column report where substr would
That doesn't mean that I don't use substr, just that
in my personal experience, with the types of text reports that I process,
it doesn't come up. Mileage Varies! Processing a binary header, say like
that found in a .WAV file is a whole different critter, substr is definately
the right tool for that job. I am talking about text reports.
Just yesterday, a file that I've been processing since 2011 changed its format.
Oops. The same info is there, but it got moved around. The 2016 format
is different and I have no control over that change. But this change was
easy for me to adapt to and was something like this:
(split ' ',$line)[1,7,3] to (split ' ',$line)[1,4,-2]. If I had
used substr(), then this would have been a bigger deal. Changing something
that has been working for 5 years comes up all the time. Such is the nature
of using ad hoc methods to parse reports that you have no control over.
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>
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
Want more info? How to link or
or How to display code and escape characters
are good places to start.