I Search for "Blank_Line_Separated" Records with the following script. I would now like to Sub-Search the Matched Records for records containing lines which start with "<WhatEver>" I have been trying foreach loops but not getting the results I expected.
#!/usr/bin/perl #<"Search.pl"> Split File $LOGIN=$ENV{"LOGNAME"}; system("mkdir /tmp/${LOGIN} 2>/dev/null"); $STATUS="/tmp/${LOGIN}/STATUS"; undef $/; if ( $#ARGV == 1 ) { $OPTION=$ARGV[0]; $SEARCH=$ARGV[1]; $spid = open(SFILE, ">>$STATUS") or die "STATUS File Not Found: $!\n +"; @finfo=split(/\n\n/, <STDIN>); $tRecsInfo = @finfo; } elsif ( $#ARGV == 2 ) { $OPTION=$ARGV[0]; $SEARCH=$ARGV[1]; $FLNAME=$ARGV[2]; $fpid = open(XFILE, $FLNAME) or die "Search File Not Found: $!\n"; $spid = open(SFILE, ">$STATUS") or die "Status File Not Found: $!\n" +; @finfo=split(/\n\n/, <XFILE>); $tRecsInfo = @finfo; } else { print ("Usage: $0 <with|not> <SearchString> [<File2Search>STDIN if mis +sing]\n"); exit; } @MATCHING = (); if ( $OPTION eq "with" ) { @MATCHING = grep /$SEARCH/i, @finfo; } else { @MATCHING = grep !/$SEARCH/i, @finfo; } $tMATCHING = @MATCHING; print SFILE "\n$OPTION, $SEARCH, $FLNAME"; print SFILE "\nI read ", $tRecsInfo, " RECORDS,"; print SFILE " I Selected ", $tMATCHING, " RECORDS\n"; print join "\n\n", @MATCHING; print "\n"; close(SFILE); $spid = open(SFILE, "<$STATUS" ) or die "The Status File Not Found: $! +\n"; print STDERR <SFILE>; close(SFILE);
All help appreciated muchly

In reply to SubSearch - "Line starts with" by Saved

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.