Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Ways of quoting

by davido (Cardinal)
on May 15, 2020 at 21:22 UTC ( #11116826=note: print w/replies, xml ) Need Help??

in reply to Ways of quoting

I have to admit, I hate the idea of the trailing ::.

If you're enumerating the ways to quote things in Perl, don't forget HERE docs:

<<HERE # Double quoted <<"HERE" # Double quoted, explicit. <<'HERE' # Single quoted, explicit. <<\HERE # Single quoted, uncommonly used. <<`HERE` # Same as qx or ``. <<~HERE # Double quoted, indented. <<~"HERE" # Double quoted, indented. <<~'HERE' # Single quoted, indented. <<~\HERE # Single quoted, indented, uncommonly used (I'll b +et you could grep all of CPAN and not find this). <<~`HERE` # Same as qx / ``, indented.

Which made me think, too bad we don't have:

<<~/HERE/x # Regexp object, indented, multi-line freeform (/ +x modifier).


Replies are listed 'Best First'.
Re^2: Ways of quoting
by haukex (Bishop) on May 15, 2020 at 21:31 UTC
    too bad we don't have: <<~/HERE/x
    my $re = qr/@{[<<'HERE']}/x; f . . HERE

    Close enough? ;-)

      Good enough for an upvote. I tend to shun the "@{[...]}" trick in real code, but this is a creative enough solution it made me smile.


        ... and commonly referred to as the baby cart.

        (As a speaker of en_GB that's not a term in our common usage. You are more likely to hear "buggy" or "pram". IMHO this makes the "baby cart" term even more preferable since it has a unique meaning for me - it's only the perl operator, regardless of context.)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11116826]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2021-09-17 10:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found