I wanted to use system like: system("mv","*","targetDir);
This part of the description of the system() function will
be important here:
Note
that argument processing varies depending on the
number of arguments. If there is more than one
argument in LIST, or if LIST is an array with more
than one value, starts the program given by the
first element of the list with arguments given by
the rest of the list. If there is only one scalar
argument, the argument is checked for shell
metacharacters, and if there are any, the entire
argument is passed to the system's command shell
for parsing
So your call above will not invoke a shell.
But * ist not interpreted at all
Because it is the shell that interprets it, and there is no shell.
and the commande failed.
What would be the best way to do that ?
Either expand it yourself:
!system('mv', glob('*'), 'targetDir') or die "mv failed $!";
#or
!system('mv', <*>, 'targetDir') or die "mv failed $!";
Or call system such that it _will_ invoke a shell (and accept
all of the dangers that go with it):
!system('mv * targetDir') or die "mv failed $!";