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??

Excuse me, but what you are calling syntactic sugar, I call grammar!. Actually I find your comment diminishing towards all those fantastic computer linguistics that have been working so hard to incorporate iterative behaviors into the natural language of Perl. Choosing long used idioms over major parts of the grammar is your choice but personally I feel you are staying one step behind. Take Perl 6 for example where they are taking these concepts even a 1000 steps further!

Just doing a bit of googling, finding tons of examples. This one from the perl6 archives is already from 2000:

The ability to take an indexed slice of a hash is desired. This would allow the programmer to pare out several keys and values from hash A into a new hash B, for greatest flexibility. Currently, this is only available through map():

    %other = map { $_ => $sounds->{$_} } qw(lizard duck);

Which could be simplified to:

%other = slice(%$sounds, { qw(lizard duck) }); # or, %other = (%$sounds =~ sl/lizard duck/h); # or, %other = %$sounds->{'lizard', 'duck'}; # or, %other = %{$sounds}{ qw(lizard duck) }; # trad'l

Syntactic sugar? Sure, whatever.

edit: corrected typo, changed last comment.

In reply to Re^4: A more elegant way to filter a nested hash? by Veltro
in thread A more elegant way to filter a nested hash? by jimpudar

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 imbibing at the Monastery: (5)
As of 2024-04-19 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found