use feature qw( say ); use IPC::Run qw( run ); my $path = q{/a/b/c/$USER}; my $output = q{}; run( ['/bin/bash', '-c', qq{echo -n "$path"}, ], q{>}, \$output ); say qq{Output: $output};