my $catname = $1;
my $data = [];
+ if ($preserve_formatting)
+ {
# Scan the input file.
while (<$ifd>)
{
# with --full-tuples to print autogenerated entries, which seems like
# useful behavior for debugging.)
#
- # Only keep non-data strings if we are told to preserve formatting.
+ # Otherwise, we have a non-data string, which we need to keep in
+ # order to preserve formatting.
if (defined $hash_ref)
{
push @$data, $hash_ref if !$hash_ref->{autogenerated};
}
- elsif ($preserve_formatting)
+ else
{
push @$data, $_;
}
}
+ }
+ else
+ {
+ # When we only care about the contents, it's faster to read and eval
+ # the whole file at once.
+ local $/;
+ my $full_file = <$ifd>;
+ eval '$data = ' . $full_file ## no critic (ProhibitStringyEval)
+ or die "error parsing $input_file\n";
+ foreach my $hash_ref (@{$data})
+ {
+ AddDefaultValues($hash_ref, $schema, $catname);
+ }
+ }
+
close $ifd;
# If this is pg_type, auto-generate array types too.