Think about Loose Coupling | |
PerlMonks |
Re: How to read zipped file in perlby Eily (Monsignor) |
on Jan 09, 2014 at 09:43 UTC ( [id://1069935]=note: print w/replies, xml ) | Need Help?? |
This works far better than it should, (split /\|/)[4] means that you read values separated by a |, and take the fifth (Edit: not fourth, thanks choroba). Since your values are separated by commas, that's either not your real input or the code you actually used. Do read the documentation on split if you intend to use it. The [4] means "only the fifth value", and join is used to join several values, so in this case, it is useless. For your expected result, you could do something like that : You still have to change something for the split to work, that's because I didn't want you to just copy and paste my code without understanding anything, and because I'm not really sure what you values separator actually is. In the list of variable in the my(), you should rename key1 and key2 to give them meaningful names, and you can replace all the variables you won't use by undef. To have something more useful with Data::Dumper, you should write print Dumper(\%result);, the backslash returns a reference to your hash, which means that instead of using Dumper on each element (key or value) of %result, you'll do it on %result as a whole. There is one thing you do correctly though, and it's reading from a zipped file. So you don't have to ask for that.
In Section
Seekers of Perl Wisdom
|
|