my $in_date = '02/05/2007'; # or 02.05.2007, or any non-digit-separators my $db_date = join '-', reverse split /\D/, $in_date; # to get the original format, do the same thing as before my $sep = '-'; my $pr_date = join $sep, reverse split '-', $db_date; print "in: $in_date; db: $db_date; pr: $pr_date\n"; # in: 02/05/2007; db: 2007-05-02; pr: 02-05-2007