diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2011-07-04 09:37:36 +0200 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2011-07-04 09:37:36 +0200 | 
| commit | e496f621262e74133d9870cc197217552ad10185 (patch) | |
| tree | 53ed5eee5fa1548588f6f9f4a449756db53ddd69 /lib/App | |
| parent | 2db2afec688b8b44ddeca55cd8226c1db923b17f (diff) | |
Raps2.pm: Make file_to_hash return a hashref (consistency with pw_load)
Diffstat (limited to 'lib/App')
| -rw-r--r-- | lib/App/Raps2.pm | 32 | 
1 files changed, 16 insertions, 16 deletions
| diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm index 61bbaee..faf74d9 100644 --- a/lib/App/Raps2.pm +++ b/lib/App/Raps2.pm @@ -36,7 +36,7 @@ sub new {  sub file_to_hash {  	my ( $self, $file ) = @_; -	my %ret; +	my $ret;  	for my $line ( slurp($file) ) {  		my ( $key, $value ) = split( qr{ \s+ }x, $line ); @@ -45,9 +45,9 @@ sub file_to_hash {  			next;  		} -		$ret{$key} = $value; +		$ret->{$key} = $value;  	} -	return %ret; +	return $ret;  }  sub sanity_check { @@ -101,10 +101,10 @@ sub create_config {  sub load_config {  	my ($self) = @_; -	my %cfg = $self->file_to_hash( $self->{xdg_conf} . '/password' ); -	$self->{master_hash} = $cfg{hash}; -	$self->{master_salt} = $cfg{salt}; -	$self->{default}->{cost} //= $cfg{cost}; +	my $cfg = $self->file_to_hash( $self->{xdg_conf} . '/password' ); +	$self->{master_hash} = $cfg->{hash}; +	$self->{master_salt} = $cfg->{salt}; +	$self->{default}->{cost} //= $cfg->{cost};  	return;  } @@ -159,16 +159,16 @@ sub pw_load {  	$data{file} //= $self->{xdg_data} . "/$data{name}"; -	my %key = $self->file_to_hash( $data{file} ); +	my $key = $self->file_to_hash( $data{file} );  	return { -		url      => $key{url}, -		login    => $key{login}, -		password => $self->pw->decrypt( $key{hash}, $key{salt} ), -		salt     => $key{salt}, +		url      => $key->{url}, +		login    => $key->{login}, +		password => $self->pw->decrypt( $key->{hash}, $key->{salt} ), +		salt     => $key->{salt},  		extra    => ( -			  $key{extra} -			? $self->pw->decrypt( $key{extra}, $key{salt} ) +			  $key->{extra} +			? $self->pw->decrypt( $key->{extra}, $key->{salt} )  			: undef  		),  	}; @@ -216,8 +216,8 @@ B<cost> of key setup, passed on to App::Raps2::Password(3pm).  =item $raps2->file_to_hash(I<$file>) -Reads $file (lines with key/value separated by whitespace) and returns a hash -with its key/value pairs. +Reads $file (lines with key/value separated by whitespace) and returns a +hashref with its key/value pairs.  =item $raps2->get_master_password() | 
