my $str = 'dfsldjf(djfls)jfslfk kfds\nfjsldf';
output: dfsldjf_djfls_jfslfk_kfds fjsldf
| [reply] |
Did you really mean to include a newline character (single quotes prevent interpolation)?
use warnings;
use strict;
my $str = 'dfsldjf(djfls)jfslfk kfds\nfjsldf';
$str =~ s/[\s()]/_/g;
$str =~ s/\\n/ /g;
print "$str\n";
__END__
dfsldjf_djfls_jfslfk_kfds fjsldf
| [reply] [d/l] |
well I have a file a lines and there is \n between lines. In order to send an example of what I have in one string, I included \n in the string. Otherwise, it's like
HeadeRdfsldjf(djfls)jfslfk kfd
lfjslfjsflk
dkflskfs
HeadeRRdfsldjf(djfls)jfslfk kfd
lfjslfjsflk
dkflskfs
in the header line, ()\s should be replaced by _, \n at the end should be replaced by \s, on the following lines without Header, \n should be removed except the last one so that it won't be concatenated with the next header line:
HeadeRdfsldjf_djfls_jfslfk_kfd lfjslfjsflkdkflskfs
HeadeRdfsldjf_djfls_jfslfk_kfd lfjslfjsflkdkflskfs
=~ s/\\n/ /g; doesn't work for me. I don't get space instead of \n.
| [reply] |
| [reply] |