use IPC::Cmd; sub _userinput2filename { my $cmd = $_[0]; print "executing >>unchecked<< user-input : '$cmd'\n"; # see https://perldoc.perl.org/IPC/Cmd.html for more details: my( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) = IPC::Cmd::run( command => $cmd, verbose => 1, ); die "failed : $error_message (@$stderr_buf)" unless $success; # this is the stdout of the command return $stdout_buf }