Click here to get back home

tricky use of print?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
tricky use of print? Ela 04-02-2008
Get Chitika Premium
Posted by szr on April 2, 2008, 5:28 pm
Please log in for more thread options
David Filmer wrote:
> Ela wrote:
>>> Or a heredoc :-)
>>>
>>> print <<_EOF_;
>>> $foo $bar
>>> _EOF_
>>>
>>
>> There are too few words in your example and I'm unable to
>> follow/Google. I guess maybe you are telling something important? thx
>
> szr is just showing you an example of how to use a heredoc, which
> recognizes the \n at the end of any lines within it (so it's just
> another way of printing newlines).

I should of also said, you can either physically have new lines, like:

print <<_EOF_;
A
B
C
_EOF_


Or you can use \n instead:

print <<_EOF_;
A\nB\nC
_EOF_


Or mix and match:

print <<_EOF_;
A
B\nC
_EOF_


Either way you get:

$ perl -e 'print <<_EOF_;
> A
> B\nC
> _EOF_'
A
B
C

--
szr



Posted by Tad J McClellan on April 2, 2008, 7:09 pm
Please log in for more thread options
>> Or a heredoc :-)
>>
>> print <<_EOF_;
>> $foo $bar
>> _EOF_
>>
>> --
>> szr
>>
>
> There are too few words in your example and I'm unable to follow/Google. I
> guess maybe you are telling something important? thx


See the "<<EOF" section in perlop.pod.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Similar ThreadsPosted
Tricky Merge task in Perl - Pls help June 5, 2005, 3:41 pm
Coderefs in objects: tricky questions September 26, 2005, 2:18 pm
Tricky regex (exclude some multiple characters) July 27, 2006, 4:44 pm
(",) Print This! Press [Ctrl][P] Keys To Print... >> http://www.phpbbserver.com/phpbb/viewtopic.php?t=2&mforum=anysubjectchat < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < May 30, 2005, 2:05 pm
Tricky subclassing problem: Parent class method uses static value from child class September 26, 2006, 4:45 am
* * * Please Read And/Or Print This! * * * Press [Ctrl][P] Keys On Your Keyboard To Print >> June 1, 2004 8:24:38 pm >> http://115639.aceboard.net/forum2.php?rub=158&cat=61&login=115639&page=0#id96 << * * * * * * * * * * * * * * * * * * * * * * * * * * * June 1, 2005, 6:24 pm
print @ versus print @ September 25, 2005, 9:53 pm
difference between print < August 16, 2006, 1:16 pm
CGI: print $x =~ s/\n/
\n/g;
July 9, 2004, 9:46 pm
why not print $A[0] November 5, 2004, 6:28 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap