Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

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

Wrong how? By suggesting that foreach() could work if suitably innovated? I don't see how this could be wrong. You are looking at the current implementation of foreach() and local() and declaring it impossible, unfeasible, or wrong. If everybody looked at Perl this way, there would be no Perl 6, let alone Perl 2.

Please note that I didn't say the patch would be less than 100 lines long. Perl's evolution is entirely based on this sort of principle. People expecting something to 'just work'. It doesn't. People fix it so that it does. This is Perl. You should be familiar with this by now. :-)

You seem to be stuck on the definition of 'variable'. Where you and the original poster differ is that you don't see a[5] as a variable. I and the original poster *do* consider a[5] to be a variable. Fine, it doesn't have a simple name, but then, who cares about simple names? Your example showing that local() has a wider scope is wrong, since I am sure you should realize that:

package main; local $b = 2; $main::b = 3; print "$b\n"; # prints "3\n"

Meaning, that '$b' is really just ${$main::{'b'}}, which is just as much a 'variable' or not a 'variable' as $a[5] is.

I think I've made my case... :-)


In reply to Re: Re: Re: Re: Re: Re: Surpised by foreach iterator limitation by MarkM
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 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 admiring the Monastery: (3)
As of 2024-04-20 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found