http://qs321.pair.com?node_id=1204948


in reply to Re: Bolt on where a match is not found to a print script
in thread Bolt on where a match is not found to a print script

I think they wanted to check for each number separately. But this is most of the way there -- I'd just add a hash for the match, something like $matched{$1} = 1, and check that at the end.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^3: Bolt on where a match is not found to a print script
by hippo (Bishop) on Dec 05, 2017 at 12:30 UTC

    Hmmm. Yes, you could well be right about each one requiring a separate flag, although that's not how I originally read the requirement. At least our anonymous brother has 2 marginally differing approaches to choose between. The whole thing does have something of an XY ring to it. Perhaps we'll find out.

      Thank you so much guys.. so the primary function of the code is to search through the text files in the folder and print every line that includes a the exact match to the number (contained within the line). the secondary requirement is that IF after searching through all the files no single match is found of the number then print at the bottom that it was not matched

      this is a sample of the data:

      Port Name Status Vlan Duplex Speed Fa0/1 Sohnsons connected 1404 full 100 Fa0/2 Sohnsons connected 1404 full 100 Fa0/3 XYZ connected 1221 full 100 Fa0/4 Sohnsons notconnect 1404 full 100

      If you searched the files for 3 number (1404,1221,1234) 1234 would not be matched and printed, thus we would want "1234 not matched" printed. The code you presented worked really well for a single search, but we need to search multiple values

        Thanks for this clarification. In that case, QM's solution should be precisely what you need. Try that and see how you get on.