use String::Escape qw(unbackslash); if(open(my $fh,"<","template_file")) { while(<$fh>) { next if(/^$/ || /^#/); chomp $_; $bu=unbackslash($_); print("$bu\n"); } close($fh); }