use feature 'say'; use DateTime::Format::Strptime qw(strptime strftime); use Time::Piece; my $raw_date = '2012-01-12'; # Using tr///; built into Perl. ( my $date = $raw_date ) =~ tr/-//d; say $date; # From Time::Piece; core since 5.10. $date = Time::Piece ->strptime( $raw_date, "%Y-%m-%d" ) ->ymd(''); say $date; # From DateTime::Format::Strptime; imported functions. $date = strftime( "%Y%m%d", strptime( "%Y-%m-%d", $raw_date ) ); say $date; # From DateTime::Format::Strptime; OO interface. $date = DateTime::Format::Strptime ->new( pattern => "%Y-%m-%d" ) ->parse_datetime($raw_date) ->ymd(''); say $date;