JupiterHost.Net am Mittwoch, 8. Februar 2006 15.51:
> > use strict; # forces declaring variables
> > use warnings;
>
> yep yep :)
>
> >>@cpv_codes=('a','a','a','a','b','b','b','c','c','d');
> >
> > my @letters=(qw{ a a a a b b b c c d });
>
> No neeed for the (), which also make sit easier to write
On Wednesday 08 February 2006 15:51, JupiterHost.Net wrote:
> So for instance to treat upper and lowercase the same (IE 't' is
> considered the same as 'T')
>
> for my $letter(@letters) {
> $letter_count{ lc($letter) }++ if lc($letter) =~ m{^[a-z]$};
> }
or just (untested):
$letter_count{$_}+
use strict; # forces declaring variables
use warnings;
yep yep :)
@cpv_codes=('a','a','a','a','b','b','b','c','c','d');
my @letters=(qw{ a a a a b b b c c d });
No neeed for the (), which also make sit easier to write and to look at :)
# qw (quote words) makes it easier to write and to
Hello,
and it prints:
a1
a2
a3
a4
b1
b2
b3
c1
c2
d1
What I really need is:
a = 4
b = 3
c = 2
d = 1
>
How would I do this? Any ideas?
You're printing each time its incremented, just print the keys and their
Graeme McLaren am Mittwoch, 8. Februar 2006 14.53:
> Hi all, I have the following code:
Hi Graeme
> # code
use strict; # forces declaring variables
use warnings;
> @cpv_codes=('a','a','a','a','b','b','b','c','c','d');
my @letters=(qw{ a a a a b b b c c d });
# qw (
>foreach (@letters) {
>$hash{$_}++;
>print "$_\t $hash{$_} \n";
>}
I think,the code should be written as below:
foreach (@letters) {
$hash{$_}++;
}
foreach (sort keys %hash){
print "$_ = $hash{$_} \n";
}
--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com
--
To unsu
I'll answer my own question:
Inside optionsNextItem I'm making a copy of @{$ref}, so setting any
value in that copy won't change the array (stupid me).
-Original Message-
From: Duarte Cordeiro
Sent: Monday, December 16, 2002 9:53 AM
To: '[EMAIL PROTECTED]'
Subject: array iteration & ref
--- Chris Rogers <[EMAIL PROTECTED]> wrote:
> Hi all,
Hi, Chris. =o)
Suggestion below problem description.
> I backed myself into a corner and cold use a little help. I have a
> multi-dimensional array that has a know number of elements at the
> deepest level but the number of levels is unknown.
Chris Rogers wrote:
> Hi all,
>
> I backed myself into a corner and cold use a little help. I have a
> multi-dimensional array that has a know number of elements at the deepest
> level but the number of levels is unknown. Here is a brief example:
there are a number of ways of doing what you wa