Variable inside regular expression



Hi there,

Im trying to get specific groups out of the unix group file. The list
of group names is contained in Group_list.txt, when I try and run this
code, I get no output. Is it possible to use variables inside regex?


----------------------------
#!/usr/bin/perl -w

use Slurp;
$datafile="/home/mw/Group_list.txt";
$groupfile="/etc/group";
my @array = Slurp::to_array($datafile);

foreach $entry(@array) {

open(FH, "<$groupfile");
while (<FH>)
{
chomp $_ ;
if ($_ =~ /^$entry/){print $_ . "\n" ;}
}
close (FH);
}

----------------------------


Thanks in advance,

matt

.