I found it very clean and easy to read. I'm an Emacs user and would like to switch to that mode of formatting my text. But I'm not sure if that's possible.sub rand_date { # Get the options hash my %options = @_; # use the Date::Calc module eval q{ use Date::Calc }; cluck($@) && return if $@; my ( $min_year, $min_month, $min_day, $max_year, $max_month, $max_ +day ); # Get today's date my ( $year, $month, $day ) = Date::Calc::Today(); if ( $options{'min'} ) { if ( $options{'min'} eq 'now' ) { ( $min_year, $min_month, $min_day ) = ( $year, $month, $da +y ); } else { ( $min_year, $min_month, $min_day ) = split ( /\-/, $options{'min'} ); } } else { ( $min_year, $min_month, $min_day ) = ( $year, $month, $day ); } if ( $options{'max'} ) { if ( $options{'max'} eq 'now' ) { ( $max_year, $max_month, $max_day ) = ( $year, $month, $da +y ); } else { ( $max_year, $max_month, $max_day ) = split ( /\-/, $options{'max'} ); } } else { ( $max_year, $max_month, $max_day ) = Date::Calc::Add_Delta_YMD( $min_year, $min_month, $min_day, +1, 0, 0 ); } my $delta_days = Date::Calc::Delta_Days( $min_year, $min_month, $min_day, $max_ye +ar, $max_month, $max_day, ); cluck('max date is later than min date') && return if $delta_days +< 0; $delta_days = int( rand( $delta_days + 1 ) ); ( $year, $month, $day ) = Date::Calc::Add_Delta_Days( $min_year, $min_month, $min_day, $delta_days ); return sprintf( "%04u-%02u-%02u", $year, $month, $day ); }
-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Code Formatting - generous spaces in expressions
by toolic (Bishop) on Jun 16, 2011 at 14:41 UTC | |
|
Re: Code Formatting - generous spaces in expressions
by biohisham (Priest) on Jun 18, 2011 at 15:54 UTC | |
|
Re: Code Formatting - generous spaces in expressions
by pvaldes (Chaplain) on Aug 13, 2011 at 10:55 UTC |