my %record; if ( /^Request Number:/ ) { my @flds = (); push @flds, substring( $_, 0, 40 ); push @flds, substring( $_, 40, 26 ); push @flds, substring( $_, 66 ); # rest of line for my $fldname ('Request Number', 'Parent', 'Priority') { (my $val = shift @flds) =~ s/^$fldname\s*:\s*//; $val =~ s/\s*$//; # update: remove leading/trailing whitespace... $record{$fldname} = $val; # which means this could be "" -- not a problem } } # and likewise for each other type of line