Re: simple question
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Sun, 27 Apr 2008 09:58:03 -0700
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
.
- References:
- simple question
- From: Alex Goor
- simple question
- Prev by Date: Re: simple question
- Next by Date: Re: simple question
- Previous by thread: Re: simple question
- Next by thread: Re: simple question
- Index(es):
Relevant Pages
|
|