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:
print @out;
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:
{
local $, = ':';
print @out;
}
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:
print "@out";
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:
{
local $" = "\n";
print "@out";
}
In this case, the elements of @out will be separated by
newline characters.
--
<http://www.dave.org.uk>
"The first rule of Perl club is you don't talk about
Perl club."
|