First, I think you might have an error in the code you submitted. I assume that
$names{$refnum} = $str;
should be
$names{$ref} = $str;
Second, the reason the code is dying is because on the last line,
$names{$number} does not exist.
It might be a good idea to take a look at what $names is actually holding after the loop. A good way to see that is to use Data::Dumper
#!/usr/bin/perl
use Data::Dumper;
%names;
{
open(name, "<data/gly.txt");
while(<name>) {
($ref, $str) = split /\|/;
$names{$ref} = $str;
}
}
print Dumper(%names);
This will help you track down the problem.
davidj
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.