pbbruce has asked for the wisdom of the Perl Monks concerning the following question:

I have an variable for example: $dummp = "Phillip "B" Bruce"; How should I get rid of quotes around the "B"?

Replies are listed 'Best First'.
Re: Quotes
by dvergin (Monsignor) on Apr 21, 2001 at 05:20 UTC
    Your presentation of the problem is a bit puzzling because $dummp = "Phillip "B" Bruce"; is not a valid statement... Is this what you are after?
    my $dummp = 'Phillip "B" Bruce'; print $dummp; # prints: Phillip "B" Bruce $dummp =~ s/"//g; print $dummp; # prints: Phillip B Bruce
      That exactly what I thought I typed but I left out the ~ in my assignment statement. Thanks.
        but I left out the ~ in my assignment statement.

        The perlman:perlop defines =~ as a binding operator, not an assignment:
        Binary ``=~'' binds a scalar expression to a pattern match.

        Rudif
Re: Quotes
by Beatnik (Parson) on Apr 21, 2001 at 13:52 UTC
    Valid as well... $dummp = qq/Phillip "B" Bruce/; and $dummp = q/Phillip "B" Bruce/; and ofcourse $dummp = "Phillip \"B\" Bruce";

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
Re: Quotes
by rchiav (Deacon) on Apr 21, 2001 at 05:27 UTC
    could you explain what you mean a little better? Your statement
    $dummp = "Phillip "B" Bruce";

    really isn't a valid Perl statement because "Phillip" and "Bruce" are quoted and the B is not. Perl isn't going to know what you mean by that.

    Does your string have quotes around the B? If so, the above answer will do what you want it to. If not, we're going to need more info.

    -Rich