$$_ = node() for \my ($in_neg, $in_pos, $out_neg, $out_pos);

Or more simply, since  $_ is already aliased to each item of the list:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "use 5.010; ;; sub node { state $x = 42; return ++$x; } ;; $_ = node() for my ($in_neg, $in_pos, $out_neg, $out_pos); dd $in_neg, $in_pos, $out_neg, $out_pos; " (43 .. 46)

Update 1: BTW: Both approaches work under Perl version 5.8.9 (without the use of state of course!).

Update 2: Although I have to say that the first | quoted form could be very useful when iterating over a list of references to arbitrary my variables (actually, I think this would work with any kind of variable, but I haven't tested this):

c:\@Work\Perl\monks>perl -wMstrict -le "use Data::Dump qw(dd); ;; print 'perl version: ', $]; ;; init($_) for \my ($scalar, @ra, %ha); dd $scalar, \@ra, \%ha; ;; sub init { my ($r) = @_; ;; return 'ARRAY' eq ref $r ? @$r = (9, 8, 7) : 'HASH' eq ref $r ? %$r = qw(one 1 two 2 three 3) : 'SCALAR' eq ref $r ? $$r = 42 : die qq{unknown ref type: '$r'} ; } " perl version: 5.008009 (42, [9, 8, 7], { one => 1, three => 3, two => 2 })


Give a man a fish:  <%-{-{-{-<


In reply to Re^2: Resistor network simplifier (updated) by AnomalousMonk
in thread Resistor network simplifier by roboticus

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.