On Thu, Jun 21, 2001 at 01:43:44PM -0400, Yacketta, Ronald wrote:
> I have been looking for a way to search for two strings in a line
> at the command line I would

Well, for this you'd use something like:

    open(FILE, $file) || die("Unable to open file \"$file\": \l$!.\n");
    while (<FILE>) {
        print if /$string1/ && /$string2/;
    }


> Communication $grepTMPFILE | grep failure | wc -l
> 
> how would this be converted into perl/regex? I have part of it right now
> (Thanxs to others on the list)

Translating this verbatim:

    open(COM, "Communication \Q$grepTMPFILE\E |") || die("fork failed: \l$!\n");
    while (<COM>) {
        $count++ if /failure/;
    }

    print "$count\n";



> foreach (@output) {
>       foreach my $test(@lookFor) {
>               $results{$test}++ if /$test/igo;
>       }
> }
> 
> I need to add a && to the if above.. correct?
> 
> if ( $test == 'Communication' ) {
>       if ( /$text/igo && /failed/igo ) {      $results($test)++; }
> }


The three descriptions you provide above contradict each other.  You ask for
a solution to search for multiple strings in each line of a file, then show
an example of grepping the output of a program called Communication, then
list some Perl code doing neither.  Hopefully one of the solutions I've
provided solves your problem, but if not you need to be clearer about what
it is you're trying to solve.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Reply via email to