in reply to Re^4: Optional Arguments..?
in thread Optional Arguments..?
You can't store all the data you need like this ;
Consider using a tab delimiter record format like this ;# declare a hash of array to prepare storage of all # variables to be encoded together my $HoA{$sitename} = ["$loginid", "$password", "$url"]; open(FILEHANDLE, ">>passmgr.dat") or die("The file cannot be opened!"); my $encode = ST2614::encode($HoA, $ARGV[1]); print FILEHANDLE "$encode"; close FILEHANDLE;
Then you can build a HoA from the file like thissitename1 loginid1 encoded_password1 url1 sitename2 loginid2 encoded_password2 url2 sitename3 loginid3 encoded_password3 url3
and save it to the file like thismy $key = $ARGV[1] || 'secretkey'; my %HoA=(); open IN, '<','passmgr.dat' or die ("The file cannot be opened!"); while (<IN>){ chomp; my ($sitename,$id,$enc_password,$url) = split "\t",$_; my $password = ST2614::decode($enc_password, $key); $HoA{$sitename} = [$id,$password,$url]; # print "$sitename $id $password $url\n"; }
pojopen OUT, '>','passmgr.dat' or die ("The file cannot be opened!"); for my $sitename (sort keys %HoA){ my $id = $HoA{$sitename}[0]; my $enc_password = ST2614::encode($HoA{$sitename}[1], $key); my $url = $HoA{$sitename}[2]; print OUT join "\t",$sitename,$id,$enc_password,$url,"\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Optional Arguments..?
by Watergun (Novice) on Jun 04, 2012 at 00:07 UTC | |
by poj (Abbot) on Jun 04, 2012 at 08:12 UTC |
In Section
Seekers of Perl Wisdom