http://www.perlmonks.org?node_id=330784

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 http://www.faqs.org/docs/jargon/D/Duff'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?)