saintmike answered your question. But by the way, it looks like you want a data structure you can easily and efficiently use to determine membership of a particular value. In this case, a hash can be useful:
my %sheets;
[...]
# The next three methods are equivalent. Pick whichever you like most.
# 1
if (not exists $sheets{$machine_sheetname}) {
$sheets{$machine_sheetname} = 1; # "1" is just a dummy existenc
+e flag
}
# 2
$sheets{$machine_sheetname} = 1 unless $sheets{$machine_sheetname};
# 3
$sheets{$machine_sheetname} ||= 1;
Then, when you need all the sheets, use this expression:
keys %sheets;
The prime limitation of this approach, however, is that hashes are not sorted. If the order of your sheets matter, this may not be appropriate after all, or, if you do want to use them, you need to use something like Tie::IxHash. |