in reply to pattern matching

as for me, I'd use a little split action, as it looks like you are using colon-separated records. This has the advantage of isolating the fields from each other, allowing you to more easily (and safely) extract their content.
while(<>){ my ($id, $user_name, $p_id, $password) = split ':'; #do stuff to the stuff in $id and $p_id }

thor