use File::Which qw(which); $tshark_binary = which('tshark'); $tshark_binary =~ s/\\/\\\\/g if $tshark_binary =~ /\\/;