# Pattern to be Parsed is below
#
# 		ABC_011 0311           0311      Pat Asc      FirstName LastName MiddleName ABCAHS:  no City present, City Required...
# 		ABC_010 V9D2 0310      0311      Requires     FirstName MiddleName          SANAH 3.0x- 55+ User Fields UI- : no feature.
# 		ABC_000 0903 9.0a1     0903      Pat Asc      FirstName LastName            blah blah blah Series Timeframe max
# 		ABC_579 0903 0303_AB99 0311      Cat Dog                LastName MiddleName Serivce Summarisation not option sorting by Date.
# 		ABC_707 0903           0311                                                 SRFDSA0142\\///SS:NullPointerException:mark incomplete
# 		ABC_707 0903                                                                SRFDSA0142\\///SS:NullPointerException:mark incomplete
#
# Below is the expected results
# from
# 		ABC_011 0311           0311      Pat Asc      FirstName LastName MiddleName ABCAHS:  no City present, City Required...
#
# @array [0]="ABC_011"
# @array [1]="0311"
# @array [2]=""
# @array [3]="0311"
# @array [4]="Pat Asc"
# @array [5]="FirstName LastName MiddleName"
# @array [6]="ABCAHS:  no City present, City Required..."
#
#
# from
# 		ABC_000 0903 9.0a1     0903      Pat Asc      FirstName LastName            blah blah blah Series Timeframe max
#
# @array [0]="ABC_000"
# @array [1]="0903"
# @array [2]="9.0a1"
# @array [3]="0903"
# @array [4]="Pat Asc"
# @array [5]="FirstName LastName"
# @array [6]="blah blah blah Series Timeframe max"
#
#
# from
# 		ABC_579 0903 0303_AB99 0311      Cat Dog                LastName MiddleName Serivce Summarisation not option sorting by Date.
#
# @array [0]="ABC_579"
# @array [1]="0903"
# @array [2]="0303_AB99"
# @array [3]="0311"
# @array [4]="Cat Dog"
# @array [5]="LastName MiddleName"
# @array [6]="Serivce Summarisation not option sorting by Date."


use warnings;
use strict;

# use Data::Dumper;  # FOR DEBUG


# since all lines seem to have data in fields of fixed width,
# use unpack() function on each line.

# unpack() template sub-fields:
#            start  field
#            col    width
my $field1 = ' @2     A8'; # individual field descriptions
my $field2 = '@10     A5'; #
my $field3 = '@15    A10'; #
my $field4 = '@25    A10'; #
my $field5 = '@35    A13'; #
my $names  = '@48    A30'; #
my $notes  = '@78    A* '; #

my $DataFields =  # generate unpack() template string
   $field1 . $field2 . $field3 . $field4 . $field5 . $names . $notes;


my @Lines;

while (<DATA>) {

    # generate array of fixed-width data fields unpacked from each line
    my @fields = unpack $DataFields, $_;

    # trim leading and trailing whitespace from each field.
    s{ \A \s+ | \s+ \z }{}gxms for @fields;

    # push reference to array of fields to array of lines processed
    push @Lines, \@fields;

    # although it may be a bit less maintainable to do so,
    # the three statements above could be combined into one, as follows:
    # push @Lines,
    #      [ map { s{ \A \s+ | \s+ \z }{}gxms;  $_ } unpack $DataFields, $_ ]
    #      ;

    }


# print Dumper(\@Lines);  # FOR DEBUG

for my $line (0, 2, 3) {  # display certain processed lines...
    my @fields = @{ $Lines[$line] };  # array of fields
    for my $field (0 .. $#fields) {   # for each field index...
        print qq(line $line field $field = "$fields[$field]" \n);
        }
    print "\n";
    }


__DATA__
		ABC_011 0311           0311      Pat Asc      FirstName LastName MiddleName ABCAHS:  no City present, City Required...
		ABC_010 V9D2 0310      0311      Requires     FirstName MiddleName          SANAH 3.0x- 55+ User Fields UI- : no feature.
		ABC_000 0903 9.0a1     0903      Pat Asc      FirstName LastName            blah blah blah Series Timeframe max
		ABC_579 0903 0303_AB99 0311      Cat Dog                LastName MiddleName Serivce Summarisation not option sorting by Date.
		ABC_707 0903           0311                                                 SRFDSA0142\\///SS:NullPointerException:mark incomplete
		ABC_707 0903                                                                SRFDSA0142\\///SS:NullPointerException:mark incomplete
