
japhy
Enthusiast
Sep 8, 2000, 6:31 AM
Post #2 of 4
(422 views)
|
Your biggest problem is that [ and ] are regex metacharacters. Try backslashing them: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> if ($text =~ /\[$user\]/) { ... } </pre><HR></BLOCKQUOTE> And that while loop of yours is a bit silly-looking. You shouldn't check for eof(VIRT), especially since you CLOSED the filehandle. There's no need to store the file in an array. Just loop over it with while: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $x = 1; open VIRT, "/etc/mail/virtusertable"; while (<VIRT> ) { print "$_ $user $x<br>\n" if /\[$user\]/; print "$_ $domain $x<br>\n" if /\[$domain\]/; $x++; } close VIRT; </pre><HR></BLOCKQUOTE> ------------------ Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher
|