[sf-perl] use {strict,warnings}

Kevin Frost biztos at mac.com
Tue Mar 4 09:46:09 PST 2008


That's a cool trick but it only works if the underlying module doesn't  
use warnings.

--snip (Foo.pm)--
package Foo;

use strict;
use warnings;

sub bar {

     my ( $class, $val ) = @_;
     return "you said '$val'";
}

1;
--snip (Bar.pm)--
package Bar;

use Foo;

sub baz {

     my $class = shift;

     my $result = $class->_sloppy_operation;
     return Foo->bar($result);

}

sub _sloppy_operation {

     return;

}

1;
--snip--

Then, alas, this throws a warning:

use Bar;

use strict;
use warnings;

my $x = Bar->baz();

-- frosty

On Mar 3, 2008, at 7:26 PM, Rich Morin wrote:

> At 03:43 -0800 3/3/08, frosty wrote:
>> The problem with *not* doing that is there is plenty of
>> CPAN code that spews warnings all over your log files if
>> you happen to have any.
>
>  ...
>  use this;      # Look, Ma...
>  use that;      # No warnings!
>  ...
>  use strict;
>  use warnings;
>  ...
>
> -r
> -- 
> http://www.cfcl.com/rdm            Rich Morin
> http://www.cfcl.com/rdm/resume     rdm at cfcl.com
> http://www.cfcl.com/rdm/weblog     +1 650-873-7841


More information about the SanFrancisco-pm mailing list