Clean way to get size of directory
I agree with @rolfl that this would be much simpler as a one-line shell pipeline.  The -s option to du makes it produce a total.  awk is a good tool to use for processing multi-column text.

du -s --si | awk '$1 ~ /G/ { exit 1 }'


However, the --si option seems to be a non-portable GNU extension.  A more portable version would look at the number of 512-byte blocks.  The magic number 1953125 is \$\dfrac{10^9}{512}\$.

du -s | awk '$1 &lt; 1953125 { exit 1 }'


The second version also works even if the total is in the terabyte or exabyte range.



There is an inefficiency, though: you should be able to exit early as soon as you find that the total exceeds 1 GB.  For that, you would go back to Perl, but with a proper Perl program instead of a wrapper around du.

use File::Find;
use strict;

my $sum = 0;
my %seen_inodes;
find(sub {
    my ($inode, $blocks) = (stat)[1, 12] or die "${File::Find::name}: $!";

    # Do not double-count hard links
    if (!$seen_inodes{$inode}) {
        $seen_inodes{$inode} = 1;
        $sum += 512 * $blocks;
        exit 0 if $sum &gt;= 1_000_000_000;
    }
}, ".");
exit 1;