#!/usr/bin/perl use strict; use warnings; my $path_before = qx(/home/user/Downloads/PythonProject/test.py 2>&1); print "Befofe: " . $path_before; my $path_new = $path_before; $path_new =~ s{/}{\\}g; # Use s/\\/\//g; print "After: " . $path_new; __END__ perl test_2.pl Befofe: /home/user/.local After: \home\user\.local