Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

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

There's nothing really wrong with it, but I find it's wordier than it needs to be. Look at what the Perl6 idiom looks like; much quieter visually. Trying to retrofit the construct for this use can lead to some awkward choices: f.ex, I understand why you put the assingment in the for list rather than on the my line before it, but isn't that really the wrong way around? There's no reason to pick one over the other in terms of effective length, but of course putting the assignment on the my line makes the for line stick out like a sore thumb…

If I really wanted to use $_ as “it”, I'd probably use a do block:

my $window = do { local $_ = Gtk2::Window->new( "toplevel" ); $_->signal_connect( delete_event => sub { Gtk2->main_quit } ); $_->set_title( "Test" ); $_->set_border_width( 15 ); $_->add( do { local $_ = Gtk2::Button->new( "Quit" ); $_->signal_connect( clicked => sub { Gtk2->main_quit } ); $_; } ); $_->show_all(); $_; };

That mirrors the structure I achieve with my snippet most closely. But it needs those ugly $_; strewn in there and I'm still mentioning $_ a million times — a blanket of noise covering the code.

Make no mistake, I'm not 100% satisfied with what this snippet allows, either. But until we have Perl6 in our hands, it won't be possible to do much better than it.

Makeshifts last the longest.


In reply to Re^2: multiple method calls against the same object, revisited by Aristotle
in thread multiple method calls against the same object, revisited by Aristotle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (13)
    As of 2014-07-11 06:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (220 votes), past polls