Next | Program Repair Shop | 97 |
(my $copy_target_node) = $dst_file; $copy_target_node=~s/\//\\/g; (my $copy_source_node) = $src_file; $copy_source_node=~s/\//\\/g;
Here we're trying to replace Unix-ish / with DOS-ish \
This is an example of the dreaded Leaning Toothpick Syndrome
When s///-ing patterns with many slashes, use s{}{} instead:
(my $copy_target_node) = $dst_file; $copy_target_node=~s{/}{\\}g; (my $copy_source_node) = $src_file; $copy_source_node=~s{/}{\\}g;
In this case, however, tr is more appropriate
(my $copy_target_node) = $dst_file; $copy_target_node=~ tr{/}{\\}; (my $copy_source_node) = $src_file; $copy_source_node=~ tr{/}{\\};
Similarly use tr/x//d in place of s/x//g
Next | Copyright © 2002 M. J. Dominus |