No comment on the NL problem really, except that reading is usually not a problem in Perl - you have to be more careful if writing files for distribution to *nix or WinDOS.
If you are looking at making your code more robust, I would second the previous recommendations on file handling - remember FH style globs are global.
You might even consider using IO::File which IMHO has an easy peasy and pretty interface, and automatically closes in a kernel resource friendly manner!
use IO::File;
my $fh = IO::File->new($filename, "r")
or die "unable to open $filename: $!";
for my $line ( $fh->getlines() ) {
chomp $line;
print "[$line]\n";
}
I would also add the comment that your two subs duplicate each other - why not just have one? Or if you really like having the two names then...
sub load_primers {
return _loadIndex( @_);
}
sub load_parents {
return _loadIndex( @_);
}
and move all the code into _loadIndex();
$0.02
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.