Re: simple question



run command:
perldoc perldsc


use strict;
use warnings;
are two pragmas, strict will force you to declare variables with my
warnings will produce useful warnings

please see
perldoc -f use


On Sun, Apr 27, 2008 at 11:46 AM, Alex Goor <a_goor@xxxxxxxxx> wrote:

thank you so much for your fast answer.

what do you mean by perldoc perldsc? how do i get that?

what is "use strict" and "use warnings"

sorry to bother you and thanks again!

----- Original Message ----
From: "Li, Jialin" <jialinli1981@xxxxxxxxx>
To: Alex Goor <a_goor@xxxxxxxxx>
Sent: Sunday, April 27, 2008 12:43:47 PM
Subject: Re: simple question

you should use hash, see more detail
perldoc perldsc


use strict;
use warnings;
my %hash_symbol;

while (my $message = <>) {
++$hash_symbol( substr($message,17,6) );
}

my @sybolset = keys %hash_symbol;



On Sun, Apr 27, 2008 at 11:36 AM, Alex Goor <a_goor@xxxxxxxxx> 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.

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
the new symbol
{
#then add it to the array
push (@symbolset, "substr($message,17,6)

}

substr($message,17,6) is the symbol info within each line of the array
of the data set.

the problem is that that doesn't work!

does anyone have any ideas how to do this?


--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/






Relevant Pages

  • Re: debugger exiting
    ... strict and warnings pragmas. ... I think portraying Perl as a command-line tool limits it to fewer platforms than ... work only as a Unix shell command line. ...
    (perl.beginners)
  • Re: reading command line arguments
    ... The code already has parts the read command line arguments, ... If you use strict, as you should, then you'll need to declare $t and $e ... use warnings; ...
    (comp.lang.perl.misc)
  • Re: FetchURL with GIF files
    ... > be able to automate the image download process. ... use strict; ... use warnings; ... (This command should be entered as a single line). ...
    (comp.lang.perl.misc)
  • Re: Help with Net::IP::Match and mod_perl
    ... > I'm having trouble getting this to work ... > use strict; ... > use warnings; ... > running this from command line works fine, ...
    (comp.lang.perl.modules)
  • Re: shift vs @_
    ... use strict; ... use warnings; ... $ cat prime-recursion.pl ... push @stream, $num; ...
    (perl.beginners)