in reply to Matching 2 Keywords to retreve information

You could either create a regular expression to match both parts at the same time, or alternatively use the Perl grep function to match the username and userid individually.

Using the following data file (phonebook.txt):

Jon:1:0123456789 Rob 1 0987654321 Sean 4 075312468 Tom-3-0111 222 333 Colin 3 0222 111 5555
You could write something like
#! /usr/bin/perl my ($username,$userid) = @ARGV; undef @ARGV; my @phonebook = (<>); @phonebook = grep /\b$username\b/ , @phonebook; @phonebook = grep /\b$userid\b/ , @phonebook; print foreach(@phonebook);
Then if you type
cat phonebook.txt | match.pl Jon 1
You will get Jon:1:0123456789 Hope this helps,

JJ

Update:
I do realise that the above code still has bugs, I'm just trying to give our brother Monk some pointers. For a more robust solution, you should really define a file format (e.g. colon-sperated values), then you could use split to ensure you are only matching against the right fields.