9 package # hide from PAUSE
15 sub kilobytes { $_[0] * 1024 }
16 sub megabytes { $_[0] * 1024->kilobytes }
17 sub gigabytes { $_[0] * 1024->megabytes }
18 sub terabytes { $_[0] * 1024->gigabytes }
21 no warnings 'once'; # << squelch the stupid "used only once, maybe typo" warnings
23 *kilobyte = \&kilobytes;
24 *megabyte = \&megabytes;
25 *gigabyte = \&gigabytes;
26 *terabyte = \&terabytes;
30 Moose::Autobox->mixin_additional_role(SCALAR => 'Units::Bytes');
34 print "5 kilobytes are " . 5->kilobytes . " bytes";
35 print "2 megabytes are " . 2->megabytes . " bytes";
36 print "1 gigabyte is " . 1->gigabyte . " bytes";
37 print "2 terabyes are " . 2->terabytes . " bytes";
47 Moose::Autobox->mixin_additional_role(SCALAR => 'Units::Bytes');
49 print "5 kilobytes are " . 5->kilobytes . " bytes";
50 print "2 megabytes are " . 2->megabytes . " bytes";
51 print "1 gigabyte is " . 1->gigabyte . " bytes";
52 print "2 terabyes are " . 2->terabytes . " bytes";
56 This is a Moose::Autobox port of the perl6 vmethods example.
60 Stevan Little, E<lt>stevan@iinteractive.comE<gt>
62 =head1 ACKNOLEDGEMENTS
64 This code was ported from the version in the Pugs
65 examples/vmethods/ directory. See that for original author