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

I know that this is probably very easy and the answer is probably staring me in the face but say I have
$a = "this"; $b = "is"; $c = "a"; $d = "sentence";
and I want to make one string that looks like

this|is&a|sentence

so that I have one $sentenceString that equals the above I want the pipes and "&" symbols in the string as well because that is the format of the database file I need to test against
been searching everywhere but to no avail... syntax is not my friend... yet.. thanks in advance -redpaw

Replies are listed 'Best First'.
(chromatic) Re: making a new string out of many old ones
by chromatic (Archbishop) on Jul 14, 2000 at 02:03 UTC
    For the sake of completeness, there's a concatenation operator -- the noble period.
    my $first = "This is the whole "; my $second = "of the sentence."; my $full = $first . $second;
    But using double-quotish interpolation is definitely the way to go here.
Re: making a new string out of many old ones
by plaid (Chaplain) on Jul 14, 2000 at 01:41 UTC
    Maybe i don't understand your question.. what won't work about
    $sentence = "$a|$b&$c|$d";
      well it seems to not work in CGI land .... I get a server error every time I try that
        Ok I goofed... this was an unfortunately annoying little problem which was a combonation of 3 different errors which I just figured out all at once...
        the double quotes work fine thanks for the extremely quick replies all !!! -REDPAW
Re: making a new string out of many old ones
by infoninja (Friar) on Jul 14, 2000 at 01:42 UTC
    One way:
    $sentenceString = "$a|$b&$c|$d";