So...
would set $p_str to one,two,three@array = qw(one two three); $p_str=join ",",@array;
But, your sample code has an extra little something... the list of items is ('?')x@array.
The x after a string ('?' in this case) is an operator that says, repeat this string x number of times, where x is the number following it.
So what is x? It is @array, and since this is in scalar context (Perl knows that it is supposed to supply a number not a list), @array returns the number of elements within the array.
so...
sets $p_str to '???'@array = qw(one two three); $p_str = '?'x@array;
Finally,
is equivalent to...@array = qw(one two three); $p_str = join ",",'?'x@array;
which simply joins the items ??? (note that there is only one item) together with commas.@array = qw(one two three); $p_str = join ",","???";
Since there is only one item, there is no comma, and the final result is:
???
In reply to Re: Code Explanation
by Sandy
in thread Code Explanation
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |