Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^6: Constant subroutine main::C redefined (diag)

by tye (Sage)
on Sep 10, 2012 at 14:04 UTC ( [id://992769]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Constant subroutine main::C redefined
in thread Constant subroutine main::C redefined

perldiag says "(S) A severe warning (enabled by default)." which is probably part of the problem. But it is still easy to get around in a couple of different ways:

#!/usr/bin/perl -w BEGIN { $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /^Constant subroutine/; } } sub FOO() { 23 } sub FOO() { 42 }

Or

#!/usr/bin/perl -w sub FOO() { 23 } BEGIN { no warnings 'misc'; undef &FOO if ! @ARGV } sub FOO() { 42 }

I threw in the 'if ! @ARGV' just so one can see the warning produced or suppressed by the same code.

- tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://992769]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found