Hello,
I was wondering if some one could assist me in something I am sure is
simple for most. I am utilizing find2perl utility and implemented it into a
perl script. However I would like to have the results of the find stored
into an array.
Basically I am trying to traverse a directory tree, and grep for a string.
When I come across that string I print the file name. I want to put that
result and all other occurrence's of my grep into an array. In running the
Unix find, I get my list of files. I then run find2perl to convert my Unix
find to a perl equivalent. I run the perl scripts and it prints out the
correct files, so I know the perl find is searching and finding the files.
The find2perl command generated two subroutines (wanted and exec). I have
tried different combinations to try and put these find results into an
array. Below is the exact code I am using. Anyone have any suggestions? It
would mean a great deal.
Thanks
Greg
eval 'exec perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
require "find.pl";
# Traverse desired filesystems
&find('/local');
exit;
sub wanted {
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
&exec(0, 'grep','-q','domain.com','{}') &&
print("$name\n");
#@filelist=$name;
#print ("Test to see if $name print\n");
}
sub exec {
local($ok, @cmd) = @_;
foreach $word (@cmd) {
$word =~ s#{}#$name#g;
}
if ($ok) {
local($old) = select(STDOUT);
$| = 1;
print "@cmd";
select($old);
return 0 unless <STDIN> =~ /^y/;
}
chdir $cwd; # sigh
system @cmd;
chdir $dir;
return !$?;
}
wanted;
--------------------------
Gregory D. Tomczyk
IBM - Contractor
(503) 578-5390
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]