SPUG: Re: How to get pwd (current dir name)?

Michael R. Wolf MichaelRunningWolf at att.net
Thu Jan 2 01:42:24 CST 2003


Jeremy Mates <jmates at sial.org> writes:

[...]

> There are probably modules, or one can drag the information from
> stat(2) kicking and screaming.  Figuratively.
> 
> sub print_file_type {
>   my $file = shift;
> 
>   my %st_mode_map = (
>     '010000' => 'named pipe (fifo)',
>     '020000' => 'character special',
>     '040000' => 'directory',
>     '060000' => 'block special',
>     '100000' => 'file',
>     '120000' => 'link',
>     '140000' => 'socket',
>     '160000' => 'whiteout'
>   );

Whiteout!  What's whiteout?  I only know the answer because it was a
quiz question at the most recent Seattle SAGE group.  Do you?


>   my $mode = (lstat($file))[2];
>   my $type = sprintf("%06o", $mode & 0170000);
>   my $humantype = $st_mode_map{$type};
> 
>   print "$file $humantype $type $mode\n";
> }
> 
> -- 
> Jeremy Mates                                        http://www.sial.org/

You sneak!!!!

-- 
Michael R. Wolf
    All mammals learn by playing!
        MichaelRunningWolf at att.net


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list