in reply to Re^2: delete folder and its content with plain perl
in thread delete folder and its content with plain perl

ytiPerl:

Inside single quotes, a variable is not expanded, so you're running "rmdir /S /Q $foldername".

Try changing it to:

my $result = system("rmdir /S /Q $foldername");

Of course, if you have backslashes or spaces in the $foldername variable, then you'll get other problems. That's why you might want to consider using the list version of the system command, like:

my $result = system('rmdir', '/S', '/Q', $foldername);

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^4: delete folder and its content with plain perl
by ytjPerl (Scribe) on Nov 08, 2017 at 16:35 UTC

    my $result = system('rmdir', '/S', '/Q', $foldername);?

    I used this, but as my $foldername path is d:\log_script\Archive I got error invalid switch - "log_script" , is that because "_" in my path?