Array/hash question.
Let's say I open a file. Can I apply the file array to a hash? So that they file info would in key/value pairs? If so, how do I do it?
Let's say I open a file. Can I apply the file array to a hash? So that they file info would in key/value pairs? If so, how do I do it?
Orpheus posted this at 05:33 — 25th July 2000.
They have: 568 posts
Joined: Nov 1999
You can't open a regular file as a hash. But you can go through each line of the file then assign it to a has.
Can you be more specific?
Patrick A Baer posted this at 14:21 — 25th July 2000.
He has: 32 posts
Joined: Mar 1999
# read the file
@lines = ;
# parse data into the hash named 'values'
foreach $line (@lines) {
($key,$value) = split(/\|/,$line);
$values{$key} = $value;
}
later
http://www.patrickbaer.com
Professional Photo Retouching Services
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.