in reply to facing problem in escaping space in file path No such file or folder

add
use autodie;
and you'll get better error messages, observe
$ perl -Mautodie -e " $asdf = 44; chdir '$asdf' " Can't chdir('$asdf'): No such file or directory at -e line 1 $ perl -Mautodie -e " $asdf = 44; chdir $asdf " Can't chdir('44'): No such file or directory at -e line 1
moral of the story, single quotes do not interpolate

Also, chdir does not care about spaces

Replies are listed 'Best First'.
Re^2: facing problem in escaping space in file path No such file or folder
by NaveeN Kumar S (Initiate) on Jun 22, 2011 at 11:07 UTC
    use autodie; my $unInstallExepath = "C:\Program Files\NetBeans 7.0\uninstall.exe"; my $path = dirname($unInstallExepath); # $path contain C:\Program + Files\NetBeans 7.0 $path = quotemeta($path); chdir($path) or print "XXXXXXXXXXXXXX $!";

    after quotemeta $path contain \"C\:\\Program\ Files\\NetBeans\ 7\.0 Error is Can't chdir('\"C\:\\Program\ Files\\NetBeans\ 7\.0'): No such file or directory at line 4

    in confusion why it was quoting \" in ----- > chdir('\"C\:\\Program\ Files\\NetBeans\ 7\.0')

      That's because you are not supposed to use quotemeta() here. quotemeta() is for escaping stuff from the regexp engine, not for the shell!

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.