in reply to Re: foreach not working as I expected
in thread foreach not working as I expected

For one-time throw away tasks, maybe. This is expensive code though, particularly if there are tons and tons of files to be appended to. You are spawning shells for each iteration of the loop. These in turn fire off copy (which may or may not be a builtin to your shell) which in turn has to perform the same open, print, close logic your script would do anyway.

Besides, it's not very perlish. {g}

But, on an off topic for those who are saying "don't close your file, let the scope take care of it", please think some about maintainability. Someday a n00b will see your code and not understand how the scope issues work. They'll just think "oh, I guess you don't have to worry about closing things".
{NULE}
--
http://www.nule.org

  • Comment on Re: Re: foreach not working as I expected