#!/usr/bin/perl use strict; use warnings; use Time::Piece; my $newfilename = userinput2filename($ARGV[0]); print "got this: $newfilename\n"; sub userinput2filename { my $inp = $_[0]; my $out = $inp; while( $out =~ s/`(.+?)`/_userinput2filename($1)/eg ){} return $out } sub _userinput2filename { my $inp = $_[0]; # date +FORMAT where FORMAT must be understood by POSIX's strftime if( $inp =~ /^date\s+\+(.+?)$/ ){ return Time::Piece->new()->strftime($1) } # insert other cases you want to substitute # eventually there is something in backticks that is not in our list die "do not understand '$inp'" }