Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^7: Optional Arguments..?

by poj (Curate)
on Jun 04, 2012 at 08:12 UTC ( #974251=note: print w/ replies, xml ) Need Help??


in reply to Re^6: Optional Arguments..?
in thread Optional Arguments..?

I have added some comments and changed it to encode/decode complete records i.e. all the data.

#!perl use strict; use ST2614; my $key = $ARGV[1] || 'secretkey'; my %HoA=(); # open file to read open IN, '<','passmgr.dat' or die ("The file cannot be opened!"); # read records line at a time while (<IN>){ chomp; # remove carriage return/line feed # decode record my $record = ST2614::decode($_, $key); # split records into fields on tab my ($sitename,$id,$password,$url) = split "\t",$record; # build hash of arrays $HoA{$sitename} = [$id,$password,$url]; # print "$sitename $id $password $url\n"; } # open file to write open OUT, '>','passmgr.dat' or die ("The file cannot be opened!"); # loop through HOA using key to extract values from array for my $sitename (sort keys %HoA){ my $id = $HoA{$sitename}[0]; my $password = $HoA{$sitename}[1]; my $url = $HoA{$sitename}[2]; # build a record of fields seperated with tab my $record = join "\t",$sitename,$id,$password,$url; # store as encoded value print OUT ST2614::encode($record,$key)."\n"; }
hope this helps
poj


Comment on Re^7: Optional Arguments..?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://974251]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2014-08-02 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls