Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Perl one liner and stat functionby samtregar (Abbot) |
on Mar 23, 2009 at 22:10 UTC ( [id://752735]=note: print w/replies, xml ) | Need Help?? |
There's nothing about that line of code that works. The stat call is broken by the lack of quotes around /dir/filename. Then the rest is broken because stat() doesn't return an object, it returns an array. And even if it did return an object, the method calls wouldn't work because they're in the middle of a quoted string!
Here's a version that works: perl -le '@pv=stat("/dir/filename"); printf "%d,%d,%04o", $pv[4],$pv[5],$pv[2] & 07777;' The mode stuff is tricky - I took that bit-mask and format stuff from stat. -sam
In Section
Seekers of Perl Wisdom
|
|