open my $fh, '<', $file or die "Can't open $file: $!"; while (my $line=<$fh>) { chomp $line; for($line) { s/\&//g; #s/[\\\_\@\_]//g; s/COMMENT//g; } my @data = split /:/, $line; my $class = $data[0] ? 'normal' : 'bold'; print $fh_out qq[]; my $check=0; my $dolink=$data[0] !~ m/[\=\%]/; for my $word(@data){ $check++; print $fh_out ''; if($check==1 && $dolink ) { $word=~s/("\S+|\S+|")\s*/$1/g; print $fh_out qq[$word]; } else { print $fh_out $word;} print $fh_out ''; } }