Debbie Cooper wrote:
>
> I need to search for the occurrence of a string in a file that is buried in
> directories. So, for example, I have a directory structure that looks like
> this C:\data\elec\1\220\webdata.tab. The last three folders change
> frequently so I can have c:\data\appl\3\180\webdata.tab and so on. The file
> I'm searching will always be called webdata.tab. It is a tab delimited file
> with headers and I need to search the header for a specific word like
> "Brand" and somehow return the directory structure where the word is found.
> Can this be done in "beginning" perl?
You could do something like this (untested):
@ARGV = glob 'C:/data/*/*/*/webdata.tab';
my @files;
while ( <> ) {
push @files, $ARGV if /string/;
close ARGV if $. == 5; # five header lines?
}
print "$_\n" for @files;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>