I thought this would be really easy...how do I
Assuming you have a recent version of perl (I think 5.8.0 or higher,
maybe?), see:
perldoc if
Ah. Thanks. But I can't guarantee the users of my script will
have a specific version of perl.
Although I'm using 5.8.8 on win32 and 5.8.[67] on Linux/Solaris, I
don't think I can guarantee the level of my users. Some of whom
would rather not be using perl in the first place.
If you don't have that recent a version of perl, either download this
module from CPAN (
http://search.cpan.org/~ilyaz/if-0.0401/if.pm) or [...]
....similar issue. It would be better if I needn't force my users to
use a
module if it's not included everywhere.
Especially since I am sure there is a way to get this to work
without resorting to external code. (And there is, see below.)
or use an eval on the two separate components of a 'use'
statement. (See perldoc -f use)
Huh? What are the two separate components of a use?
use Module VERSION LIST? Require Module; import Module?
"does not work" is the worst of all possible error descriptions. *how*
does it not work? Syntax error? Runtime error? Incorrect output?
Computer blows up?
In fact, in this case, it must also be asked *what* does not work?
Where is the code that demonstrates what you tried? How can we help
you fix your code if you don't show us your code?
By "does not work" I meant "I was unable to include conditionally
a package." (I think that's the first paragraph of my post.)
But yes, the error message would have been helpful. Sorry about that.
To wit:
Can't locate win32/TieRegistry.pm in @INC (@INC contains: ...
I think we can agree that the Unix @INC contents are irrelevant?
And the code is in the subject line, mate.
Ahh, there's the old standby. "I can't figure out how to do this,
therefore it must not be possible." Do you even realize how supremely
arrogant that question is?
Not as arrogant as your reply.
Maybe I should have said 'cannot be trapped *by eval*.'
I'm sorry if I came across as arrogant. My intention was to show
that I'd RTFM'd. I thought I saw in perldoc -f eval that that eval()
doesn't trap compilation errors? But now I don't see the reference.
In any event:
eval {
use win32::TieRegstry;
}
Does not give me the chance to check if that eval worked, it just
crashes the script (with the @INC message.)
I'm 100% sure that it's something that I'm doing wrong, mate!
Please read the posting guidelines for this group. They will help you
to ask better questions and therefore to get better answers.
Point taken.
Thank you, Mertha, for a working example of what I'm trying to do.
For reference:
BEGIN {
if ($^O =~ /win32/i) {
require win32::TieRegistry;
}
else {
print "not on win32. So we'll parse files, not registry.\n";
}
}
Brian Shelden
(e-mail address removed)