in reply to Is there a way to reduce Data::Dumper's output size?

You could reprocess the dumper output before storing it by replacing any sequence of one (or two) or more spaces by a single space:
$dumper_output =~ s/ +/ /g;
The result will not be pretty, but you'll save quite a bit of space.

Or you could use a module more dedicated to what you want to do than Data::Dumper, such as, for example Storable, which produces a more compact output.

Update: crossed out my first suggestion because, as pointed out by Anonymous Monk below, it might mess things up is either keys or values of the hash have multiple spaces.

Je suis Charlie.

Replies are listed 'Best First'.
Re^2: Is there a way to reduce Data::Dumper's output size?
by Anonymous Monk on Feb 10, 2015 at 22:25 UTC
    $dumper_output =~ s/ +/ /g;

    Probably not a good idea...

    use Data::Dumper; my $dumper_output = Dumper({"foo bar"=>"quz\n baz"}); print $dumper_output; $dumper_output =~ s/ +/ /g; print $dumper_output; __END__ $VAR1 = { 'foo bar' => 'quz baz' }; $VAR1 = { 'foo bar' => 'quz baz' };
      Ooops, yes, you are quite right, I did not think of the cases where keys or values might have multiple spaces. This would usually not happen where I work (because we usually normalize keys and values), but, yes, there is a danger of messing things up. Thank you for for the comment.

      Je suis Charlie.
Re^2: Is there a way to reduce Data::Dumper's output size?
by tkguifan (Scribe) on Feb 11, 2015 at 05:15 UTC
    I'm trying Storable. Especially because the doc says: 'The heart of Storable is written in C for decent speed. Extra low-level optimization have been made when manipulating perl internals, to sacrifice encapsulation for the benefit of a greater speed.' My data gets so big that speed matters.
      You really should try Sereal.