I'm not aware that it is possible. I have build hashrefs in the past to keep the two pieces of information together. In the simplest case, it looks something like this (warning, untested code ahead):
use IO::File;
my $file;
$file->{name} = '/tmp/foo';
$file->{fd} = IO::File->new( $file->{name} ) or die "$!\n"; # TODO:
+more explicit error message
# this lets me do stuff like
$file->{fd}->print( "The name of this file is $file->{name}\n" );
$file->{fd}->close();
But that means that you have to start passing these hashrefs around, instead of raw IO::File objects, so that may mean major surgery on your code.
And now I will probably be tarred and feathered for not knowing that the IO::File or one of its ancestors has some really useful method, like name() or something.
--g r i n d e r
just another bofh
print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u';
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.