From fa6e78f4955d541cf0600f72e522c9a62e432f5b Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Fri, 17 Jul 2015 15:40:15 +0300 Subject: [PATCH] Make perlcritic a bit happier --- lib/Pod/Constants.pm | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/Pod/Constants.pm b/lib/Pod/Constants.pm index 80c2eab..05f33a0 100644 --- a/lib/Pod/Constants.pm +++ b/lib/Pod/Constants.pm @@ -30,26 +30,26 @@ sub end_input { $parser->{paragraphs} =~ s/^\s*|\s*$//gs if $parser->{trimmed_tags}->{$parser->{active}}; - if (ref $whereto eq "CODE") { + if (ref $whereto eq 'CODE') { print "calling sub\n" if $parser->{DEBUG}; local ($_) = $parser->{paragraphs}; $whereto->(); print "done\n" if $parser->{DEBUG}; - } elsif (ref $whereto eq "SCALAR") { + } elsif (ref $whereto eq 'SCALAR') { print "inserting into scalar\n" if $parser->{DEBUG}; $$whereto = $parser->{paragraphs}; - } elsif (ref $whereto eq "ARRAY") { + } elsif (ref $whereto eq 'ARRAY') { print "inserting into array\n" if $parser->{DEBUG}; @$whereto = split /\n/, $parser->{paragraphs}; - } elsif (ref $whereto eq "HASH") { + } elsif (ref $whereto eq 'HASH') { print "inserting into hash\n" if $parser->{DEBUG}; # Oh, sorry, should I be in LISP101? %$whereto = ( - map { map { s/^\s*|\s*$//g; $_ } split /=>/, $_ } grep m/^ + map { map { s/^\s*|\s*$//g; $_ } split /=>/ } grep m/^ ( (?:[^=]|=[^>])+ ) # scan up to "=>" => ( (?:[^=]|=[^>])+ =? )# don't allow more "=>"'s - $/x, split /\n/, $parser->{paragraphs}); + $/x, split /\n/, $parser->{paragraphs},); } else { die $whereto } $parser->{active} = undef; } @@ -99,7 +99,7 @@ sub verbatim { my ($parser, $paragraph, $line_num) = @_; $paragraph =~ s/(?:\r\n|\n\r)/\n/g; - my $status = $parser->{active} ? "using" : "ignoring"; + my $status = $parser->{active} ? 'using' : 'ignoring'; print "Got paragraph: $paragraph ($status)\n" if $parser->{DEBUG}; $parser->{paragraphs} .= $paragraph if defined $parser->{active} @@ -116,8 +116,8 @@ sub import { # try to guess the source file of the caller my $source_file; - if (caller ne "main") { - (my $module = caller().".pm") =~ s|::|/|g; + if (caller ne 'main') { + (my $module = caller.'.pm') =~ s|::|/|g; $source_file = $INC{$module}; } $source_file ||= $0; @@ -145,7 +145,7 @@ sub import_from_file { $parser->add_hook(@_); print "Pod::Parser: DEBUG: Opening $filename for reading\n" if $parser->{DEBUG}; - open my $fh, "<$filename" or die "cannot open $filename for reading; $!"; + open my $fh, '<', $filename or croak "cannot open $filename for reading; $!"; $parser->parse_from_filehandle($fh, \*STDOUT); @@ -154,18 +154,18 @@ sub import_from_file { sub add_hook { my $parser; - if (UNIVERSAL::isa($_[0], __PACKAGE__)) { + if (eval { $_[0]->isa(__PACKAGE__) }) { $parser = shift; } else { - $parser = $parsers{caller()} or die "add_hook called, but don't know what for - caller = ".caller; + $parser = $parsers{caller()} or croak 'add_hook called, but don\'t know what for - caller = '.caller; } while (my ($pod_tag, $var) = splice @_, 0, 2) { #print "$pod_tag: $var\n"; - if (lc($pod_tag) eq "-trim") { + if (lc($pod_tag) eq '-trim') { $parser->{trim_next} = $var; - } elsif ( lc($pod_tag) eq "-debug" ) { + } elsif ( lc($pod_tag) eq '-debug' ) { $parser->{DEBUG} = $var; - } elsif (lc($pod_tag) eq "-usage") { + } elsif (lc($pod_tag) eq '-usage') { # an idea for later - automatic "usage" #%wanted_pod_tags{@tags} } else { @@ -174,7 +174,7 @@ sub add_hook { $parser->{wanted_pod_tags}->{$pod_tag} = $var; $parser->{trimmed_tags}->{$pod_tag} = 1 if $parser->{trim_next}; } else { - die "Sorry - need a reference to import POD sections into, not the scalar value $var" + croak "Sorry - need a reference to import POD sections into, not the scalar value $var" } } } @@ -182,10 +182,10 @@ sub add_hook { sub delete_hook { my $parser; - if ( UNIVERSAL::isa($_[0], __PACKAGE__) ) { + if (eval { $_[0]->isa(__PACKAGE__) }) { $parser = shift; } else { - $parser = $parsers{caller()} or die "delete_hook called, but don't know what for - caller = ".caller; + $parser = $parsers{caller()} or croak 'delete_hook called, but don\'t know what for - caller = '.caller; } while ( my $label = shift ) { delete $parser->{wanted_pod_tags}->{$label}; @@ -193,7 +193,7 @@ sub delete_hook { } } -1.4142; +1; __END__ =encoding utf-8 -- 2.39.2