for (@ID,@ISIN,@SYMBOL, "\n",) { print "$_:"; } ... #### #!/usr/bin/perl use 5.014; sub getValue { my ($value, $name); # $name is a throwaway; why? $_ = shift; ( $name, $value ) = split(/:/); $value =~ s/\s//g; return $value; } print "ID SYMBOL ISIN\n"; while () { my ($ID,$ISIN,$SYMBOL); if ($_ =~ m/ID:/) { $ID = getValue($_); $ID = $ID . ":"; # append colon removed by split chomp $ID; print $ID; } elsif ($_ =~ m/Symbol:/) { $SYMBOL = getValue($_); chomp $SYMBOL; $SYMBOL .= ":"; # alternate method to append colon print $SYMBOL; } elsif ($_ =~ m/ISIN:/) { $ISIN = getValue($_); chomp $ISIN; print $ISIN ."\n"; } else { next; } } __DATA__ Deleted; see careless OP's request in node below and, as msgd to me: "Sorry for bothering you sir. But could you please change the data on node : http://www. perlmonks.org/? displaytype= displaycode; node_id=976512 to : http://www. perlmonks.org/? displaytype= displaycode; node_id=991009 , appreciate it! !prod data" #### ID SYMBOL ISIN QYQ:LUP2L100OHM:SE0004017929 R1M:TLS2K50OHM:SE0004018539 QNF:MINILONGOMXAO:SE0003990183 QX8:ALF2K160OHM:SE0004017440 NC0:BOL2K170OHM:SE0003842137 NEV:NOK2K90OHM:SE0003843069