A piece of historical Perl code I have has the following function:
sub binds { join(",", ("?")x$_[0]) }
It is later called with binds(4) or the like. From what I can tell it is joining ?s and ,s but I’m lost as to exactly how, nor do I understand the x$_[0] part.
This function takes an integer (let’s say
n) as its first argument and returns a string ofnquestion marks separated by commas. Here’s how it breaks down:It’s probably a utility function for a database interface to create the specified number of
?place holders which will be later bound to some specific values as part of an SQL statement.