Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Just to recap my main point thru out this subthread: (many points here is not directly against the original post, but against the whole subthread. Many of those things I disagree with is even not part of shotgunefx's original purpose, but MarkM's extension. I disagree with MarkM's points, but not him as a fellow monk ;-)

$hash{key} is the valid syntax to name a hash element, which happened to be a scalar (which could be array ref, hash ref ...), does not mean $hash{key} is a valid variable name for a scalar.

There is something subtle here, and we are looking at two different perspectives.

maybe a better way to explain this subtle difference is to look at some other computer language, for example c:

You can define a collective int a[200];, and ref to its 100th element by saying a[99], but a[99] is not a valid variable name. Otherwise, how can you recognize whether a[99] is a single variable or an element of a collective data structure?

One may say that this is Perl, not c. Well, when you look at the foundation, they have more similarities than differences. Whatever language it is, it requires the syntax can be consistently parsed/recognized.

Some people may argue that there are lots of "bad" syntax in Perl, what a big deal to have one more? Again, here is something subtle. Perl might have many "bad" syntax from a conventional language point of view, but all those "bad" syntax can be consistently parsed according to context. I bet nobody dare to have "bad" syntax that cannot be consistently parsed.

(the original content of this original reply is based on misunderstanding of what shotgunefx means. He actually means something much more subtle.)I don't call that a limitation ;-). To iterate thru a hash, you would do something like:
%hash = (a=>1, b=> 2, c=>3); foreach (keys %hash) { print "\$hash{$_} = $hash{$_}\n"; }
What makes this conventional approach not work for you?

In reply to Re: Surpised by foreach iterator limitation by pg
in thread Surpised by foreach iterator limitation by shotgunefx

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 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? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2021-07-26 14:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?