Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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....


In reply to Re: •Re: Re: Get All Duplicated Elements in an Array (Once, without shifting) by demerphq
in thread Get All Duplicated Elements in an Array (Once, without shifting) by George_Sherston

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 19:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found