Message: 11 started at: 2018-06-29 16:20:07 Transmit: ATV1[0D] Transmit: [01]10179311000=[03] Receive: [01]20179321157>[02]0000006880140000000000000000000000000000000000688014000000 000000006880140000000000000000000040000000004000000000400000000040000000000000 000000000000000000[03][00] Transmit: [01]10179312000>[03] Receive: [01]20179331157?[02]0000006880140000000000000000000000000000000000688014000000 000000006880140000000000000000000040000000004000000000400000000040000000000000 000000000000000000[03][00] Transmit: [01]10179313000?[03] Receive: [01]201793411578[02]0000006880140000000000000000000000000000000000688014000000 000000006880140000000000000000000040000000004000000000400000000040000000000000 000000000000000000[03][00] Transmit: [01]101793140008[03] Receive: [01]201793511579[02]0000006880140000000000000000000000000000000000688014000000 000000006880140000000000000000000040000000004000000000400000000040000000000000 000000000000000000[03][00] Transmit: [01]101793150009[03] Receive: [01]001793611578[02]0000006880140000000000000000000000000000000000688014000000 000000006880140000000000000000000040000000004000000000400000000040000000000000 000000000000000000[03][00] Message: reading of spontaneous buffer not ordered Message: Periodic Buffer: Start: 2018-06-29 13:15:00 End: 2018-06-29 16:10:00 Periods: 36 Dec: 8 Points: 15 bytes collected: 5564 estimated: 5564 Message: amount of bytes collected ok, data accepted Message: 11 ended at: 2018-06-29 16:20:46 #### Receive: [01]201793511579[02]0000006880140000000000000000000000000000000000688014000000 000000006880140000000000000000000040000000004000000000400000000040000000000000 000000000000000000[03][00] #old 01 32 30 31...........30 03 00 #newstring has only oneline, is allmade of hex string and no [] #### my $start_str = "Receive"; my $end_str ="\n"; my @first_loop = grep { /$start_str/../^$end_str$/ ? 1 : 0; } @logs; my @second_loop; my $data = ""; my $k = 0;my $j=0; for(@first_loop){ #first loop is to remove return, head and tail do { $k = 1, next } if $_ =~ /$start_str/; do { $k = 0; push @second_loop, $data; $data = ""; next;} if $_ =~ /^$end_str$/; do { $sctm_data .= $_; chomp $sctm_data; next } if $k == 1; } my @strings; my $refined_logs; my $hex_str; for(@second_loop){ # second loop is to convert and remove [] my $data_str = $_; chomp $data_str; for(split(//, $data_str)) { do { $j = 1, next } if $_ =~ /\[/; do { $j = 0;push @strings, $hex_str; $hex_str = ""; next;} if $_ =~ /\]/; do { $hex_str .= $_; next } if $k == 1; push @strings, sprintf("%02X", ord($_)); } my $last_str = join( " ", @strings ); @strings =(); push @refined_logs, $last_str; }