Thanks for replies but i still can't make it--the below lists file with some lines in it i need to match a combination of 1=NF and 5=8( each line starts with 8=F^) to select a right line
8=F^A 9=145^A 5=D^A 34=4^A 49=ABC_DEFG01^A 52=20090323-15:40:29^A 56=C +CG^A 115=XYZ^A 1=NF 0542/03232009^A 54=1^A 38=100^A 55=CVS^A 40=1^A 5 +9=0^A 47=A^A 60=20090323-15:40:29^A 21=1^A 207=N^A 10=139^A 8=F^A 9=226^A 5=8^A 128=XYZ^A 34=4^A 49=CCG^A 56=ABC_DEFG01^A 52=20090 +323- 15:40:35^A 55=CVS^A 37=NF 0542/03232009^A 1=NA 0542/03232009^A 1 +7=0^A 20=0^A 39=0^A 150=0^A 54=1^A 38=100^A 40=1^A 59=0^A 31=0^A 32=0 +^A 14=0^A 6=0^A 151=100^A 60=20090323- 15:40:30^A 58=New order^A 30=N +^A 207=N^A 47=A^A 10=149^A 8=F^A 9=378^A 5=8^A 128=XYZ^A 34=5^A 49=CCG^A 56=ABC_DEFG01^A 52=20090 +323- 15:40:35^A 55=CVS^A 37=NF 0542/03232009^A 1=NF 0542/03232009^A 1 +7=NF 0542/03232009 001001001^A 20=0^A 39=2^A 150=2^A 54=1^A 38=100^A +40=1^A 59=0^A 31=25.4800^A 32=100^A 14=0^A 6=0^A 151=0^A 60=20090323- +15:40:30^A 58=Fill^A 30=N^A 76=0034^A 207=N^A 47=A^A 9430=NX^A 9483=0 +00008^A 9578=1^A 382=1^A 375=TOD^A 337=0000^A 437=100^A 438=1243^A 95 +79=0000100001^A 9433=0034^A 29=1^A 63=0^A 9440=001001001^A 10=080^A #!/usr/bin/perl -w use strict; use warnings; my $log = "log"; my $log_string = "grep '^8=' $log |"; usage (); chomp (my $TAB_1 = $ARGV[0]); chomp (my $TAB_5 = $ARGV[1]); open (my $HAN, "$log_string") || die "Problems grepin... : $!"; my @contents = <$HAN>; my @matches = grep /1=$TAB_1 && 5=$TAB_5/, @contents ; foreach (@matches) { print "[+] FOUND $TAB_1 and $TAB_5 in\n", "-----------------------\n", "$_" ;} now you can do it like foreach (@contents) if /1=$TAB_1 && 5=$TAB_5 / - that also doesn't find lines with those 2 + matches

In reply to Perl:how to find multiple strings by auto_w

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.