in reply to Directory used % in Linux

Untested but "should work"

opendir $mydir, "/somedir"; chdir $mydir; print `du -ha $mydir`; closedir $mydir;
sh: 1: Syntax error: "(" unexpected

ups, or maybe not :-)

Well... this is awful, but works

perl -e 'system("du -ha /somedir");'

but this don't go, Opendir issue probably. I'm surely doing a very silly mistake

perl -e 'opendir (my $dir, "/somedir"); chdir $dir; system ("du -ha $dir"); closedir $dir;'

Replies are listed 'Best First'.
Re^2: <p>Directory used % in Linux </p>
by Anonymous Monk on Jan 31, 2014 at 22:42 UTC
    a dirhandle is not a dirpath, you're using a system with a dirhandle, maybe you want '.' instead of $dir?

      Yup, you are right. But '.' was too trivial, that I wanted for my example the abstraction: "the current directory".

      With some delay, but a little research today led me to the solution. It was more easy than expected.

      use Cwd qw(); use strict; my $current = Cwd::cwd(); print `du -ha $current\n`;