http://qs321.pair.com?node_id=1212594

CPTQuesoXI has asked for the wisdom of the Perl Monks concerning the following question:

I am performing a phylogenetic tree from sequence alignments with a software that requires no whitespaces and no brackets/parentheses in the text file. I try to substitute my whitespaces with underscores and my brackets with whitespaces so that the file can be read without problem in the alignment software. My code runs without error warnings, but does not give any output whatsoever.

foreach my $line (<>) { chomp ($line); if ($line =~ m/^>/) { #if line matches ">" at beginnin +g if ($line =~ /\s/g) { #if line matches whitespa +ce globally $line =~ s/\]/\s/; $line =~ s/\[/\s/; $line =~ s/\s /_/g; #substitut +e whitespace with underscore. } } }