Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: using grep to search an array

by alicatserver (Initiate)
on Jun 06, 2011 at 21:54 UTC ( [id://908373]=note: print w/replies, xml ) Need Help??


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

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)
{
$item=$_;
chomp($item);
if (grep/$item/,@allper)
{
push(@found,grep/$item/,@allper);
}
else
{
push(@notfound,$item);
}
}

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

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://908373]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-18 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found