SPUG: Re: Filter::Simple by J.P. tomorrow too

Tim Maher tim at consultix-inc.com
Tue Apr 16 10:15:56 CDT 2002


On Tue, Apr 16, 2002 at 07:40:03AM -0700, Richard Anderson wrote:
> What's wrong with this (paraphrased from my memory of the Camel book section
> on here docs, may not have the syntax right):
> 
> ($test = <<END ) =~ s/^\s+//;
>                  This is
>                   my indented
>                   here document.
> END
> 
> Cheers,
> Richard
> richard at richard-anderson.org
> www.richard-anderson.org
> www.raycosoft.com

You have to fudge the "Framing Word" to include the quotes too, and
add /gm:

($test = <<'    END' ) =~ s/^\s+//gm;
	 This is
	 my indented
	 here document.
	END
print "$test";

What's wrong is that this is a kludge imposed as a burden on the user
to simulate a convenient feature provided by the modern UNIX shells.

Sure, you can write the hideous code shown above , but I think most
would agree that it would be nicer to have Perl handle this itself.
Because it doesn't (currently), patching the language through Source
Filtering is a way to get that funtionality.

My guess is that this has been a sufficient annoyance to JP that he
seized the opportunity to use this as a test case for explorations in
the world of Source Filtering (the excuses of needing Klingon and Latin
functionality were already taken) 8-}

-Tim
*==============================================================================*
|  Dr. Tim Maher, CEO, Consultix          (206) 781-UNIX/8649;  ask for FAX#   |
|  tim at consultix-inc.com   teachmeperl.com  teachmeunix.com  teachmelinux.net  |
| APR: Shell; Int/OO Perl; Perl DataBase;  JUNE: Basic UNIX, Perl  JULY: Perl  |
*------------------------------------------------------------------------------*
| NEW Seminar Series!  "DAMIAN CONWAY's Adv. Perl Workshop"; Seattle, 7/15-18  |
| Adv. OOP  *  Adv. Module Implementation Techniques  *  Programming in Perl 6 |
*==============================================================================*

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list