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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vyona
    New Member
    • Feb 2008
    • 6

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

    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.
  • manimarank
    New Member
    • Jul 2007
    • 23

    #2
    Originally posted by vyona
    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",Pe rl
    reports a clash.

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      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:

      Code:
      sub foo ($$) {
      just use a regular function:

      Code:
      sub foo {
      unless you really do need a prototype for some good reason.

      Comment

      • vyona
        New Member
        • Feb 2008
        • 6

        #4
        Originally posted by manimarank
        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",Pe rl
        reports a clash.

        Hi Manimarank,

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

        [CODE=perl]#line 1
        package Module::Install ;

        # For any maintainers:
        # The load order for Module::Install is a bit magic.
        # It goes something like this...
        #
        # IF ( host has Module::Install installed, creating author mode ) {
        # 1. Makefile.PL calls "use inc::Module::In stall"
        # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::In
        stall
        # 3. The installed version of inc::Module::In stall loads
        # 4. inc::Module::In stall calls "require Module::Install "
        # 5. The ./inc/ version of Module::Install loads
        # } ELSE {
        # 1. Makefile.PL calls "use inc::Module::In stall"
        # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install
        # 3. The ./inc/ version of Module::Install loads
        # }

        use 5.004;
        use strict 'vars';

        use vars qw{$VERSION};
        BEGIN {
        # All Module::Install core packages now require synchronised versions.
        # This will be used to ensure we don't accidentally load old or
        # different versions of modules.
        # This is not enforced yet, but will be some time in the next few
        # releases once we can make sure it won't clash with custom
        # Module::Install extensions.
        $VERSION = '0.64';
        }

        # Whether or not inc::Module::In stall is actually loaded, the
        # $INC{inc/Module/Install.pm} is what will still get set as long as
        # the caller loaded module this in the documented manner.
        # If not set, the caller may NOT have loaded the bundled version, and thus
        # they may not have a MI version that works with the Makefile.PL. This would
        # result in false errors or unexpected behaviour. And we don't want that.
        my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
        unless ( $INC{$file} ) {
        die <<"END_DIE";
        Please invoke ${\__PACKAGE__} with:

        use inc::${\__PACKA GE__};

        not:

        use ${\__PACKAGE__} ;

        END_DIE
        }

        # If the script that is loading Module::Install is from the future,
        # then make will detect this and cause it to re-run over and over
        # again. This is bad. Rather than taking action to touch it (which
        # is unreliable on some platforms and requires write permissions)
        # for now we should catch this and refuse to run.
        if ( -f $0 and (stat($0))[9] > time ) {
        die << "END_DIE";
        Your installer $0 has a modification time in the future.

        This is known to create infinite loops in make.

        Please correct this, then run $0 again.

        END_DIE
        }

        use Cwd ();
        use File::Find ();
        use File::Path ();
        use FindBin;

        *inc::Module::I nstall::VERSION = *VERSION;
        @inc::Module::I nstall::ISA = __PACKAGE__;

        sub autoload {
        my $self = shift;
        my $who = $self->_caller;
        my $cwd = Cwd::cwd();
        my $sym = "${who}::AUTOLO AD";
        $sym->{$cwd} = sub {
        my $pwd = Cwd::cwd();
        if ( my $code = $sym->{$pwd} ) {
        # delegate back to parent dirs
        goto &$code unless $cwd eq $pwd;
        }
        $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
        unshift @_, ($self, $1);
        goto &{$self->can('call')} unless uc($1) eq $1;
        };
        }

        sub import {
        my $class = shift;
        my $self = $class->new(@_);
        my $who = $self->_caller;

        unless ( -f $self->{file} ) {
        require "$self->{path}/$self->{dispatch}.pm" ;
        File::Path::mkp ath("$self->{prefix}/$self->{author}");
        $self->{admin} = "$self->{name}::$sel f->{dispatch}"->new( _top => $self
        );
        $self->{admin}->init;
        @_ = ($class, _self => $self);
        goto &{"$self->{name}::import "};
        }

        *{"${who}::AUTO LOAD"} = $self->autoload;
        $self->preload;

        # Unregister loader and worker packages so subdirs can use them again
        delete $INC{"$self->{file}"};
        delete $INC{"$self->{path}.pm"};
        }

        sub preload {
        my ($self) = @_;

        unless ( $self->{extensions} ) {
        $self->load_extension s(
        "$self->{prefix}/$self->{path}", $self
        );
        }

        my @exts = @{$self->{extensions} };
        unless ( @exts ) {
        my $admin = $self->{admin};
        @exts = $admin->load_all_exten sions;
        }

        my %seen;
        foreach my $obj ( @exts ) {
        while (my ($method, $glob) = each %{ref($obj) . '::'}) {
        next unless $obj->can($method) ;
        next if $method =~ /^_/;
        next if $method eq uc($method);
        $seen{$method}+ +;
        }
        }

        my $who = $self->_caller;
        foreach my $name ( sort keys %seen ) {
        *{"${who}::$nam e"} = sub {
        ${"${who}::AUTO LOAD"} = "${who}::$name" ;
        goto &{"${who}::AUTO LOAD"};
        };
        }
        }

        sub new {
        my ($class, %args) = @_;

        # ignore the prefix on extension modules built from top level.
        my $base_path = Cwd::abs_path($ FindBin::Bin);
        unless ( Cwd::abs_path(C wd::cwd()) eq $base_path ) {
        delete $args{prefix};
        }

        return $args{_self} if $args{_self};

        $args{dispatch} ||= 'Admin';
        $args{prefix} ||= 'inc';
        $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author');
        $args{bundle} ||= 'inc/BUNDLES';
        $args{base} ||= $base_path;
        $class =~ s/^\Q$args{prefix }\E:://;
        $args{name} ||= $class;
        $args{version} ||= $class->VERSION;
        unless ( $args{path} ) {
        $args{path} = $args{name};
        $args{path} =~ s!::!/!g;
        }
        $args{file} ||= "$args{base }/$args{prefix}/$args{path}.pm" ;

        bless( \%args, $class );
        }

        sub call {
        my ($self, $method) = @_;
        my $obj = $self->load($method ) or return;
        splice(@_, 0, 2, $obj);
        goto &{$obj->can($method) };
        }

        sub load {
        my ($self, $method) = @_;

        $self->load_extension s(
        "$self->{prefix}/$self->{path}", $self
        ) unless $self->{extensions} ;

        foreach my $obj (@{$self->{extensions} }) {
        return $obj if $obj->can($method) ;
        }

        my $admin = $self->{admin} or die <<"END_DIE";
        The '$method' method does not exist in the '$self->{prefix}' path!
        Please remove the '$self->{prefix}' directory and run $0 again to load it.
        END_DIE

        my $obj = $admin->load($method , 1);
        push @{$self->{extensions} }, $obj;

        $obj;
        }

        sub load_extensions {
        my ($self, $path, $top) = @_;

        unless ( grep { lc $_ eq lc $self->{prefix} } @INC ) {
        unshift @INC, $self->{prefix};
        }

        foreach my $rv ( $self->find_extension s($path) ) {
        my ($file, $pkg) = @{$rv};
        next if $self->{pathnames}{$p kg};

        local $@;
        my $new = eval { require $file; $pkg->can('new') };
        unless ( $new ) {
        warn $@ if $@;
        next;
        }
        $self->{pathnames}{$p kg} = delete $INC{$file};
        push @{$self->{extensions} }, &{$new}($pkg , _top => $top );
        }

        $self->{extensions} ||= [];
        }

        sub find_extensions {
        my ($self, $path) = @_;

        my @found;
        File::Find::fin d( sub {
        my $file = $File::Find::na me;
        return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
        my $subpath = $1;
        return if lc($subpath) eq lc($self->{dispatch});

        $file = "$self->{path}/$subpath.pm";
        my $pkg = "$self->{name}::$subpa th";
        $pkg =~ s!/!::!g;

        # If we have a mixed-case package name, assume case has been preserved
        # correctly. Otherwise, root through the file to locate the case-preser
        ved
        # version of the package name.
        if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
        open PKGFILE, "<$subpath. pm" or die "find_extension s: Can't open $su
        bpath.pm: $!";
        my $in_pod = 0;
        while ( <PKGFILE> ) {
        $in_pod = 1 if /^=\w/;
        $in_pod = 0 if /^=cut/;
        next if ($in_pod || /^=cut/); # skip pod text
        next if /^\s*#/; # and comments
        if ( m/^\s*package\s+( $pkg)\s*;/i ) {
        $pkg = $1;
        last;
        }
        }
        close PKGFILE;
        }

        push @found, [ $file, $pkg ];
        }, $path ) if -d $path;

        @found;
        }

        sub _caller {
        my $depth = 0;
        my $call = caller($depth);
        while ( $call eq __PACKAGE__ ) {
        $depth++;
        $call = caller($depth);
        }
        return $call;
        }

        1;[/CODE]



        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!
        Last edited by eWish; Feb 29 '08, 12:51 PM. Reason: Please use code tags

        Comment

        • vyona
          New Member
          • Feb 2008
          • 6

          #5
          Originally posted by KevinADC
          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:

          Code:
          sub foo ($$) {
          just use a regular function:

          Code:
          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!

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            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.

            Comment

            • vyona
              New Member
              • Feb 2008
              • 6

              #7
              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.cpanelconfi g.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.

              Comment

              • KevinADC
                Recognized Expert Specialist
                • Jan 2007
                • 4092

                #8
                Originally posted by vyona
                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.cpanelconfi g.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.

                Comment

                • vyona
                  New Member
                  • Feb 2008
                  • 6

                  #9
                  Originally posted by KevinADC
                  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 :)

                  Comment

                  Working...