develooper Front page | perl.perl6.language | Postings from August 2001

Re: Qouting and white-space etc..

Thread Previous
Michael G Schwern
August 16, 2001 14:28
Re: Qouting and white-space etc..
Message ID:
On Wed, Aug 15, 2001 at 12:36:24PM +0300, raptor wrote:
> I was wondering if there was some way when using qouting to specify triming
> of white space or other type of charachters we may need ... say like TT or
> may be example..
> my $javascripCode = qq{
>     |<script>
>     |    function blah()
>     |        if ( ) ....
>     |    };
>     |</script>
> };

I believe Larry said this idea is in:

    my $javascriptCode = <<CODE;
            function blah()

                if ( ) ...

(Your example faithfully preserved.)

The indentation of the CODE terminator is how much whitespace is
stripped from each line of the here-doc string.

> and I want to have some syntax so I can specify that First and Last "\n" be
> removed,

Here-docs have no leading newline, so that's not a problem.  And it's
fairly trivial to just chomp().  In fact, you can do this:

    chomp( my $code = <<CODE );

Trying to wedge some sort of special syntax into here-docs to do this
probably isn't worth the trouble.


Michael G. Schwern   <>
Perl6 Quality Assurance     <>	     Kwalitee Is Job One
Now people age and die, that's why people want children because children is
supposed to take care elders when they grow up. But in future, people don't
age. Then children become hindrance instead of liking. Then people will stop
having children.
	     --Alex Chiu, Immortality Guy

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About