My comments will be in two parts, each regarding a different possible suggested solution.
IO::File, For that Matter, Modules in General
- How do I know if this module is installed?
- If it isn't installed and I get it from CPAN, how do I install it?
- The IO::File node shows how to open, close, and read from a IO::File object, but not how to write to one opened for writing. Where can I get more complete information?
Typeglobs
The
filehandle and
passing stuff nodes seems to imply that once such a typeglob is declared in a subroutine it must be passed in to every function that wishes to use it. So I have to do it like this?
my *bighandle = openafile();
useafile(*bighandle);
sub openafile {
local *handle;
open handle, "file" or die;
return *handle;
}
sub useafile {
local *handle = shift;
# do stuff with *handle
}
This is a little inconvenient if I want to use this handle everywhere. Which leads me to a scoping question. Since I declared
my *bighandle; at the global level, will
*bighandle be visible in
useafile even if I don't pass it in? How do you force a variable to be global?
Thanks again
Some people drink from the fountain of knowledge, others just gargle.
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.