homepage Welcome to WebmasterWorld Guest from 54.166.123.2
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Multi line string assignment
Can strings span multiple lines?
Fotiman




msg:4263870
 8:41 pm on Feb 7, 2011 (gmt 0)

Can you do the following with Perl?

$myValue = "Blah blah blah
blah blah blah";

(notice the line break)

If not, will this work:

$myValue = qq|Blah blah blah
blah blah blah|;

 

janharders




msg:4263889
 9:05 pm on Feb 7, 2011 (gmt 0)


Can you do the following with Perl?

$myValue = "Blah blah blah
blah blah blah";


yes.

If not, will this work:

$myValue = qq|Blah blah blah
blah blah blah|;


of course. there's more than one way to do it!

Fotiman




msg:4263921
 9:37 pm on Feb 7, 2011 (gmt 0)

Ok, I thought so, but was having a hard time finding a resource that said so explicitly. :) Thanks.

rocknbil




msg:4264236
 5:09 pm on Feb 8, 2011 (gmt 0)

qq is one of the cool things about Perl that you don't have, for whatever reason, in PHP. You can do

$var = qq|
This is $some_day and that
lands on a $weekdays{$some_day}.
|;

But in PHP, you have concatenate array variables, which makes it a little harder to debug and maintain.

$var = "
This is $some_day and that
lands on a " . $weekdays[$some_day] . "."
;

This is also why you see so many single quoted HTML attributes, which I abhor. I don't know why, they're perfectly valid. I just do. :-)

$var = "
here is the link
to <a href='$url'>your site."
;

Ahh. :-)

$var = "
here is the link
to <a href=\"$url\">your site."
;

It does have HEREDOCS, but it's a bit messy.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved