Hey all,

This is not a CGI/perl related question, and the option of an SQL database is out for me. I am trying to figure out the best way to open an /etc/passwd file with thousands of users and compare it to a flat-file database that I created. I have some examples below:

FROM PASSWD FILE:
chamnsa:71807168:4653:Alex A. Chamn,GROUP:/users/group/chapmanr:/usr/bin/ksh
clarkj:506558:4653:Janet Clark,WHEEL,,ED74561:/users/group/clarkj:/usr/bin/ksh
n647x12:8792:4653:Jim.E.Dew,SYSTEM,123456,ED74493:/users/system/n647x12:/usr/bin/ksh
chas:71807168:4653:Alex Chamn,GROUP:/users/group/chapmanr:/usr/bin/ksh


I want to use names, and possibly usernames to search a file that looks like this:
chamnsa:Alex:A:Chamn:00000432543:ED98709
n47x12:James:E:Dew:0000012345:ED98765
chas:Alex:D:Chamn:00000765987:ED12345
clarkj:Janet:C:Clark:00000567432:ED09876


Basically from here I would like for it to match Alex Chamn for both Alex Chamns, each with a different middle initial, and then print it out like so:
1. chamnsa:Alex:A:Chamn:00000432543:ED98709
2. chas:Alex:D:Chamn:00000765987:ED12345
If the user selects 1, then the information is then written to an output file like so:

chamnsa:Alex A. Chamn,GROUP,00000432543,ED98709


The group is actually pulled from the system being worked on, so each field from database has to be saved and accessed from an array.

Basically, I want it to search a name (from /etc/passwd) in a database and pull up to five people and display them, then allowing user which one to use. I only want it to display up to 5 results. So, for example, if I have Bill Johnson from /etc/passwd and there are 50 Bill Johnsons in the database, I only want to display the first five.

Anyway, just wondering the best way to do this...

In reply to Best way to search flat-file database by walkingthecow

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.