469,343 Members | 5,478 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

Error: Prototype mismatch: sub main::prompt ($;$) vs none at inc/Module/Install.pm

6
Dear All,

This is my first time touching Perl. Could anyone explain what does the following error means and how could i resolve it?

"Prototype mismatch: sub main::prompt ($;$) vs none at inc/Module/Install.pm line 146."

Appreciate your help on this. Thanks a million.
Feb 29 '08 #1
8 10971
Dear All,

This is my first time touching Perl. Could anyone explain what does the following error means and how could i resolve it?

"Prototype mismatch: sub main::prompt ($;$) vs none at inc/Module/Install.pm line 146."

Appreciate your help on this. Thanks a million.

Hi,

It is look like You have probably defined a function named "prompt" elsewhere in your program, the install.pm module tries to export its function "prompt",Perl
reports a clash.
Feb 29 '08 #2
KevinADC
4,059 Expert 2GB
Never seen that error before but look into what manimarank suggests. On a side note, there is practically zero reasons to use prototypes in your perl scripts, I would just drop the prototyping, which is the () after a function name:

Expand|Select|Wrap|Line Numbers
  1. sub foo ($$) {
just use a regular function:

Expand|Select|Wrap|Line Numbers
  1. sub foo {
unless you really do need a prototype for some good reason.
Feb 29 '08 #3
vyona
6
Hi,

It is look like You have probably defined a function named "prompt" elsewhere in your program, the install.pm module tries to export its function "prompt",Perl
reports a clash.

Hi Manimarank,

Thanks for your reply. I have extracted the code from my program and attached below:

Expand|Select|Wrap|Line Numbers
  1. #line 1
  2. package Module::Install;
  3.  
  4. # For any maintainers:
  5. # The load order for Module::Install is a bit magic.
  6. # It goes something like this...
  7. #
  8. # IF ( host has Module::Install installed, creating author mode ) {
  9. #     1. Makefile.PL calls "use inc::Module::Install"
  10. #     2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::In
  11. stall
  12. #     3. The installed version of inc::Module::Install loads
  13. #     4. inc::Module::Install calls "require Module::Install"
  14. #     5. The ./inc/ version of Module::Install loads
  15. # } ELSE {
  16. #     1. Makefile.PL calls "use inc::Module::Install"
  17. #     2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install
  18. #     3. The ./inc/ version of Module::Install loads
  19. # }
  20.  
  21. use 5.004;
  22. use strict 'vars';
  23.  
  24. use vars qw{$VERSION};
  25. BEGIN {
  26.     # All Module::Install core packages now require synchronised versions.
  27.     # This will be used to ensure we don't accidentally load old or
  28.     # different versions of modules.
  29.     # This is not enforced yet, but will be some time in the next few
  30.     # releases once we can make sure it won't clash with custom
  31.     # Module::Install extensions.
  32.     $VERSION = '0.64';
  33. }
  34.  
  35. # Whether or not inc::Module::Install is actually loaded, the
  36. # $INC{inc/Module/Install.pm} is what will still get set as long as
  37. # the caller loaded module this in the documented manner.
  38. # If not set, the caller may NOT have loaded the bundled version, and thus
  39. # they may not have a MI version that works with the Makefile.PL. This would
  40. # result in false errors or unexpected behaviour. And we don't want that.
  41. my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
  42. unless ( $INC{$file} ) {
  43.     die <<"END_DIE";
  44. Please invoke ${\__PACKAGE__} with:
  45.  
  46.     use inc::${\__PACKAGE__};
  47.  
  48. not:
  49.  
  50.     use ${\__PACKAGE__};
  51.  
  52. END_DIE
  53. }
  54.  
  55. # If the script that is loading Module::Install is from the future,
  56. # then make will detect this and cause it to re-run over and over
  57. # again. This is bad. Rather than taking action to touch it (which
  58. # is unreliable on some platforms and requires write permissions)
  59. # for now we should catch this and refuse to run.
  60. if ( -f $0 and (stat($0))[9] > time ) {
  61.         die << "END_DIE";
  62. Your installer $0 has a modification time in the future.
  63.  
  64. This is known to create infinite loops in make.
  65.  
  66. Please correct this, then run $0 again.
  67.  
  68. END_DIE
  69. }
  70.  
  71. use Cwd        ();
  72. use File::Find ();
  73. use File::Path ();
  74. use FindBin;
  75.  
  76. *inc::Module::Install::VERSION = *VERSION;
  77. @inc::Module::Install::ISA     = __PACKAGE__;
  78.  
  79. sub autoload {
  80.     my $self = shift;
  81.     my $who  = $self->_caller;
  82.     my $cwd  = Cwd::cwd();
  83.     my $sym  = "${who}::AUTOLOAD";
  84.     $sym->{$cwd} = sub {
  85.         my $pwd = Cwd::cwd();
  86.         if ( my $code = $sym->{$pwd} ) {
  87.             # delegate back to parent dirs
  88.             goto &$code unless $cwd eq $pwd;
  89.         }
  90.         $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
  91.         unshift @_, ($self, $1);
  92.         goto &{$self->can('call')} unless uc($1) eq $1;
  93.     };
  94. }
  95.  
  96. sub import {
  97.     my $class = shift;
  98.     my $self  = $class->new(@_);
  99.     my $who   = $self->_caller;
  100.  
  101.     unless ( -f $self->{file} ) {
  102.         require "$self->{path}/$self->{dispatch}.pm";
  103.         File::Path::mkpath("$self->{prefix}/$self->{author}");
  104.         $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self
  105. );
  106.         $self->{admin}->init;
  107.         @_ = ($class, _self => $self);
  108.         goto &{"$self->{name}::import"};
  109.     }
  110.  
  111.     *{"${who}::AUTOLOAD"} = $self->autoload;
  112.     $self->preload;
  113.  
  114.     # Unregister loader and worker packages so subdirs can use them again
  115.     delete $INC{"$self->{file}"};
  116.     delete $INC{"$self->{path}.pm"};
  117. }
  118.  
  119. sub preload {
  120.     my ($self) = @_;
  121.  
  122.     unless ( $self->{extensions} ) {
  123.         $self->load_extensions(
  124.             "$self->{prefix}/$self->{path}", $self
  125.         );
  126.     }
  127.  
  128.     my @exts = @{$self->{extensions}};
  129.     unless ( @exts ) {
  130.         my $admin = $self->{admin};
  131.         @exts = $admin->load_all_extensions;
  132.     }
  133.  
  134.     my %seen;
  135.     foreach my $obj ( @exts ) {
  136.         while (my ($method, $glob) = each %{ref($obj) . '::'}) {
  137.             next unless $obj->can($method);
  138.             next if $method =~ /^_/;
  139.             next if $method eq uc($method);
  140.             $seen{$method}++;
  141.         }
  142.     }
  143.  
  144.     my $who = $self->_caller;
  145.     foreach my $name ( sort keys %seen ) {
  146.         *{"${who}::$name"} = sub {
  147.             ${"${who}::AUTOLOAD"} = "${who}::$name";
  148.             goto &{"${who}::AUTOLOAD"};
  149.         };
  150.     }
  151. }
  152.  
  153. sub new {
  154.     my ($class, %args) = @_;
  155.  
  156.     # ignore the prefix on extension modules built from top level.
  157.     my $base_path = Cwd::abs_path($FindBin::Bin);
  158.     unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) {
  159.         delete $args{prefix};
  160.     }
  161.  
  162.     return $args{_self} if $args{_self};
  163.  
  164.     $args{dispatch} ||= 'Admin';
  165.     $args{prefix}   ||= 'inc';
  166.     $args{author}   ||= ($^O eq 'VMS' ? '_author' : '.author');
  167.     $args{bundle}   ||= 'inc/BUNDLES';
  168.     $args{base}     ||= $base_path;
  169.     $class =~ s/^\Q$args{prefix}\E:://;
  170.     $args{name}     ||= $class;
  171.     $args{version}  ||= $class->VERSION;
  172.     unless ( $args{path} ) {
  173.         $args{path}  = $args{name};
  174.         $args{path}  =~ s!::!/!g;
  175.     }
  176.     $args{file}     ||= "$args{base}/$args{prefix}/$args{path}.pm";
  177.  
  178.     bless( \%args, $class );
  179. }
  180.  
  181. sub call {
  182.         my ($self, $method) = @_;
  183.         my $obj = $self->load($method) or return;
  184.         splice(@_, 0, 2, $obj);
  185.         goto &{$obj->can($method)};
  186. }
  187.  
  188. sub load {
  189.     my ($self, $method) = @_;
  190.  
  191.     $self->load_extensions(
  192.         "$self->{prefix}/$self->{path}", $self
  193.     ) unless $self->{extensions};
  194.  
  195.     foreach my $obj (@{$self->{extensions}}) {
  196.         return $obj if $obj->can($method);
  197.     }
  198.  
  199.     my $admin = $self->{admin} or die <<"END_DIE";
  200. The '$method' method does not exist in the '$self->{prefix}' path!
  201. Please remove the '$self->{prefix}' directory and run $0 again to load it.
  202. END_DIE
  203.  
  204.     my $obj = $admin->load($method, 1);
  205.     push @{$self->{extensions}}, $obj;
  206.  
  207.     $obj;
  208. }
  209.  
  210. sub load_extensions {
  211.     my ($self, $path, $top) = @_;
  212.  
  213.     unless ( grep { lc $_ eq lc $self->{prefix} } @INC ) {
  214.         unshift @INC, $self->{prefix};
  215.     }
  216.  
  217.     foreach my $rv ( $self->find_extensions($path) ) {
  218.         my ($file, $pkg) = @{$rv};
  219.         next if $self->{pathnames}{$pkg};
  220.  
  221.         local $@;
  222.         my $new = eval { require $file; $pkg->can('new') };
  223.         unless ( $new ) {
  224.             warn $@ if $@;
  225.             next;
  226.         }
  227.         $self->{pathnames}{$pkg} = delete $INC{$file};
  228.         push @{$self->{extensions}}, &{$new}($pkg, _top => $top );
  229.     }
  230.  
  231.     $self->{extensions} ||= [];
  232. }
  233.  
  234. sub find_extensions {
  235.     my ($self, $path) = @_;
  236.  
  237.     my @found;
  238.     File::Find::find( sub {
  239.         my $file = $File::Find::name;
  240.         return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
  241.         my $subpath = $1;
  242.         return if lc($subpath) eq lc($self->{dispatch});
  243.  
  244.         $file = "$self->{path}/$subpath.pm";
  245.         my $pkg = "$self->{name}::$subpath";
  246.         $pkg =~ s!/!::!g;
  247.  
  248.         # If we have a mixed-case package name, assume case has been preserved
  249.         # correctly.  Otherwise, root through the file to locate the case-preser
  250. ved
  251.         # version of the package name.
  252.         if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
  253.             open PKGFILE, "<$subpath.pm" or die "find_extensions: Can't open $su
  254. bpath.pm: $!";
  255.             my $in_pod = 0;
  256.             while ( <PKGFILE> ) {
  257.                 $in_pod = 1 if /^=\w/;
  258.                 $in_pod = 0 if /^=cut/;
  259.                 next if ($in_pod || /^=cut/);  # skip pod text
  260.                 next if /^\s*#/;               # and comments
  261.                 if ( m/^\s*package\s+($pkg)\s*;/i ) {
  262.                     $pkg = $1;
  263.                     last;
  264.                 }
  265.             }
  266.             close PKGFILE;
  267.         }
  268.  
  269.         push @found, [ $file, $pkg ];
  270.     }, $path ) if -d $path;
  271.  
  272.     @found;
  273. }
  274.  
  275. sub _caller {
  276.     my $depth = 0;
  277.     my $call  = caller($depth);
  278.     while ( $call eq __PACKAGE__ ) {
  279.         $depth++;
  280.         $call = caller($depth);
  281.     }
  282.     return $call;
  283. }
  284.  
  285. 1;


The error line :146 is the one that highlighted in bold above. I'm not sure how could i edit the error in this function. Could you please help? Many thanks again!
Feb 29 '08 #4
vyona
6
Never seen that error before but look into what manimarank suggests. On a side note, there is practically zero reasons to use prototypes in your perl scripts, I would just drop the prototyping, which is the () after a function name:

Expand|Select|Wrap|Line Numbers
  1. sub foo ($$) {
just use a regular function:

Expand|Select|Wrap|Line Numbers
  1. sub foo {
unless you really do need a prototype for some good reason.

Hello Kevin,

Thanks for your reply. My function seems more complicated so i really have no idea how could i edit it. I am actually trying to install a program called "Swatch". Below are the steps i have taken until i reached the error:
1. telnet into the server
2. type #bash
3. cd /usr/local/swatch-3.2.2
4. Run the following command:
perl Makefile.PL

I get the error while running the above command.
Today is my first day learning Perl. Really appreciate if you could guide me how to troubleshoot the error. Thanks a bunch!
Feb 29 '08 #5
KevinADC
4,059 Expert 2GB
I seriously doubt you want to go editing that module. The error must be getting generated for a good reason, editing it to try and remove the error could have unforseen consequences. The module has a large number of bugs reported on CPAN. Not sure what to make of this error you are getting but I think editing the module code is unadvisable until you understand what is really causing the error. Personally I have no idea what is going or how to even begin to fix the problem. Contact the module author and see if he responds.
Feb 29 '08 #6
vyona
6
Thanks for your advices. I plan to upgrade the Perl version from v5.6.1 to v5.8.8. Do you think that is a good idea? I found the link for the steps to upgrade Perl to version 5.8.8,

http://www.cpanelconfig.com/how-to/how-to-upgrade-perl-to-v588/

Need your expertise to advice if i could follow the above steps to upgrade my Perl version. Thanks again.
Feb 29 '08 #7
KevinADC
4,059 Expert 2GB
Thanks for your advices. I plan to upgrade the Perl version from v5.6.1 to v5.8.8. Do you think that is a good idea? I found the link for the steps to upgrade Perl to version 5.8.8,

http://www.cpanelconfig.com/how-to/how-to-upgrade-perl-to-v588/

Need your expertise to advice if i could follow the above steps to upgrade my Perl version. Thanks again.
A very good idea to upgrade. Perl 5.6 is considerably old, at least 10 years. Upgrade to Perl 5.8.8 or even 5.10, which is the newest version, but perl 5.8.8 is a very good choice.

Do you have root access to the computer you are going to upgrade? If not you can't do it, someone with root acess will have to do it.

I'm off to bed now (1:00AM here). Good night.
Feb 29 '08 #8
vyona
6
A very good idea to upgrade. Perl 5.6 is considerably old, at least 10 years. Upgrade to Perl 5.8.8 or even 5.10, which is the newest version, but perl 5.8.8 is a very good choice.

Do you have root access to the computer you are going to upgrade? If not you can't do it, someone with root acess will have to do it.

I'm off to bed now (1:00AM here). Good night.

Yes, i have the root acccess to the remote machine. So is it advisable for me to follow the steps in the link above for performing the upgrade?

Oops, not aware of it's late at your side now. Sorry, have a good sleep! Good night :)
Feb 29 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Marcus Schneider | last post: by
3 posts views Thread by Chris_147 | last post: by
3 posts views Thread by korean_dave | last post: by
reply views Thread by Gabriel Genellina | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.