Unclear spec:
These pushed values in a set of 4, can be any no of times in the last place of each input line.
But in your "Desired output" block there's only one set of four on a line? Then there's a line break, and the next line contains the continuation? Is that really what you want, or do you want the elements at index 7 in each array ref on one line? Then, you have those coordinate blocks neatly left-aligned at column 34. Is that a requirement? I'll assume it is.
At line 65, put brackets around @tmp, otherwise you will have a flat list in @finalarr.
From line 11 on things are getting messy. No need to dereference $cordinate_r into @refer, so no need for line 13.
To get at the data:
foreach my $ref(@$cordinate_r)
{
my $line = join ' ', @$ref[0..6];
# splice field 7 into groups of four
my @ary = @{$ref->[7]};
my @coord;
while(@ary) {
push @coord, join ' ', splice @ary, 0, 4 ;
}
no warnings 'uninitialized';
# see 'perldoc perlform' for what follows
write;
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
$line, shift @coord
~@<<<<<<<<<<<<<<<<<<<<<<<<
shift @coord
.
}
Output:
G6081 yaaX 5234 5530 + 6 6 244 480 540 480
EG10011 yaaA 5683 6459 - 6 7 693 480 1010 480
10 560 469 560
EG11555 yaaJ 6529 7959 - 7 8 539 560 1010 560
10 640 969 640
Be consistent with the alignment of your curlies!
There's more to 'go all perlmonks on you', no time now... look for an update of this node.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
-
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.