in reply to Integrating System commands with regex's
Regarding the efficiency issue, I think that there shouldn't be much difference between the two approaches; I don't want to Benchmark it because I don't want to fill a directory with useless files :)
I say that because, on a very general approach, I think that the OS has to load the directory table to give to Perl, and then you end up either analysing it by yourself, or leaving Perl to do it for you, which I don't think makes much difference. If you only want to test if some file exists, I'd stick to the simpler solution, that is:
See perldoc -f -X for variants in the test, I've put the most general "file existence" test instead of your more specific "file is a plain file", thus including directories, fifos, etc.my $basedir = "/path/to/directory"; my @candidates = qw ( this and that file ); my @present = grep { -e "$basedir/$_" } @candidates;
Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")
Don't fool yourself.
|
|---|