Do you only need the first username/password or all of them.
If you want all of them I would do something like this.
use Data::Dumper;
my %ids=map {
chomp; #Get rid of the \n
(split(/=/))[0,1]
} grep( !(/^\s*#/||!/=/),
<DATA>);
print Data::Dumper->Dump([\%ids]);
exit;
__DATA__
#user=passwd
test=prrft5142
tester=foo
#This is a comment
foo
The reason why the grep has 2 patterns to match is for some error checking.
The first checks to see if it is a comment. And the second checks to see if it has an = sign in it.You probly want to put a bit more checking there like at least 1 leal character on both sides or something. 8)
Update: added the \s* to the first condition on the grep.
also added a test case for the \s* comment and the
conditiosn where there is no =.
--
Pug