in reply to Re: Multiple file handles
in thread Multiple file handles
If I were to use a file as opposed to a DB, I'd most definitely use JSON. Cross-platform, cross-language, and web API ready.
codes.json
{ "91280": "CA", "61682": "NY", "23823": "WA" }
Perl script:
use warnings; use strict; use JSON; my $file = 'codes.json'; my $data; { local $/; open my $fh, '<', $file or die $!; my $json = <$fh>; $data = decode_json $json; } print "$_: $data->{$_}\n" for sort keys %$data;
Output:
23823: WA 61682: NY 91280: CA
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Multiple file handles
by MoodyDreams999 (Scribe) on Apr 07, 2023 at 21:44 UTC | |
by 1nickt (Canon) on Apr 08, 2023 at 10:41 UTC | |
by MoodyDreams999 (Scribe) on Apr 13, 2023 at 17:26 UTC |