Apart from the headers are those fixed width fields?

If they are unpack can be pressed into service to break the records into their respective fields.

This uses an array of hashes and, for the pro id fields, a AoHoA. I've used printf to reassemble the data. You may have to adjust the field widths to suit.

The debugging prints are left in if you want to see what is going on. You might want to consider what error checking you need.

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $headers = <DATA>; my (%field, @db); while (my $record = <DATA>){ chomp $record; my ($character, $count, $length, $pro_id) = unpack(q{A29A6A7A*}, $re +cord); #print qq{*$_* } for $character, $count, $length, $pro_id; #print qq{\n}; if ($character ne q{W}){ push @db, {%field} if exists $field{character}; %field = (); $field{character} = $character; } elsif ($count ne q{W}){ $field{count} = $count; } elsif ($length ne q{W}){ $field{length} = $length; } elsif ($pro_id ne q{W}){ push @{$field{pro_id}}, $pro_id; } } push @db, {%field}; #print Dumper \@db; for my $record (@db){ printf( qq{%-29s%-6s%-7s%s\n}, $record->{character}, $record->{count}, $record->{length}, $record->{pro_id}[0], ); for (1..$#{$record->{pro_id}}){ printf( qq{%47s\n}, $record->{pro_id}[$_], ); } } # 29 6 7 5 __DATA__ Character Count Length Pro_ID Timothy Watson 12 Medulla W W W W W W ID:10 W W W ID:11 W W W ID:12 W W W ID:13 W W W ID:14 W 5 W W W W 16 W Maya Alabina 5 Exo W W W W W W ID:28 W W W ID:30 W 1 W W W W 11 W
Timothy Watson 12 Medulla 5 16 ID:10 ID:11 ID:12 ID:13 ID:14 Maya Alabina 5 Exo 1 11 ID:28 ID:30

In reply to Re: Remove unwanted chars and maintain table integrity by wfsp
in thread Remove unwanted chars and maintain table integrity by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.