Skip to content

Warning "Name 'Pod::Usage::Formatter' used only once: possible typo" #32

Description

@scfc

When running perl -Mwarnings=FATAL,all -c blib/script/pod2usage, a warning is issued:

$ perl -Mwarnings=FATAL,all -c blib/script/pod2usage 
Name "Pod::Usage::Formatter" used only once: possible typo at blib/script/pod2usage line 137.
$

This warning can be silenced with:

diff --git a/scripts/pod2usage.PL b/scripts/pod2usage.PL
index 9d79043..f27eea3 100644
--- a/scripts/pod2usage.PL
+++ b/scripts/pod2usage.PL
@@ -169,7 +169,10 @@ my @opt_specs = (
 
 ## Parse options
 GetOptions(\%options, @opt_specs)  ||  pod2usage(2);
-$Pod::Usage::Formatter = $options{formatter} if $options{formatter};
+{
+    no warnings 'once';
+    $Pod::Usage::Formatter = $options{formatter} if $options{formatter};
+}
 require Pod::Usage;
 Pod::Usage->import();
 pod2usage(1)  if ($options{help});

But this is a rather heavy solution for a very light problem, so if someone knows a more elegant way, I'd appreciate it. (I like all Perl scripts on my system to pass the perl -Mwarnings=FATAL,all -c check.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions