Re: array iteration problem

2006-02-08 Thread John Doe
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

Re: array iteration problem

2006-02-08 Thread Bjørge Solli
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{$_}+

Re: array iteration problem

2006-02-08 Thread JupiterHost.Net
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

Re: array iteration problem

2006-02-08 Thread JupiterHost.Net
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

Re: array iteration problem

2006-02-08 Thread John Doe
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 (

Re: array iteration problem

2006-02-08 Thread Jeff Pang
>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

RE: array iteration & references

2002-12-16 Thread Duarte Cordeiro
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

Re: Array Iteration

2002-11-11 Thread Paul
--- 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.

Re: Array Iteration

2002-11-11 Thread david
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