Re: replacing this backlash (\) with no backlash
From: Anno Siegel (anno4000_at_lublin.zrz.tu-berlin.de)
Date: 02/24/04
- Next message: Peter Scott: "Re: Perl Socket question"
- Previous message: Reinhard Pagitsch: "Re: DBI object in modules"
- In reply to: Devop: "replacing this backlash (\) with no backlash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 24 Feb 2004 15:50:24 GMT
Devop <as@hotmail.com> wrote in comp.lang.perl.misc:
> -=-=-=-=-=-
>
> hi.
>
> I have been replacing string with backslas (\) with an other without
> backlash.
>
> This is part of the code
> The reason i use \ in front of $ is that , $ is included in my search.
>
> But when i replaced with the second variable, i get \${string2} - i
> love you & (see the backlash is with me again ? how can i ignore this
> backlash? . I want to get just {string2} - i love you &
>
> my $first = '\${string1} &';
^
That backslash has no function in single quotes, it is included literally
in your string. Print out "$first" before the substitution to see it.
> my $second = '\${string2} - i love you &';
Since your substitution does nothing about a literal backslash, it stays in.
You don't want to "ignore" the backslash, you don't want to put it in the
original string in the first place.
my $first ='${string1} &';
Anno
- Next message: Peter Scott: "Re: Perl Socket question"
- Previous message: Reinhard Pagitsch: "Re: DBI object in modules"
- In reply to: Devop: "replacing this backlash (\) with no backlash"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|