Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

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

This is a japh using duff's device. If you want to understand it, make sure you know what duff's device is (google it or see's-device.html).

This may fail if perl is compiled with long doubles or some 64bitness.

I run it successfully with perl5.{00503(if deleted "no warnings"),6.1,8.0,8.1} on i686-linux and perl5.6.1 on sun4-solaris (sparc).

# the usual declarations you use in evry program no warnings; no strict; # initialize arrays @a= ( 2.9230032746618539e+48, 3.7537584144024476e+255, 8.7398998774645058e+245, 5.7277807836951398e+250, 1.4916681462400519e-154, 1.7573882009934739e+159, 7.2294757342932134e+221, 4.7379092172264014e+226, 5.7277807836951398e+250, 9.1248812352446012e+192, 3.2418090381883485e+178, 1.3336028865760046e+241, 1.4916681462400519e-154, 2.315841784746365e+77, 3.2418090381883485e+178, 1.3336028865760046e+241, 1.6832434884955199e+212, 1.4916681462400519e-154, 9.1248812352446012e+192, 1.7573882009934739e+159, 7.5479248496432486e+168, 2.5684257331779778e+207, 3.2418090381883485e+178, 1.3336028865760046e+241, 1.6259745436952359e-260 ); tie @b, &^Px$^P; # with duff's device I can copy array very efficently goto ("case" . (@a % 8)); while ($a < @a) { case0: $b[$b++] = $a[$a++]; case7: $b[$b++] = $a[$a++]; case6: $b[$b++] = $a[$a++]; case5: $b[$b++] = $a[$a++]; case4: $b[$b++] = $a[$a++]; case3: $b[$b++] = $a[$a++]; case2: $b[$b++] = $a[$a++]; case1: $b[$b++] = $a[$a++]; }; # oh, I nearly forgot magical subs, so here they are sub DESTROY { } sub AUTOLOAD { ($#, %c)= qw(%c $#); print $_[2]; bless []; } __END__

I wonder if you can see how it works, especially what the two magic subs do. If you know, please reply me. (Is this too trivial?)

In reply to Fun with duff's device and AUTOLOAD by ambrus

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, 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
  • 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (5)
    As of 2018-02-24 08:49 GMT
    Find Nodes?
      Voting Booth?
      When it is dark outside I am happiest to see ...

      Results (310 votes). Check out past polls.