Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

You've put your chaining at a disadvantage in the ugliness department by illustrating it with mutators of $_. This technique shines in combination with other list operators like grep and sort, and when wrapped in a subroutine so that it acts on a copy of @_.

sub quux { my @args = @_; map { foo $_ } map { bar $_ } map { baz $_ } @args; }

The real alternative is nested sub calls. While those look messy in C, with all the parens to be balanced, they have an equally nice expression in Perl, my $quux = foo bar baz $_;

One of the better reasons to use map in this way is the aliasing of localized $_ to each argument in turn. That is not a big advantage in your actions on a list of one element, but is a nice shorthand when operations act on $_ by default. You missed an opportunity to use that in the map { uc } stage.

Of course, this is all extremely powerful when acting on lists. The Schwartzian Transform is on anybody's list of "Best Dressed Perl".

After Compline,

In reply to Re: Confessions of a back-alley map abuser by Zaxo
in thread Confessions of a back-alley map abuser by dimar

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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2023-11-28 15:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found