in reply to transfering a particular kind of file
because readdir() returns file names from the given directory handle, and those will never have slashes in them. And because it's just the file name without the directory path, the -s won't work on $_ by itself there.my @lines = grep { -s && "$source/*.log" } readdir ($DIR);
You may need to show us the line in your script that does the "opendir()" -- you do have such a line, don't you? (readdir won't work unless you do opendir first)
In any case, you probably want something like this:
That's assuming that $source is the name of the directory that was passed to the opendir() call (and that the directory handle was the lexically-scoped variable $DIR rather than a bareword "DIR").my @lines = grep { /\.log$/ and -s "$source/$_" } readdir $DIR;
|
|---|