jonasbn has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w # $Id: version.pl,v 1.2 2003/05/14 19:44:28 jonasbn Exp $ use strict; my $modulename = shift; my $modulepath = $modulename; if ($modulepath =~ m/::/) { $modulepath =~ s[::][/]g; require "$modulepath.pm"; } else { undef $/; open(FIN, "<", $modulepath) || die ("Unable to open file $modulepa +th"); my $module = <FIN>; close(FIN); ($modulename) = $module =~ m/package (.*);/; require "$modulepath"; } my $str = '$'.$modulename.'::VERSION'; print "$modulename is version: "; print eval($str); print "\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: package name?
by bigj (Monk) on May 14, 2003 at 20:01 UTC | |
by jonasbn (Scribe) on Jun 05, 2003 at 07:35 UTC | |
by jonasbn (Scribe) on Dec 19, 2003 at 09:35 UTC |