subroutine redefined warning

Discussion in 'Perl Misc' started by jyothsna, Oct 4, 2005.

  1. jyothsna

    jyothsna Guest

    How to avoid "subroutine redefined" warning in perl.
    what are the possible cases of getting this warning and avoid it.
     
    jyothsna, Oct 4, 2005
    #1
    1. Advertising

  2. jyothsna

    Guest

    jyothsna wrote:
    > How to avoid "subroutine redefined" warning in perl.
    > what are the possible cases of getting this warning and avoid it.



    The warning is issued because you redefined a
    subroutine.

    You can turn off the warning.
    See perldoc perlexwarn.

    For example:

    use strict;
    use warnings;

    use vars qw(*foo);

    sub bar {
    print "bar";
    }


    {
    no warnings 'redefine';
    local *bar = sub {
    print "foo";
    };
    bar();
    }

    bar();

    --
    Hope this helps,
    Steven
     
    , Oct 4, 2005
    #2
    1. Advertising

  3. jyothsna

    Paul Lalli Guest

    wrote:
    > jyothsna wrote:
    > > How to avoid "subroutine redefined" warning in perl.
    > > what are the possible cases of getting this warning and avoid it.

    >
    >
    > The warning is issued because you redefined a
    > subroutine.
    >
    > You can turn off the warning.


    I would wager that about 9 times out of 10, this is the equivalent of
    sticking your fingers in your ears and shouting "LA LA LA I CAN'T HEAR
    YOU!!".

    Don't ignore warnings. Fix them.

    Figure out where you're redefining the subroutine (read the WHOLE
    warning message, including the parts about line numbers and filenames),
    and then decide if that's really something you wanted to do.

    Paul Lalli
     
    Paul Lalli, Oct 4, 2005
    #3
  4. jyothsna

    Guest

    "jyothsna" <> wrote:
    > How to avoid "subroutine redefined" warning in perl.


    Don't redefine your subroutine. Or turn off the warning.

    > what are the possible cases of getting this warning and avoid it.


    I usually get this warning when I abstract some common subroutine out of
    many scripts, and put it into a central module. But then I find/run some
    scripts which I forgot to abstract it out of, so it gets defined once in
    the module and once in the script itself.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Oct 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Strandgaard
    Replies:
    0
    Views:
    108
    Simon Strandgaard
    Feb 23, 2004
  2. Brian Takita

    Removing "warning: method redefined"

    Brian Takita, Jul 8, 2005, in forum: Ruby
    Replies:
    4
    Views:
    107
    Brian Takita
    Jul 8, 2005
  3. MiG
    Replies:
    8
    Views:
    156
    Ryan Leavengood
    Oct 19, 2005
  4. bill

    'Subroutine redefined' annoyance

    bill, Feb 7, 2005, in forum: Perl Misc
    Replies:
    10
    Views:
    249
    Anno Siegel
    Feb 8, 2005
  5. Marc Girod
    Replies:
    5
    Views:
    368
    Marc Girod
    Feb 16, 2011
Loading...

Share This Page