Re: how to remove the letter n from a line of text



Jürgen Exner wrote:
pauls <pauls@xxxxxxxxxx> wrote:
I want to replace all occurances of the letter n in a line of text.
The confusion I am having is due to the fact that n denotes a new line in reg expressions.

No, it doesn't. "\n" denotes a newline when interpolated in a double quoted
string.

I tried to do this:
s/n/fred/; to replace the letter n with fred. But, it did not happen.

Works for me

use strict; use warnings;
$_ = 'banana';
s/n/fred/g;
print;

C:\tmp>t.pl
bafredafreda

jue

Let me be more clear and correct myself:
What I was actually trying was this:

$my_variable =~ s/n/e-9/;

where the variable $my_variable has this in it: 3.5n


and I was hoping to change it to:

3.5e-9


when I read-in the data and do the following (below) on $_

s/n/e-9/;

it works!

But if I do it like this:

$my_variable =~ s/n/e-9/;

The n is removed but not replaced by the e-9


Thanks

P.


.



Relevant Pages