in reply to RE: Writing the contents of an array to a file
in thread Writing the contents of an array to a file
Passing arguments to a function (even internal) as an array is just like passing a list of your own individual arguments. In this case, however, each element will be printed one after another. If you want to separate with spaces, either set $, or use join as you've done.@a = (1, 2, 3); print @a; print $a[0], $a[1], $a[2]; # equivalent to @a
If you're working from a list generated from a file, though, as we are here, newlines are still at the end of each element in the list, so printing them out like he's doing will have the desired effect:
@list = <INPUT_FILE>; print OUTPUT_FILE @list; # exact (textual) copy
|
|---|