Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get file permissions get displayed through perl

Status
Not open for further replies.

khoont

Programmer
Mar 9, 2001
10
US
Hi,
how can i display the file in the current directory in the UNix to get displayed through Perl script. i m using File:: Find whcich gives you anem of the file but how to get the attribute of the file to be displayed
Nilesh
 
[tt]perldoc -f stat[/tt] "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
yes u are right,
but it doesnt supported in all file system.
not all unix supports that.
what i want is to get all filename as key and permissions as value into the hash.
thanks
 
Have a look at:

File::stat - by-name interface to Perl's built-in stat() functions

SUPPORTED PLATFORMS
Linux
Solaris
Windows

In the perl documentation. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
to make a hash like you want, you'll do something like:[tt]
my %files = ();
foreach (@the_files_you_found_with_File_Find) {
$files{$_} = (stat($_))[4];
}[/tt]

'4' is NOT the number you want, i just put it in for the fun of it.
Does stat work on your system? "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top