in reply to How to print the dollar sign.

print '$';
print "\$";.

Ciao, Valerio

Replies are listed 'Best First'.
Re: Re: How to print the dollor sign.
by crenz (Priest) on May 09, 2003 at 09:58 UTC

    As an explanation of why it works:

    1. A string enclosed in '' will not be interpolated (ie. any variable names inside will stay what they are instead of being replaced by the value of the variable).

    2. You can use backslashes to "escape" characters, ie. make them lose their special function.

    Example:

    my $var = "Testing 1 2 3"; my $no_interpolation = 'Var = $var'; # result: Var = $var my $interpolate = "Var = $var" # result: Var = Testing 1 2 3 my $escape = "Get lots of \$\$\$ by pressing Shift+4 many times \%-)"; # result: Get lots of $$$ by pressing Shift+4 many times %-) # (note: this money-making technique is designed for German keyboards +:) )