Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

You're assuming code exists in isolation. I can't think of any code that needs the number of elements in a hash that would be unclear no matter how you spelled

0+keys(%h)

But that doesn't mean they're all equal.

  • The 0+ points out that something special is happening, whereas scalar() just looks like a function call. A function call that doesn't exist. There's not even an op for it.

  • The 0+ points out that a number is going to be returned, confirming what one might think keys is doing.

If you used scalar, they might not know exactly what it did but they'd have a direct pointer to documentation that would explain exactly what the intent of the code was.

I think they'd be better off reading the docs for keys, not scalar. The former lists the two possible return values for keys. The understanding of context will follow.


In reply to Re^3: Wrong result for "length keys %$hashref"? by ikegami
in thread Wrong result for "length keys %$hashref"? by samwyse

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 studying the Monastery: (5)
As of 2024-03-29 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found