Suppress "mytime redefined" message from Benchmark?

J

Jeff Boes

Hmm ... this one's got me puzzled:

$ perl -v


This is perl, v5.8.3 built for i686-linux

....

$ perl -w -e 'no warnings; use Benchmark qw:)hireswallclock)'
Subroutine Benchmark::mytime redefined at
/usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.

$ perl -w -e 'no warnings qw(redefine); use Benchmark qw:)hireswallclock)'
Subroutine Benchmark::mytime redefined at
/usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.


Does anyone know of a way to completely suppress this warning? It's
irritating, because I have a script running in cron that reports this
message, over and over. (I don't want to suppress or redirect STDERR,
because there may be other legitimate errors.)
 
M

Malcolm Dew-Jones

Jeff Boes ([email protected]) wrote:
: Hmm ... this one's got me puzzled:

: $ perl -v
:

: This is perl, v5.8.3 built for i686-linux

: ...

: $ perl -w -e 'no warnings; use Benchmark qw:)hireswallclock)'
: Subroutine Benchmark::mytime redefined at
: /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.

: $ perl -w -e 'no warnings qw(redefine); use Benchmark qw:)hireswallclock)'
: Subroutine Benchmark::mytime redefined at
: /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.


: Does anyone know of a way to completely suppress this warning? It's
: irritating, because I have a script running in cron that reports this
: message, over and over. (I don't want to suppress or redirect STDERR,
: because there may be other legitimate errors.)


$SIG{__WARN__}

Examine the warnings and skip the one you don't want.
 
D

Darren Dunham

Jeff Boes said:
$ perl -w -e 'no warnings; use Benchmark qw:)hireswallclock)'
Subroutine Benchmark::mytime redefined at
/usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
$ perl -w -e 'no warnings qw(redefine); use Benchmark qw:)hireswallclock)'
Subroutine Benchmark::mytime redefined at
/usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.

Both of those attempts won't work because the 'no warnings' isn't read
until runtime, while the 'use' is done earlier.

Is this a bug with Benchmark? I suppose you could report it.

Add your 'no warnings qw(redefine)' to Benchmark.pm between 455 and 456.
 
J

John W. Krahn

Jeff said:
Hmm ... this one's got me puzzled:

$ perl -v

This is perl, v5.8.3 built for i686-linux

$ perl -w -e 'no warnings; use Benchmark qw:)hireswallclock)'
Subroutine Benchmark::mytime redefined at
/usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.

$ perl -w -e 'no warnings qw(redefine); use Benchmark qw:)hireswallclock)'
Subroutine Benchmark::mytime redefined at
/usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.

Does anyone know of a way to completely suppress this warning? It's
irritating, because I have a script running in cron that reports this
message, over and over. (I don't want to suppress or redirect STDERR,
because there may be other legitimate errors.)

The warnings pragma and the -w switch are incompatible.

perldoc perllexwarn


John
 
G

Gunnar Hjalmarsson

Jeff said:
$ perl -w -e 'no warnings; use Benchmark qw:)hireswallclock)'
Subroutine Benchmark::mytime redefined at
/usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.

Does anyone know of a way to completely suppress this warning? It's
irritating, because I have a script running in cron that reports
this message, over and over. (I don't want to suppress or redirect
STDERR, because there may be other legitimate errors.)

The -w switch is dynamically scoped, which means that it enables all
kinds of warnings also in modules that you use or require. The
warnings pragma is lexically scoped, so 'no warnings' only switches
off the warnings in the current file.

I suppose that the best solution is to drop the -w switch and enable
warnings lexically by doing

use warnings;
 
J

Jay Tilton

: > $ perl -w -e 'no warnings; use Benchmark qw:)hireswallclock)'
: > Subroutine Benchmark::mytime redefined at
: > /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
:
: > $ perl -w -e 'no warnings qw(redefine); use Benchmark qw:)hireswallclock)'
: > Subroutine Benchmark::mytime redefined at
: > /usr/local/lib/perl5/5.8.3/Benchmark.pm line 456.
:
: Both of those attempts won't work because the 'no warnings' isn't read
: until runtime, while the 'use' is done earlier.

Poppycock. 'use' and 'no' both happen during compilation.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top