in reply to match a word in an words' array
Hashes are almost always the proper way to implement a set.sub addfor{ my ($mainwidget,$entryVariable) = @_; my %history; if (exists $history{$entryVariable}) { $mainwidget->messageBox (-icon => 'error', -type => 'OK', -title => 'Error for input', -message => "duplicate input"); } else { $widget{'forwardlistbox'}->insert ('end', $entryVariable); $history{$entryVariable} = 1; } }
(Also, 'use strict;'! You've got some phantom variables floating around. I'm not sure whether $widget is the same as $mainwidget or not, and @history was unscoped.)
|
|---|