Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > subroutine redefined warning

Reply
Thread Tools

subroutine redefined warning

 
 
jyothsna
Guest
Posts: n/a
 
      10-04-2005
How to avoid "subroutine redefined" warning in perl.
what are the possible cases of getting this warning and avoid it.

 
Reply With Quote
 
 
 
 
attn.steven.kuo@gmail.com
Guest
Posts: n/a
 
      10-04-2005
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

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      10-04-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      10-04-2005
"jyothsna" <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subroutine exec redefined warning with perl 5.12.2 Marc Girod Perl Misc 5 02-16-2011 12:23 PM
Array.sort when it's items are String inheritors with redefined <=> works like if not redefined MiG Ruby 8 10-19-2005 03:48 PM
Removing "warning: method redefined" Brian Takita Ruby 4 07-08-2005 04:36 PM
'Subroutine redefined' annoyance bill Perl Misc 10 02-08-2005 08:51 PM
delegate.rb:110: warning: method redefined; discarding old __getobj__ Simon Strandgaard Ruby 0 02-23-2004 06:28 PM



Advertisments