Note also that while each pair of lines of code below produce the same output:
they are not equivalent in terms of performance. Only print FILE @array avoids building a potentially huge string in memory before writing. In practice, the speed improvement is usually small (or even negative) but I prefer to allow for huge arrays and avoid the join if I'm just going to write the result to a file and then throw the constructed string away.print FILE "@array"; print FILE join $", @array; print FILE @array; print FILE join $,, @array;
Though I do find appealing the way that using join prevents your code from breaking if you accidentally sneak a scalar context into the mix (typing a "." when you meant a ",", for example).
- tye (but my friends call me "Tye")In reply to (tye)RE: Writing the contents of an array to a file
by tye
in thread Writing the contents of an array to a file
by Limo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |