Hey qball,
Where in your example are you trying to use a hash?
Now here are some tips you might want to follow:
- Use the -w switch and use strict.
- You probably don't want to put you file in an array. There's no real use here and it can be a performance issue if your file is several hundreds MB large. Use the while (<DATA>){} construction instead. The line will be stored in the scalar $_.
- Use the map function when you have to repeat the same operation several time on array elements and get another array back (or use a foreach loop if you don't want a new array).
- Your loop and regex seem to be stripping the commas and whitespaces on the current line. There's more efficient ways to do it (ex: s/(?:\s|,)//g, and/or use a join to print the array back without commas).
- You can save some keystrokes on your split by assiging it directly to an array, and later access the array elements with $array[n], where n is the array index (starting from 0).
- To affect a key in a hash, it's really easy just say $hash{$key}=$value. $value can be just anything, but it has to be something (even undef or '').
By mixing these advices and your current code, you'll probably get the results you want. (I hope so!)
<kbd>--
my $
OeufMayo = new PerlMonger::Paris({http => '
paris.mongueurs.net'});</kbd>