in reply to Rewrite in a more compact way

my $str = q{CALL DB_PROC_FOO(} . join(',', ('?') x $n) . ')';

(assuming that you don't care if $n is zero afterwards)

Replies are listed 'Best First'.
Re^2: Rewrite in a more compact way
by Bloodnok (Vicar) on Nov 27, 2008 at 12:10 UTC
    Hi moritz ,

    In the interests of consistency, methinx your snippet should have read

    my $str = 'CALL DB_PROC_FOO(' . join(',', ('?') x $n) . ')';

    ;-)

    A user level that continues to overstate my experience :-))
      Since andreas1234567 asked for a compact way, I also used a compact way to quote strings.

      I know that PBP encourages q{..} and discourages '...' on "noisy" strings, but it's one of the things I don't like visually. (I do resort to other quoting constructs if it saves me backslashes for escaping, which are usually a bit confusing).

      Note that your version also isn't consequent, because it still uses ',' instead of q{,}.

        FWIW, I systematically use q{} for SQL strings. It's the best I've come to that doesn't require backslashing or later changing the quotes to something else.