Perl Advent Calendar 2010-12-8++

Selfless gifting

by Jerrad Pierce

Given the megamiles of ribbon Nick goes through every December, it should come as no surprise that he's not a afraid of tieing the occasional package from time to time. He therefore had no aversion to the labor saving design of selfvars, a module that simplifies the tedious accessing of method parameters.

   1 package Present;
   2 use selfvars;
   4 sub new{
   5     return bless({}, shift);
   6 }
   8 sub give{
   9     #Look ma! No shift
  10     printf "%s to %s\n", $hopts{what}, $hopts{who};
  11 }
  13 package main;
  15 my $gift = new Present;
  16 $gift->give(what=>'Zoozit sticks', who=>'Cindy Lou');
View Source (POD)