Make eval statement naturally proof against perltidy
authorJohn Naylor <[email protected]>
Mon, 12 Sep 2022 04:59:43 +0000 (11:59 +0700)
committerJohn Naylor <[email protected]>
Mon, 12 Sep 2022 04:59:43 +0000 (11:59 +0700)
This is a bit less verbose than adding an exception. Rewrite
the other eval statement in Catalog.pm as well, just for
the sake of consistency.

Idea from Andrew Dunstan
Discussion: https://www.postgresql.org/message-id/CAD5tBc%2BzRhuWn_S4ayH2sWKe60FQu1guTTokDFS3YMOeSrsozA%40mail.gmail.com

src/backend/catalog/Catalog.pm

index 1546e1b33508f7cfb0b6fe3d57fab1cc21701ba5..919a828ca738d237d151c4a900b6cf6ff447e6a9 100644 (file)
@@ -315,10 +315,7 @@ sub ParseData
                    # We're treating the input line as a piece of Perl, so we
                    # need to use string eval here. Tell perlcritic we know what
                    # we're doing.
-                   #<<< protect next line from perltidy
-                   # so perlcritic annotation works
-                   eval '$hash_ref = ' . $_;    ## no critic (ProhibitStringyEval)
-                   #>>>
+                   eval "\$hash_ref = $_"; ## no critic (ProhibitStringyEval)
                    if (!ref $hash_ref)
                    {
                        die "$input_file: error parsing line $.:\n$_\n";
@@ -364,7 +361,7 @@ sub ParseData
        # the whole file at once.
        local $/;
        my $full_file = <$ifd>;
-       eval '$data = ' . $full_file    ## no critic (ProhibitStringyEval)
+       eval "\$data = $full_file"    ## no critic (ProhibitStringyEval)
          or die "error parsing $input_file\n";
        foreach my $hash_ref (@{$data})
        {