On Sat, Mar 12, 2011 at 01:35:31PM -0500, Shawn H Corey wrote:
> On 11-03-12 10:56 AM, kurtz le pirate wrote:
> >quick write, not tested
>
> I suggest you test it.
Is this general advice or do you see a problem with the code? If it is
the former, I agree. If it is the latter, please point out t
On Sat, Mar 12, 2011 at 05:31:06PM +, Rob Dixon wrote:
> On 12/03/2011 15:41, ashwin ts wrote:
> >
> >Thank you all for the support.It helped me a lot.i tried working with arrays
> >as well as with hash.Both the approaches works fine in the case of a small
> >array with few elements.
> >When i
At 03:14 -0500 12/03/2011, Uri Guttman wrote:
this replaces the entire if/else statement:
$hash{$item}++ ;
...it is a standard perl idiom you need
to know so you don't waste code like that.
Nice!
so
#!/usr/local/bin/perl
use strict;
my %hash;
my @array = split //, 12342312111467;
f
On 11-03-12 10:56 AM, kurtz le pirate wrote:
quick write, not tested
I suggest you test it.
--
Just my 0.0002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Programming is as much about organization and communication
as it is about coding.
The secret to gr
In article
,
ashwint...@gmail.com (ashwin ts) wrote:
> Hi,
>
> I am a newbie to perl.
> I have an array which has few elements like '1,2,3,4,2,3,1,2,1,1,1,4,6,7'
> i need to know how many times each element has occurred in the same array.
> for example 1-5 times
> 2-3 times...
On 12/03/2011 15:41, ashwin ts wrote:
Thank you all for the support.It helped me a lot.i tried working with arrays
as well as with hash.Both the approaches works fine in the case of a small
array with few elements.
When i tried the same for a large array , i started getting "out of memory"
error
Hi,
Thank you all for the support.It helped me a lot.i tried working with arrays
as well as with hash.Both the approaches works fine in the case of a small
array with few elements.
When i tried the same for a large array , i started getting "out of memory"
error.
Any suggestions would be of great
On Sat, Mar 12, 2011 at 09:20:01AM +0100, mag...@trapd00r.se wrote:
> On 2011-03-12 13:17, ashwin ts wrote:
>
> >I have an array which has few elements like '1,2,3,4,2,3,1,2,1,1,1,4,6,7'
> >i need to know how many times each element has occurred in the same array.
> >for example 1-5 times
> >
On 2011-03-12 13:17, ashwin ts wrote:
Hi,
Hello,
I have an array which has few elements like '1,2,3,4,2,3,1,2,1,1,1,4,6,7'
i need to know how many times each element has occurred in the same array.
for example 1-5 times
2-3 times...
Use a hash.
#!/usr/bin/perl
use
> "PK" == Parag Kalra writes:
PK> my @array = (1,2,3,4,2,3,1,2,1,1,1,4,6,7);
PK> my %hash;
PK> foreach my $item (@array){
PK> if (exists $hash{$item}) {
PK> $hash{$item} = $hash{$item} + 1;
PK> } else {
PK> $hash{$item} = 1;
PK> }
PK> }
this repl
Hello Ashwin,
I have an array which has few elements like
'1,2,3,4,2,3,1,2,1,1,1,4,6,7' i need to know how many times each
element has occurred in the same array. for example 1-5 times 2-3
times... could some one throw some light on how i can do this.
Store the array contents into a hash, upda
>
>
> could some one throw some light on how i can do this.
> thanks in advance..
>
use strict;
use warnings;
my @array = (1,2,3,4,2,3,1,2,1,1,1,4,6,7);
my %hash;
foreach my $item (@array){
if (exists $hash{$item}) {
$hash{$item} = $hash{$item} + 1;
} else {
$hash{$item} =
12 matches
Mail list logo