Jim Gibson wrote:
Joseph L. Casale:

Inside a here doc, how can I force an expression to be evaluated
such as localtime [...]

You can use the trick mentioned in 'perldoc -q string' "How do I expand
function calls in a string?", referencing, then dereferencing an array, but
it is ugly [...]

What makes you say it "is" ugly?

To me it is just another useful language feature.
But it needs plenty of space. :)


I use $" in here-docs as well:


perl -wle'

    my @id = 1..5;

    my $sql = do {
        local $" = q{,};  #"

        <<"SQL";
SELECT
    id
,   name
FROM
    things
WHERE
    id IN (@id)
SQL
    };

    print $sql;

'


For those that are not familiar with C<$">,
change it in the above code to for example qq{\n,\t}
and see the difference in the output.

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to