in reply to Using grep with wildcards

Before answering your question, I would like to point out some areas in your code that could be improved.
sub SortDirectory() { my $arrayRef = $_[0];
You have specified an empty prototype by adding () after the subroutine name, but your subroutine actually takes an argument. Don't use prototypes unless you really need them. (In other words, leave off those parens.)
my @fileArray; my $currIndex = 0; my $i; for ( $i = 0; $i < @$arrayRef; $i++ ) { if ( (grep /\./, $$arrayRef[$i]) != "" )
grep is intended to be used for pulling elements from a list. Using grep on a scalar is silly. Additionally, you're comparing strings with the numeric comparison operator != rather than the string comparison operator ne.

This would be more Perlish: if ($arrayRef->[$i] =~ /\./)

{ $fileArray[$currIndex++] = splice(@$arrayRef,$i--,1); } } push (@$arrayRef, @fileArray); }

 

Unfortunately, your code is really just guessing as to whether each item is a file or a directory (you're clearly on a Windows machine; this /\./ test wouldn't work at all under Unix or MacOS). Instead, you should use the file test operators -d and/or -f to determine whether each item is a directory or a file:
sub SortDirectory { my($path, $arrayRef) = @_; my(@dirArray, @fileArray); foreach (@$arrayRef) { if (-d "$path/$_") { push @dirArray, $_; } else { push @fileArray, $_; } } }
Because it is necessary for the filetest operator to know where the file is, I am passing in the directory path as well as the list of contents.