Well More Little Helpers

Had a power outage for most of the day today so just a short post carrying on from where my last post left off.

Again I figured I might as well add in a second function into my little mod this one parses a directory listing (very badly) and then prints out the English for it

I do not usually have much of a problem with file entries but I figure some people might be worse at it than me so here goes.

So I exposed 'parse_file_listing' in my mod and here is a sample


use ParseCHMOD;

my $chmod= ParseCHMOD->new();

$chmod->parse_file_listing('drwxr-xr-x 3 byterok dev 4096 Dec 17 11:23 hold');
$chmod->parse_file_listing('-rw-r--r-- 1 byterok dev 10 Mar 27 10:52 .profile');
$chmod->parse_file_listing('lrwxrwxrwx 1 root root 25 Dec 10 14:34 public_html -> /wwwveh/ssssss/byterock');
$chmod->parse_file_listing('drwxr-xr-x 3 byterok dev 4096 Mar 8 14:56 junk');

and the output
The listing 'drwxr-xr-x  3 byterok dev      4096 Dec 17 11:23 hold' is a 
Directory called hold
is owned by byterok 
is in group dev  
takes up     4096 bytes 
last updated on  Dec 17 11:23 
Owner can Read, Write & Execute the Directory!
Group members can Read & Execute the Directory!
Others can Read & Execute the Directory!
the chmod of this in bits would look like this: chmod 755 hold

The listing '-rw-r--r-- 1 byterok dev 10 Mar 27 10:52 .profile' is a
File called .profile
is hidden
is owned by byterok
is in group dev
takes up 10 bytes
last updated on Mar 27 10:52
Owner can Read & Write the File!
Group members can Only Read the File!
Others can Only Read the File!
the chmod of this in bits would look like this: chmod 644 .profile

The listing 'lrwxrwxrwx 1 root root 25 Dec 10 14:34 public_html -> /wwwveh/ssssss/byterock' is a
Symbolic Link called public_html -> /wwwveh/ssssss/byterock
is owned by root
is in group root
takes up 25 bytes
last updated on Dec 10 14:34
Owner can Read, Write & Execute the Symbolic Link!
Group members can Read, Write & Execute the Symbolic Link!
Others can Read, Write & Execute the Symbolic Link!
the chmod of this in bits would look like this: chmod 777 public_html -> /wwwveh/ssssss/byterock

The listing 'drwxr-xr-x 3 byterok dev 4096 Mar 8 14:56 junk' is a
Directory called junk
is owned by byterok
is in group dev
takes up 4096 bytes
last updated on Mar 8 14:56
Owner can Read, Write & Execute the Directory!
Group members can Read & Execute the Directory!
Others can Read & Execute the Directory!
the chmod of this in bits would look like this: chmod 755 junk

Most likely the only thing useful is the last line in the each entry that tell me what the chmod command would be to set up the present permissions.

Well not going to win the programmer of the year for this one but it is something that may be useful to someone, I did learn a little while writing it.

Of course there is most likely a very good file listing parser on cpan that takes into account all the stuff I left out like operating system, socket and door file types, time zones etc etc. The list goes on and on.

So to get back on my AD&D track and to compensate for this half ass post here is a pic of every adolescent male AD&D dream player.

hope-400x500.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations