Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

printing a single quote in a string when using -e option

by yossarian (Novice)
on Jul 24, 2003 at 06:41 UTC ( [id://277449]=perlquestion: print w/replies, xml ) Need Help??

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

Nameste monks,
Here is newbie question that I am hoping a more enlightened monk can provide some guidance on: What are some ways that a single quote can be printed as part of a string using the print function when using the -e option.  print " \' " works as I want it to when part of a .pl file, but  perl -e 'print "\'"' and any variants that I have come up with so far don't and I'm unsure of the way to get around this. thanks.

Replies are listed 'Best First'.
Re: printing a single quote in a string when using -e option
by yossarian (Novice) on Jul 24, 2003 at 07:30 UTC
    Thanks. I received several helpful answers, all of them different, but all of them valid. Here's a listing of the various ways if anyone is interested:
     perl -e "print '\''"
     perl -e'print "\047"'
     perl -e "print q{'}"
    Also, I'm now aware that there is a section related to quoting in perldoc perlop.
    Thanks - yossarian.
Re: printing a single quote in a string when using -e option
by moxliukas (Curate) on Jul 24, 2003 at 06:48 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://277449]
Approved by gmax
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found