Alex Goor wrote:
i have a data set of stock orders and i want to count the number of unique
stock symbols in the set.
i have turned the data set into an array and based on the message spec, i
can identify the stock symbols. but i don't know how to make sure i'm only
counting unique ones.
Use a hash. Hash keys are always unique.
i had thought to do an if statement along the lines of
$symbolset = "@symbolset";
if $symbolset !~ /substr($message,17,6)/ #if the array doesn't contain
^^^^^^^
You can't execute a function inside a string.
perldoc -q "How do I expand function calls in a string"
the new symbol
{
#then add it to the array
push (@symbolset, "substr($message,17,6)
}
my %symbolset;
# more code here
# increment count of unique data
$symbolset{ substr $message, 17, 6 }++;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/