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

Re: Qouting and white-space etc..

Thread Previous
From:
Michael G Schwern
Date:
August 16, 2001 14:28
Subject:
Re: Qouting and white-space etc..
Message ID:
20010816172810.F728@blackrider
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 ...one example..
> 
> 
> my $javascripCode = qq{
>     |<script>
>     |    function blah()
> 
>     |        if ( ) ....
>     |    };
>     |</script>
> };

I believe Larry said this idea is in:

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

                if ( ) ...
            };
        </script>
        CODE

(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 );
        ...stuff...
        CODE

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

-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About