[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] Calling a method w/o an object :)
$ad (arrival date) is an object of a class that is a subclass of
Class::Date.
http://search.cpan.org/~dlux/Class-Date-1.1.9/Date.pod
Here I'm calling the format() method on objects which result from adding
days to arrival date...
my ($day1, $day2, $day3) = (
$ad->format("%Y-%m-%d"),
($ad + "1D")->format("%Y-%m-%d"),
($ad + "2D")->format("%Y-%m-%d")
);
Wrapping $ad + "1D" in parentheses lets me a call a method on the
resulting object w/o naming that object (who needs an extra line of
code?)...
And the results in the debugger when $ad is Jan 06, 2007:
DB<4> x $day1, $day2, $day3
0 '2007-01-06'
1 '2007-01-07'
2 '2007-01-08'
Neat, huh?
j