A previous worker for our company set up our company address book as a text file, now I'm here to add a search add on to it allowing to search for any and all criterea.
I usually work with simplistic databases such as DB_File, but never on a text file for something like this. I need to build a search which will scan through the text file and pull back all the information that matches. For example, if I searched the string "robertj" and given it matches the email address below, it would pull back the entire record of that person (or persons, given that it matches more than once). This includes name, number, etc.
I have no idea where to get started, again I've never used text files for searching like this before. All entries are separated by %%% which definitely helps determine which data fits where.
Can anyone offer advice how to do this? All I need to do is set it up so they can search ANYTHING and for all the records that match, pull it back to screen for them. Sounds simple and they refuse to let me recode the system for them :(
Name: Robert Johnson
Phone: (555)555-1111
Fax: (555)555-1112
Address: 12345 Anywhere St.
Email: robertjohnson@someisp.com
Info: more info
%%%
Name: Robert Goor
Phone: (555)555-1113
Fax: (555)555-1114
Address: 12345 Somewhere St.
Email: robert@cs.someu.edu
Info: Some more info
%%%
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.