O
Owen
The Perl Cookbook 6.23 has this "bizarre" (to me) statement;
We have found these regular expressions useful or interesting.
Turning \ followed by n into a real newline
s/\\n/\n/g;
When would a \n not be a \n ? The program below sort of simulates that condition, but presumeably there is something else?
Owen
rcook at pcug org au
#----------------------------------------------------
#!/usr/bin/perl -w
use strict;
my $string ="Now is \n the time";
print "$string\n";
$string ='Now is \n the time';
print "$string\n";
(my $newstring = $string) =~ s/\\n/\n/g;
print "$newstring\n";
Now is
the time
Now is \n the time
Now is
the time
We have found these regular expressions useful or interesting.
Turning \ followed by n into a real newline
s/\\n/\n/g;
When would a \n not be a \n ? The program below sort of simulates that condition, but presumeably there is something else?
Owen
rcook at pcug org au
#----------------------------------------------------
#!/usr/bin/perl -w
use strict;
my $string ="Now is \n the time";
print "$string\n";
$string ='Now is \n the time';
print "$string\n";
(my $newstring = $string) =~ s/\\n/\n/g;
print "$newstring\n";
Now is
the time
Now is \n the time
Now is
the time