in reply to How do I call a DOS command with a /C variable in PERL ?

Fletch had a good suggestion, but the results it returns are not the same as the find command, since the find command will return a count of all occurance, which may or may not be important to the problem at hand. This code block will give you a count of all the times the string occurs in a file.
my $file = "/path/to/file/and/filename"; open(LOG,"$file") or die; my $match_count; while(<LOG>) { my (@matches) = $_ =~ m/(127\.0\.0\.1)/g; $match_count += scalar(@matches); } print $match_count , "\n";

Try to avoid system calls completely if it can helped to provide more portability and generally faster safer programs.

Replies are listed 'Best First'.
Re: Re: How do I call a DOS command with a /C variable in PERL ?
by sheabo (Initiate) on Jan 28, 2002 at 10:57 UTC
    Thanks trs80, Your code worked a treat. Thanks again... Kind Regards Sheabo