Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

testing mac file attributes

by wrinkles (Pilgrim)
on Jan 20, 2012 at 04:54 UTC ( #948885=perlquestion: print w/replies, xml ) Need Help??
wrinkles has asked for the wisdom of the Perl Monks concerning the following question:

On my mac (10.7) the file conditionals -f and -d and -e give false when the "@" attribute is present. I believe the "@" is used to mark files downloaded from the internet. How do I test these SOBs? TIA
Update: I tried Test::Dir with dir_exists_ok(), which returned "not ok" for the directories with the "@" attribute. I'm still open for suggestions...
#!/usr/bin/env perl use warnings; use strict; use 5.010; my @dirs; my $dh; opendir ($dh, '/home/setup_scripts/mt') or die "Cannot open dir - $!"; @dirs = grep {-d $_} readdir $dh ; print "@dirs \n"; close $dh; opendir ($dh, '/home/setup_scripts/mt') or die "Cannot open dir - $!"; @dirs = readdir $dh ; print "@dirs \n"; close $dh;
. .. . .. .DS_Store MTOS-4.37-en
If I change "-d" to "-f" I see this:
.DS_Store . .. .DS_Store MTOS-4.37-en
Using -e:
. .. .DS_Store . .. .DS_Store MTOS-4.37-en
mac-pro:setup_scripts wrinkles$ ls -al mt total 11536 drwxr-xr-x 5 wrinkles staff 170 Jan 19 13:22 . drwxr-xr-x 12 wrinkles staff 408 Jan 19 20:32 .. -rw-r--r--@ 1 wrinkles staff 6148 Jan 19 20:04 .DS_Store drwxr-xr-x@ 29 wrinkles staff 986 Jun 21 2011 MTOS-4.37-en -rw-r--r--@ 1 wrinkles staff 5895060 Sep 3 22:22

Replies are listed 'Best First'.
Re: testing mac file attributes
by Anonymous Monk on Jan 20, 2012 at 09:43 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://948885]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2018-07-20 02:35 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (422 votes). Check out past polls.