CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Simple question - How to add comments within a double-quoted string

 



terrykhatri531
User

Sep 7, 2014, 6:23 AM

Post #1 of 3 (2460 views)
Simple question - How to add comments within a double-quoted string Can't Post

Hi,

Just need to know what escape characters to use to add comments within a double-quoted string like :




Code
 
qq!

<!-- open previous media -->
<li><a href='index_playlistRightOutside.html#' onClick="gallery1.previousItem(); return false;">previous media</a></li>

<!-- Open media, pass number (counting starts from 0), or data-address as string (for deeplink). -->
<li><a href='index_playlistRightOutside.html#' onClick="gallery1.loadItem(2); return false;">Open media number 2</a></li>
<li><a href='index_playlistRightOutside.html#' onClick="gallery1.loadItem('image5'); return false;">Open media 'image5'</a></li>

<!-- Open new category, pass number (counting starts from 0), or data-address as string (for deeplink).
This will open first image in category. -->

<li><a href='index_playlistRightOutside.html#' onClick="gallery1.loadCategory(2); return false;">Open category number 2</a></li>
<li><a href='index_playlistRightOutside.html#' onClick="gallery1.loadCategory('wellness_reveal'); return false;">Open category name 'wellness_reveal'</a></li>

!;


Many thanks !!

Terry


Zhris
Enthusiast

Sep 7, 2014, 5:39 PM

Post #2 of 3 (2447 views)
Re: [terrykhatri531] Simple question - How to add comments within a double-quoted string [In reply to] Can't Post

Hi,

Please check the documentation for quote and quote-like operators.

You must escape using a backslash the character that you chose for the deliminator within the string. In your case, the deliminator you chose is !, therefore you must escape all !'s that occur in the string with \!. The compiler assumes that the quote starts at the deliminator then ends when it reaches the next non escaped deliminator.

Alternatives:

- Choose a deliminator that doesn't occur or occurs less often within the string such as ~.

- Use a here-document:

Code
print <<"HEREDOCUMENT"; 
string goes here
HEREDOCUMENT


- Don't mix HTML with Perl. Use a template instead.

Regards,

Chris


(This post was edited by Zhris on Sep 7, 2014, 5:46 PM)


terrykhatri531
User

Sep 8, 2014, 1:41 AM

Post #3 of 3 (2435 views)
Re: [Zhris] Simple question - How to add comments within a double-quoted string [In reply to] Can't Post

Many thanks Chris !!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives