Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

•Re: Re: Get All Duplicated Elements in an Array (Once, without shifting)

by merlyn (Sage)
on Oct 15, 2002 at 01:14 UTC ( #205259=note: print w/replies, xml ) Need Help??


in reply to Re: Get All Duplicated Elements in an Array (Once, without shifting)
in thread Get All Duplicated Elements in an Array (Once, without shifting)

Well, the one thing you're missing is that %hash{$_}++ is illegal syntax, unless you've already projected forward about three years and are using Perl 6.

-- Randal L. Schwartz, Perl hacker

  • Comment on •Re: Re: Get All Duplicated Elements in an Array (Once, without shifting)

Replies are listed 'Best First'.
Re: •Re: Re: Get All Duplicated Elements in an Array (Once, without shifting)
by demerphq (Chancellor) on Oct 18, 2002 at 17:35 UTC
    While it is true that %hash{$_}++ is illegal syntax, it is interesting to note that %hash->{$_}++is not. (But it only works on actual hashes and not hash references.) AFAIK its a bug, but one that has basically become a feature.
    use Data::Dumper; use strict; use warnings; my %hash; %hash->{$_}=$_ foreach 0..5; print Dumper(\%hash); __END__ $VAR1 = { '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5 };
    It embarrassed the crap out of me when I discovered this. I was reviewing some code of my colleagues, (relatively new to perl at the time) and identified these as compile time errors. He politely told me what I was full of :-) and then showed me it compiled (and worked) fine. Luckily he had a few other subtle bugs that I found so I managed to avoid looking like a complete moron. :-)

    --- demerphq
    my friends call me, usually because I'm late....

Re^3: Get All Duplicated Elements in an Array (Once, without shifting)
by graq (Curate) on Aug 11, 2006 at 13:43 UTC

    How much of an estimate is 'about' and are you still confident with your prediction? :P

    -=( Graq )=-

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://205259]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2021-07-30 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?