troubleshooting Question

Writing/calling a function in a module

Avatar of simonslr
simonslr asked on
Perl
3 Comments1 Solution194 ViewsLast Modified:
I have written a function (first ever!) in a Perl module as follows:

package AlertLib;

use Win32::TieRegistry;

############ Function to Determine Operating System
sub getopsysversion{
$Registry->Delimiter("/");
$UserKey = $Registry->{"/LMachine/SOFTWARE/Microsoft/Window NT/CurrentVersion/"} || die "Could not open CurrentVersion key";
return $UserKey ->{"CurrentVersion"};
}

This is in a file called alertlib.pm.

I am trying to call the function from a perl script (.pl extension) as follows:

use AlertLib;
$opsys_version = getopsysversion;
print $opsys_version;

I get the error:

AlertLib.pm did not return a true value at E:\Coas\Code\Scripts\Security\SetStandard.pl.

If I copy the function into the .pl script it works fine.

Please help a complete Perl novice!
ASKER CERTIFIED SOLUTION
Kim Ryan
IT Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros