Somehow your parsing code and your data don't seem to be related at all. For example your code checks if the data has 11 columns, but your data only has 5 columns. So no wonder it doesn't work. (Your data sample has 11 interesting rows, but I guess that's more of a coincidence.
I'd approach the problem like this:
use strict;
use warnings;
use 5.010;
while (<DATA>) {
# skip separator lines
next if /^----/;
my @columns = split /\s*\|\s*/;
# remove leading space
$columns[0] =~ s/^\s+//;
# now do something with @columns
# you'll want to do something else here, not just
# printing to the console
say join ',', @columns;
}
__DATA__
------|----------|--------|-------------------------|--------|
S.No | TimeStamp| UE-Name| Test-Config | UL/DL |
------|----------|--------|-------------------------|--------|
1 | 18:24:38 | -NA- | Sanity_001_0001_10_00 | System |
------|----------|--------|-------------------------|--------|
2 | 18:31:34 | ueh1 | Sanity_002_0002_00_11 | UL |
------|----------|--------|-------------------------|--------|
3 | 18:23:48 | ueh1 | Sanity_003_0003_06_09 | UL |
------|----------|--------|-------------------------|--------|
3 | 18:23:48 | ueh1 | Sanity_003_0003_06_09 | DL |
------|----------|--------|-------------------------|--------|
4 | 18:38:30 | ueh1 | Sanity_004_0004_24_00 | DL |
------|----------|--------|-------------------------|--------|
5 | -NA- | -NA- | Sanity_001_0001_10_00 | System |
------|----------|--------|-------------------------|--------|
6 | 18:31:34 | ueh2 | Sanity_002_0002_00_11 | UL |
------|----------|--------|-------------------------|--------|
7 | 18:23:49 | ueh2 | Sanity_003_0003_06_09 | UL |
------|----------|--------|-------------------------|--------|
7 | 18:23:48 | ueh2 | Sanity_003_0003_06_09 | DL |
------|----------|--------|-------------------------|--------|
8 | 18:38:30 | ueh2 | Sanity_004_0004_24_00 | DL |
------|----------|--------|-------------------------|--------|
-
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.
|