#!usr/bin/perl open (FILE1, "output_log.txt") or die "cant write into the file"; while () { if($_ =~ (/(^\=\>\s+)(0x[0-9a-f]+){1,10}(.*)/)) { $value1= $2; print FILE2 $value1."=inst1 \n"; } elsif($_ =~ (/(^\s+)(0x[0-9a-f]+){1,10}(.*)/)) { $value2=$2; print FILE2 $value2."=inst2 \n"; } } close (FILE1); close (FILE2);