#!/usr/local/bin/perl use strict; use warnings; use Data::Dump qw(pp); my %log; my $record = 0; #to be incremented on each round while(my $line = ){ chomp $line; my ($system,$server,$b_in,$byteIn,$b_out, $byteOut); if($line =~ /System/){ $record++ ; ($system,$server) = split / : /,$line; push @{$log{'record'.$record}},{$system=>$server} }elsif($line =~ /ByteIn/){ ($b_in, $byteIn) = split / : /,$line; push @{$log{'record'.$record}},{$b_in=>$byteIn} ; }elsif($line =~ /Byteout/){ ($b_out, $byteOut) = split / : /,$line; push @{$log{'record'.$record}},{$b_out=>$byteOut} } } print pp \%log; __DATA__ System : system001-server Box : HW a2b 1234Mb 123.4, address is 0012.d345.1234 (abc 0012.d123 +.4567) Byteout : 5816943852464 ByteIn : 4 Description : example_system_server1_example System : system002-server Box : HW a2b 1234Mb 123.4, ByteIn : 3385 Byteout : 58169 Description : example_system_server2_example