in reply to Unusual way of accessing hash values

Thanks gaal and gellyfish! Didn't even know there was a perldiag :)
And of course using warnings would save me a lot of trouble in explaining some facts to my coworker!
  • Comment on Re: Unusual way of accessing hash values

Replies are listed 'Best First'.
Re^2: Unusual way of accessing hash values
by tlm (Prior) on May 05, 2005 at 13:20 UTC

    One other reason I sometimes temporarily turn on diagnostics is to find out what keyword to use when I want to selectively turn off a particular group of warnings. For example, in this case yo see that the body of the diagnostic message begins with (D deprecated). If for some reason I wanted to turn off such warnings in a suitably narrowed scope, I would do this:

    use strict; use warnings; # ... { no warnings 'deprecated'; %hash->{ silly } = 'foo'; }
    Granted, I can't think of any good reason for turning off this particular warning (except perhaps globally on a large body of legacy code), but there are more realistic examples. E.g.:
    use strict; use warnings; require Exporter; { no warnings 'once'; *import = \&Exporter::import; }
    The no warnings above silences a warning of the form
    Name "main::import" used only once: possible typo...

    Yes, one could silence this warning like this instead:

    *import = *import = \&Exporter::import;
    ...but I digress.

    the lowliest monk

Re^2: Unusual way of accessing hash values
by reasonablekeith (Deacon) on May 05, 2005 at 12:27 UTC
    If you're ever unsure as to what a warning means, you can ...
    use diagnostics;
    which would print the exact text as posted in the the first reply.

      Or pipe the error messages through the splain program.

      Man, it'd be great if the cow-orker in question was named "Lucy". Lucy, joo gots some splain'in to do!