good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I've been trying to wrap my head around map. I think I was going about it all wrong, trying examples and such just to see how it worked. It was probably to complicated for me, so I gave up and tried to play with grep for a while. It was a lot easier to understand. So now back with map, I've got a function that calculates a running total. My first thought was
map {$n[$#n+1]=($count+=$_)} <DATA>; but then I realized that map was returning a list anyway, so I probably didn't need @n at all. I came up with @n=map {$count+=$_} <DATA>; Is this a good way to do it? Also, I was wondering if you could do it with grep? I don't know why you'd want to, but it seems to me like you should be able to. outputs this which is what I was aiming for. In reply to playing with map by coolmichael
|
|