I am using the following line to make a simple system call which works:
system (\"mkdir -p Purged\") or die \"Failed to mkdir.\" ;
Executin
system returns the exit status of the command it calls. In shell, zero exit status means success. You have to invert the logic:
system
0 == system qw(mkdir -p Purged) or die "Failed to create the dir\n";