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"; }
In reply to Re^5: Optional Arguments..?
by poj
in thread Optional Arguments..?
by Watergun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |