Part of the specification reads: βSome names are special, such as Hughie, Dewey, Louis and Donald. Other names can be added throughout the projectβs life cycle at any time. Whenever you enter one of these names, play quackery. WAV ".
I could write ...
while (<>) { if ($_ =~ /Hughie|Dewey|Louis/) { quack() ; } elsif ($_ =~ /Donald/ { quack() ; you_re_fired_apprentice() ;
... but although not recommended, it looks like WTF-y: where is the binary search? What if there were a sudden huge increase in the number of duck names? It will not scale at all!
I can create empty files using these names in a temporary directory and then use the "file exists" API, but that seems cool, and I had to be sure that they were deleted at the end.
Of course, is there a better way?
Thomas l holaday
source share