in reply to There are a million ways to quote. How can you determine the best/safest?

You forgot to mention heredocs! =)

My (personal and improvised) formula is:

qw is a special case of q which automatically splits on whitespaces.

Regexes and system-calls are different beasts, but rules are similar, cause they operate on interpreted strings as input. (NB s/// and m// allow other delimiters, too!)

quotemeta is very good if you can't control an "injected" string in an "interpreted" context like in a regex or with string-eval

As you can see it's mainly a compromise between readability, maintainability and avoiding delimiter-problems.

YMMV, readability is often a matter of taste.

It also depends on number of collaborators, performance, scalability, the expected future of the project, and so on...

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: There are a million ways to quote. How can you determine the best/safest?
by taint (Chaplain) on Nov 16, 2013 at 21:32 UTC
    "You forgot to mention heredocs! =)"

    D'OH! You got me. Thanks for not penalizing me on that. I guess embarrassment could probably be considered punishment enough. :)
    I'll update the OP

    Thanks LanX. That's a good flow of logical deduction, ya got there.

    --Chris

    #!/usr/bin/perl -Tw
    use Perl::Always or die;
    my $perl_version = (5.12.5);
    print $perl_version;