Hmmm...
Perhaps I described the problem inadequately. The user of my module creates the file handle. My module exports openOut and it takes a file handle as its first argument in a variable:
sub openOut
{
my $file_handle = $_[0];
my $output_file = $_[1];
...
}
I use that file handle (in variable form - stored in a hash actually) multiple times throughout the module. My module doesn't know the bareword handle name, so I can't directly reference
*main::OUT in my module code to "use it twice". Even if I get the name of the bareword file handle with some trick like
$bareword_filehandle = select(), I wouldn't guess that I could satisfy the "use it more than once" requirement regarding main without typing the thing out in the code, and if I did that inside the module, I don't know if that would work for the warning about the file handle in main. How does sort do it WRT $a and $b? And how wouyld I replicate that when I don't know the name of the handle?
So... if I put
no warnings 'once' inside my openOut sub in my module, are you saying that that would suppress warnings about *OUT (or whatever hard-coded handle the user creates) in main?
Here's a full example of a user's script who would be using my module (we'll call it Foo for now):
#!perl
use Foo qw(openOut);
openOut(*BAR,"~/output.txt");
print("Hello world!\n");
I do have a feature planned to possibly make the openOut method return an anonymous file handle. That would solve the problem, but it would create other problems, which I haven't worked out yet.
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.