[PLUG] Perl

Colin Kuskie ckuskie at dalsemi.com
Mon Jul 3 19:18:57 UTC 2006


On Mon, Jul 03, 2006 at 12:09:17PM -0700, Roderick A. Anderson wrote:
 
> sub getpassdb {
>   # Read password file creating usernames and
>   # passwords hash.
> 
>   my %passworddb;
> 
>   local $file_passwd = "/root/firewall/var/cgi_password" ;
> 
>   open ( $INPASS, '<', $file_passwd" )
>     or die "Error--unable to open $file_passwd $!" ;
> 
>   while ( my $passline = <{ $INPASS }> ) {
> 
>     chomp $passline;
> 
>     %passworddb = ( $passworddb, ( split ( '=', $passline ) ) );
> 
>     return %passworddb;
> }

I don't think that code will compile.  At the very least you have to
close the while block.

$passworddb should be changed to %passworddb so that it will append
to the hash, and the subroutine isn't clean for a use strict.

Colin



More information about the PLUG mailing list