On 07/25/2013 03:26 PM, Jim Gibson wrote:
You don't need a module to recognize a date in the form DD-MM-YYYY and change it into the form YYYY-MM-DD (untested):if( $date =~ /^(\d\d)-(\d\d)-(\d\d\d\d)$/ ) { $date = "$3-$2-$1"; }else{ # try other conversions }
Jim's right, but be aware that when you roll your own date code, you are taking all the validation work upon yourself. If you can trust your input, that's probably fine, but if you are dealing with user input or input from an untrusted source, you probably want to let CPAN do the work for you.
For example, the code above will happily turn '99-99-2013' into '2013-99-99'. Cheers, Michael -- Michael Brader Senior Software Engineer and Perl Person Our World Wide Web has a World Wide Network Technology/Softdev/DevOps Internode http://internode.on.net/ [email protected] iiNet http://iinet.net.au/ [email protected] -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
