Suppose you want to grab a different version of just one function. Say, you've updated code and now want to call a newer thing, but have not updated the entire file yet.
use Module v1.0 qw/foo bar/;
use Module v2.0 qw/baz/; # was not present in 1.0
That looks easy enough, and should work just fine. But, recall the handling of direct module calls, as opposed to calling through the imported hard link. If you write
Module::foo it will decide at run-time that it must mean foo v1.0 based on the caller.
So, what happens if you call Module::zippo, something that was not directly imported also? Should that assume v1.0 or v2.0?
Musings:
- make it illegal - goes against the concept of being able to "maintain" the client and adopt newer features as needed.
- use the first - makes sence from the perspective of not changing what already worked in the client.
- use the last - makes sence from the perspective that the last assignment to a variable (or change to a setting) is the one you see.
However, I'd prefer to avoid the problem and not have the issue come up. E.g. some way to spot-import by version without making the user wonder what happens to the caller's "in use" setting.
For example, use a general syntax for renaming the import and specifying which version you want, and not re-specify a indirect version argument:
use Module v1.0 qw/foo bar/;
use Module --rename => [\&baz, 'baz', v2.0];
Any ideas?
—John
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.