Re: simple question
- From: jialinli1981@xxxxxxxxx (Jialin Li)
- Date: Sun, 27 Apr 2008 12:03:33 -0500
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/
- Prev by Date: Re: simple question
- Next by Date: Re: strings printing bug
- Previous by thread: Re: simple question
- Index(es):
Relevant Pages
|
|