Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

How to use * operator in JOIN

by ravi45722 (Pilgrim)
on Jul 31, 2015 at 09:00 UTC ( [id://1136985]=perlquestion: print w/replies, xml ) Need Help??

ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:

my $placeholders = join(',',('?') * 8);

I need an output of ?,?,?,?,?,?,?,? But its returning zero. I dont know where i mistaken. Plz correct it

Replies are listed 'Best First'.
Re: How to use * operator in JOIN
by Laurent_R (Canon) on Jul 31, 2015 at 09:11 UTC
    I guess that you mean:
    $placeholders = join(',',('?') x 8);
Re: How to use * operator in JOIN
by johngg (Canon) on Jul 31, 2015 at 09:12 UTC

    Use x, not *!

    $ perl -E 'say join q{,}, ( q{?} ) x 8' ?,?,?,?,?,?,?,? $

    Cheers,

    JohnGG

Re: How to use * operator in JOIN
by kennethk (Abbot) on Jul 31, 2015 at 14:39 UTC
    What Laurent_R and johngg said. For documentation of the repetition operator, see Multiplicative Operators.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1136985]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-24 21:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found