Re: [Boston.pm] suppressing warnings
is there a way to suppress this warning from inside testpackage.pm somehow? I've tried a bunch of things and still haven't found a solution. Is this not possible to do in per? Or is it so obvious I can't see it? Greg package file testpackage.pm: package testpackage; use warnings; use strict; use Data::Dumper; use Exporter 'import'; our @EXPORT = qw ( somesub ); sub somesub{ my ($name)=@_; my @caller=caller(0); my $package=$caller[0]; my $evalstr = '$'.$package.'::'.$name.' = 42;'; eval($evalstr); } 1; script file testscript.pl: #!/usr/bin/env perl use warnings; use strict; use testpackage; somesub('tricky'); print hello, tricky is '$main::tricky'\n; When I run this script, I get the warning: Name main::tricky used only once: possible typo at ./testscript.pl is there a way to suppress this error from inside testpackage.pm somehow? ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm -- ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
Re: [Boston.pm] suppressing warnings
You can add some no-op-ish noise to sidestep the warning e.g; local $main::tricky; or use vars '$main::tricky'; ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
Re: [Boston.pm] suppressing warnings
Design issues aside, no warnings 'once'; Sent from my iPhone On May 4, 2013, at 3:47 PM, Greg London em...@greglondon.com wrote: is there a way to suppress this warning from inside testpackage.pm somehow? I've tried a bunch of things and still haven't found a solution. Is this not possible to do in per? Or is it so obvious I can't see it? Greg package file testpackage.pm: package testpackage; use warnings; use strict; use Data::Dumper; use Exporter 'import'; our @EXPORT = qw ( somesub ); sub somesub{ my ($name)=@_; my @caller=caller(0); my $package=$caller[0]; my $evalstr = '$'.$package.'::'.$name.' = 42;'; eval($evalstr); } 1; script file testscript.pl: #!/usr/bin/env perl use warnings; use strict; use testpackage; somesub('tricky'); print hello, tricky is '$main::tricky'\n; When I run this script, I get the warning: Name main::tricky used only once: possible typo at ./testscript.pl is there a way to suppress this error from inside testpackage.pm somehow? ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm -- ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
Re: [Boston.pm] suppressing warnings
On 04/05/2013 20:47, Greg London wrote: is there a way to suppress this warning from inside testpackage.pm somehow? ... #!/usr/bin/env perl use warnings; use strict; use testpackage; somesub('tricky'); print hello, tricky is '$main::tricky'\n; When I run this script, I get the warning: Name main::tricky used only once: possible typo at ./testscript.pl is there a way to suppress this error from inside testpackage.pm somehow? %SIG is global, so ... $SIG{__WARN__} = sub { my @args = @_; # do whatever you want with the warning } -- David Cantrell | semi-evolved ape-thing Today's previously unreported paraphilia is tomorrow's Internet sensation ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
Re: [Boston.pm] suppressing warnings
This pragma usage is lexically scoped, too. Sent from my iPhone On May 4, 2013, at 5:01 PM, Jordan Adler jordan.m.ad...@gmail.com wrote: Design issues aside, no warnings 'once'; Sent from my iPhone On May 4, 2013, at 3:47 PM, Greg London em...@greglondon.com wrote: is there a way to suppress this warning from inside testpackage.pm somehow? I've tried a bunch of things and still haven't found a solution. Is this not possible to do in per? Or is it so obvious I can't see it? Greg package file testpackage.pm: package testpackage; use warnings; use strict; use Data::Dumper; use Exporter 'import'; our @EXPORT = qw ( somesub ); sub somesub{ my ($name)=@_; my @caller=caller(0); my $package=$caller[0]; my $evalstr = '$'.$package.'::'.$name.' = 42;'; eval($evalstr); } 1; script file testscript.pl: #!/usr/bin/env perl use warnings; use strict; use testpackage; somesub('tricky'); print hello, tricky is '$main::tricky'\n; When I run this script, I get the warning: Name main::tricky used only once: possible typo at ./testscript.pl is there a way to suppress this error from inside testpackage.pm somehow? ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm -- ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
Re: [Boston.pm] suppressing warnings
If your module has an import method, and in that method calls warnings-unimport(once) then the unimport should be lexically scoped to where your package was used. Which in the normal case is the whole file, so it works. On Sat, May 4, 2013 at 2:07 PM, Jordan Adler jordan.m.ad...@gmail.com wrote: This pragma usage is lexically scoped, too. Sent from my iPhone On May 4, 2013, at 5:01 PM, Jordan Adler jordan.m.ad...@gmail.com wrote: Design issues aside, no warnings 'once'; Sent from my iPhone On May 4, 2013, at 3:47 PM, Greg London em...@greglondon.com wrote: is there a way to suppress this warning from inside testpackage.pm somehow? I've tried a bunch of things and still haven't found a solution. Is this not possible to do in per? Or is it so obvious I can't see it? Greg package file testpackage.pm: package testpackage; use warnings; use strict; use Data::Dumper; use Exporter 'import'; our @EXPORT = qw ( somesub ); sub somesub{ my ($name)=@_; my @caller=caller(0); my $package=$caller[0]; my $evalstr = '$'.$package.'::'.$name.' = 42;'; eval($evalstr); } 1; script file testscript.pl: #!/usr/bin/env perl use warnings; use strict; use testpackage; somesub('tricky'); print hello, tricky is '$main::tricky'\n; When I run this script, I get the warning: Name main::tricky used only once: possible typo at ./testscript.pl is there a way to suppress this error from inside testpackage.pm somehow? ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm -- ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm