use strict; use Data::Dumper; my @seq; # array of sequences my %seq; # hash lookup of sequences based on id's { local $/ = '=========================================='; while () { s/^==========================================//g; # strip out '>' from beginning s/==========================================$//g; # and end of line my $line = $_; next if !length($_); # ignore empty lines next if /^\n$/; my @a = split /\n/, $_; # collect lines in an array my @new_a = grep {$_ ne "" } @a ; # remove empty lines #s/^(.*)\n//; # and strip it out my @rec; s/\n/\t/mg; # join the sequence strings push @rec, @new_a; # push sequence into an array push @seq, \@rec; # push into array of sequences push @{ $seq{$new_a[1]} }, \@rec; # or store in a hash lookup } } print Dumper(\@seq); print Dumper(\%seq); __DATA__ ========================================== Log Entry 14: 27 Feb 2011 10:03:42 Alert Level 2: Informational Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D6A217E0200F0 FFFF027000120300 ========================================== Log Entry 13: 20 Feb 2011 08:33:42 Alert Level 2: Informational Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D60D1E60200E0 FFFF027000120300 ========================================== Log Entry 12: 20 Feb 2011 07:14:27 Alert Level 4: TEST ALERT!!!!!!!!!!!!!!!! Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D60BF530200D0 FFFF027000120300 ========================================== Log Entry 11: 13 Feb 2011 07:24:32 Alert Level 5: TEST ALERT!!!!!!!!!!!!!!!!!!!! Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D5787300200C0 FFFF027000120300 ========================================== Log Entry 10: 06 Feb 2011 10:36:26 Alert Level 2: Informational Keyword: Type-02 127002 1208322 Soft Reset Logged by: Baseboard Management Controller; Sensor: System Event 0x204D4E79AA0200B0 FFFF027000120300 ==========================================