Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use the dollar sign without it being used as a command

Status
Not open for further replies.

chuckID

Technical User
Oct 1, 2002
8
US
Hi,

I need to use a dollar sign in my string but obviously the system thinks it's a command operand. Can this be accomplished? I would like to use the $ symbol rather than saying "197 dollars". Notice the second $ sign...

$message = qq(Enter our Contest to Win a FREE Internet Marketing Course, a $197 value!);

The output is: "Enter our Contest to Win a FREE Internet Marketing Course, a value!" ...Notice the price is missing.

Thank you,
chuck
 
In order to prevent perl from interpreting a character as a command operand just put a \ in front of it. Writing \$ should result in the $ just being treated as ordinary text.
 
Putting a \ in front of other charachters also applys. For example, " ' @ etc....all depends on how they are called. For example;

$var = "some stuff \"\" here";

but escaping is not needed if using something like;

$var = 'some stuff "" here';

Same as @'s.

$something = "me \@ somewhere.com";

and

$something = qq|me \@ somewhere.com|;

but the following will not need escaping;

$something = 'me @ somewhere.com';

Basically, using ' will stop anything being read as code (works great when priting @'s or $'s.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top