Re: simple question



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
.



Relevant Pages

  • simple question
    ... 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. ...
    (perl.beginners)
  • Re: Using C# to insert blob into Oracle
    ... > How do I convert a C# string into a byte array? ... >> The provider for Oracle should represent the field as a byte array. ... > You>> should be able to assign a new byte array to this field in a data set,>> and ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using C# to insert blob into Oracle
    ... ways to convert text to a byte array. ... >> It depends on the format of the string. ... >>>> should be able to assign a new byte array to this field in a data set, ... >>>>>I have setup an Oracle table which contains a blob field. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using C# to insert blob into Oracle
    ... How do I convert a C# string into a byte array? ... > The provider for Oracle should represent the field as a byte array. ... > should be able to assign a new byte array to this field in a data set, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: simple question
    ... i have turned the data set into an array and based on the message spec, i can identify the stock symbols. ...
    (perl.beginners)