Suppress "mytime redefined" message from Benchmark?

Discussion in 'Perl Misc' started by Jeff Boes, Mar 2, 2004.

  1. Jeff Boes

    Jeff Boes Guest

    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.)



    --
    Jeff Boes vox 269.226.9550 ext 24
    Database Engineer fax 269.349.9076
    Nexcerpt, Inc. http://www.nexcerpt.com
    ...Nexcerpt... Extend your Expertise
    Jeff Boes, Mar 2, 2004
    #1
    1. Advertising

  2. Jeff Boes () 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.



    --
    Web Work Wanted, Perl Projects Programmed, Database Development Done.

    I'm looking for telecommute projects. (Paying that is, various
    arrangements possible.)
    Malcolm Dew-Jones, Mar 2, 2004
    #2
    1. Advertising

  3. Jeff Boes <> wrote:
    > $ 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.

    --
    Darren Dunham
    Senior Technical Consultant TAOS http://www.taos.com/
    Got some Dr Pepper? San Francisco, CA bay area
    < This line left intentionally blank to confuse you. >
    Darren Dunham, Mar 2, 2004
    #3
  4. Jeff Boes 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.)


    The warnings pragma and the -w switch are incompatible.

    perldoc perllexwarn


    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn, Mar 2, 2004
    #4
  5. Jeff Boes wrote:
    >
    > $ 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;

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Mar 2, 2004
    #5
  6. Jeff Boes

    Jay Tilton Guest

    Darren Dunham <> wrote:

    : Jeff Boes <> wrote:
    : > $ 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.
    Jay Tilton, Mar 3, 2004
    #6
    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. Samik R
    Replies:
    4
    Views:
    3,060
    Samik R
    Dec 30, 2005
  2. Christian Seberino
    Replies:
    0
    Views:
    351
    Christian Seberino
    Oct 21, 2003
  3. Ian Bicking
    Replies:
    0
    Views:
    385
    Ian Bicking
    Oct 22, 2003
  4. John Nagle
    Replies:
    2
    Views:
    1,183
    John Nagle
    Jan 29, 2010
  5. Jim Freeze
    Replies:
    3
    Views:
    112
    WATANABE Hirofumi
    Feb 17, 2004
Loading...

Share This Page