|Keep It Simple, Stupid|
Re: I'm so confusedby davorg (Chancellor)
|on Nov 24, 2001 at 14:22 UTC||Need Help??|
You values are being stored in the array exactly how you want them. The problem you are seeing comes simply in the output stage.
When you print out an array using code like:
All the elements in the array are printed out with nothing between them. You can change this default behaviour by changing the value in $,. Perl prints the value of this variable inbetween the elements of an array. For example:
This prints the array elements separated with colons. Notice that I've localised the change to $, by putting it in a naked block. This is good practice for whenever you change the value of one of Perl's special variables.
Another technique you could use is to print the array in a double quoted dtring like this:
In this case, the default is to print the values separated by spaces. Once again this behaviour can be changed. In this case you need to chages the value of the $" variable, like this:
In this case, the elements of @out will be separated by newline characters.--
"The first rule of Perl club is you don't talk about Perl club."