in reply to opening a file destroys nulling entries in a list?!?!
orscrewed $_;
I use AS 5.6.1screwed "$_";
is generally frowned upon - map returns a list, and by not having map on the RHS of an assignmentmap {function($_)} @array;
, that list is considered being used in a void context. This means, in this case, all the hard work of creating a list of results via the map is wasted, the list is thrown away. Because screwed() doesn't explicitly return a value, it defaults to using the return value of the close() statement at the end of the sub. If you really dont care about the return values of applying a function using the elements of an array as parameters, it is 'better'(tm) to use this idiom@result_set = map {function($_)} @array
This makes it clear that the function has side-effects - that is, the function uses and possibly changes some variable outside its scope- in screwed()'s case, STDOUT is used.foreach (@array) {sub_without_meaningful_return($_)}
|
|---|