Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Perl one liner and stat function

by samtregar (Abbot)
on Mar 23, 2009 at 22:10 UTC ( #752735=note: print w/replies, xml ) Need Help??


in reply to Perl one liner and stat function

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://752735]
help
Chatterbox?
[LanX]: machiato!
shmem fills a glas with sambuca, drops 3 beans of coffee into it, lights the stuff and hands it to erix
[Your Mother]: Liquore Strega. :P
[shmem]: s/beans of coffee/enterprise beans/ :-P
[erix]: Take your bottles -- you're all invited! :)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-03-28 12:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (330 votes). Check out past polls.