Not to new to Perl (yet I have alot to learn still), but I've never had a real open need for hashes before either, until now. Here's my question. Basically I have multiple files that I'm reading out of, where the files are the names of my hashes, so given the code (for one hash):
open(STATS, "/path/to/file");
@file = <STATS>;
close STATS;
Each file will contain a one liner only, in the format of:
key|value|key1|value| and so on
And now the hash:
%file=("key" =>value,
"key1" =>value);
How would I be able to read this out of @file, so that I could write the hash as:
%file=("$key" =>value,
"$key1"=>value);
I was thinking of some snippits, but they would be way to long and complicated (and not needed), as I am sure there is a much easier way out there (basically I was going to run a few loops, but pointless I think). Any help would be appreciated.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.