Here is a quick way; # Global declarations open(spooler,"test.html") or die "Can't open file\n"; while($spool=){ $spool; @value=split(/<*>*//g; @val1=split(/ /,$value[$i]); } if($value[$i] =~ /^jtitle>/i) { #$value[$i] =~ s/^jtitle>//ig; $val2[$j]=$value[$i]; $j++; } $i++; } } for($n=0;$n<$j; $n++) { print $val1[$n]." <".$val2[$n]."\n"; }