I've been trying to find different IO functions for opening files, listing directories, getting file stats and such and have come up quite sort so far. Anyone know of a good perl module or some built-in stuff that does file and directory stuff with quite a few options?
Paul
Perl file IO sucks?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
It's been a while since I've used Perl last, so I looked it up:
Code: Select all
#!/usr/bin/perl
opendir(MYDIR, '/path/to/folder') or die("e;Unable to open directory.\n"e;);
while( $file = readdir( MYDIR ) )
{
if( -d $file )
{
print( $file . "e; directory.\n"e; );
}
else
{
($device, $inode, $fileinfo, $links, $userID, $groupID, $deviceID, $size, $access, $modify, $inodeChange, $prefIO, $IO) = stat($file);
print( $file . ' ' . $size . "e;\n"e; );
}
}