in reply to Concatenate printing a string and array

Was that on purpose or a typo that you have a period (.) instead of a comma (,) between the string and your @array ?

If the former, you should read up about context. The concatenation operator (.) joins two scalars, so the array is in scalar context (i.e. the concatenation needs a scalar, so the array provides a scalar). An array provides its size in scalar context, in this case 4

The parameters of a print on the other hand (with the possible exception of the optional filehandle parameter) provide list context which is why a comma works

  • Comment on Re: Concatenate printing a string and array

Replies are listed 'Best First'.
Re^2: Concatenate printing a string and array
by shawnhcorey (Friar) on Jan 05, 2009 at 15:36 UTC
    print "The array is ", @array, "\n";
    or
    print( "The array is ", @array, "\n");
Re^2: Concatenate printing a string and array
by shawnhcorey (Friar) on Jan 05, 2009 at 15:35 UTC
    print "The array is ", @array, "\n"; or print( "The array is ", @array, "\n");