Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
This idea will certainly work!
I personally try to avoid using undef as an intentional value because: We are getting a bit off topic, but this is a hash slice. To get this work with the =1 idea, I think something like the below is required. There isn't foreach, but there is still a loop (except in the enumerated first case). I personally like the $hr->{$_} = 1; syntax because it makes clear that we are de-referencing a hash reference. A short thing about hash slice is at hash slice. My foreach loop can be replaced with this.. Oh, the map{1} generates an "@something" that has the same number of "1's" as there are elements in the input @$arr although here it is "anon", having no explicit name. Here that output of the map is used (ie, it is not a "bare" map). In this case, there is still a loop and we've just made the situation more confusing. Clarity of code is important and just because some implementation uses fewer lines doesn't mean that it is faster. In reply to Re^3: Possible useless use of map
by Marshall
|
|