in reply to problems with arrays

To remove the leading whitespace, you will need a regex. Something like this should do:

my $line =~ s/^\s+//;
Which basically tells Perl to strip 1 or more instances of a whiespace from the beginning of the line or string (instructed by the ^).

Looking over your code quickly, I would use the above code to replace the line $line =~ s/\s{1}//g;

Hope this helps.

- wil