Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^3: using grep to search an array

by John M. Dlugosz (Monsignor)
on May 23, 2011 at 20:53 UTC ( #906366=note: print w/replies, xml ) Need Help??

in reply to Re^2: using grep to search an array
in thread using grep to search an array

OK, so it is supposed to be a prefix. That means the \n at the end of $testit is getting in the way of letting it match.

Use chomp inside the loop.

Replies are listed 'Best First'.
Re^4: using grep to search an array
by alicatserver (Initiate) on May 23, 2011 at 21:11 UTC
    Chomp worked!! thanks
      I made an improvement to my script and I thought Id post it so that others can benefit from it.
      This rewritten version gives me two files... items that were "found" when searching the allper array and items that were "not found".
      (PS: the variables were renamed)

      foreach (@raw_data)
      if (grep/$item/,@allper)

      open RESULT, ">_found_items.txt";
      print RESULT "@found\n\n";

      open noRESULT, ">_doesnotexist.txt";
      print noRESULT "@notfound\n\n";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://906366]
Corion is mildly surprised as some different toy projects coagulate into a useful application. I've been toying with writing a Meetup wrapper and also have been toying with synchronizing events between (CalDAV) calendars, and now that means I can ...
[Corion]: ... easily* synchronize my personal calendar with Meetup and import stuff from Meetup there
[Corion]: * Code not yet written, some restrictions may apply

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2017-02-23 09:31 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (343 votes). Check out past polls.