On Fri, 18 Feb 2005, Jeremy Mates wrote:

> * Christopher L. Filkins <[EMAIL PROTECTED]>
> > I'm looking for the perl equivalent of a heredoc declaration.  For some
> > reason I can't recall how.  In php it would work like this:
> 
> my $foo = <<EOD;
> 
>  Stuff stuff stuff
> 
> EOD

I've never quite understood the appeal of this construct, except among 
Perl-hackers-that-are-reformed-Shell-hackers.

Isn't something like this much clearer & easier?

  my $foo = qq[

  Stuff stuff stuff

  ];

  my $bar = q{

  Thingy thingy thingy! [Really!]

  };

  print qq(

  So first foo said "$foo"

  And then bar said: $bar

  );

Doesn't that look so much easier than heredoc syntax? You can pick 
whatever quot delimiters work best for the output of the moment, you 
don't have to keep track of the fiddly <<TOKEN; syntax, you don't get 
tripped up if the closing quote has *gasp* proper indentation, etc.

Heredocs have a place, sure, but AFAIK it's a very small, dark one.

YMMV.

 

-- 
Chris Devers

Reply via email to