You can do this with C and C ++. On Windows, you can use [ FindFirstFileand FindNextFile] ( http://msdn.microsoft.com/en-us/library/aa364418(VS.85).aspx) .
Your platform may already do this for you. If you are using Unix, say that you are running the following command:
$ ./myprog *to4
The shell first extends the wildcard and then executes myprogwith extended arguments equivalent to
$ ./myprog from0to4 from1to4 from2to4 from3to4
.
, : Perl:
foreach my $file (<*to4>) {
open my $fh, "<", $file or die "$0: open $file: $!\n";
while (<$fh>) {
print "$file: $_";
}
}
, , , :
$ for i in 0 1 2 3; do
> echo file $i > from${i}to4
> done
$ ./opento4s
from0to4: file 0
from1to4: file 1
from2to4: file 2
from3to4: file 3