[Perl] Re: glob/readdir
nothingmuch
nothingmuch at mac.com
Tue Aug 28 00:51:03 PDT 2001
thnx, dude, i'll try it if the non-module needing method will fail...
damn i love these lists.... too much info =D
Pinkhas Nisanov said at Ò[Perl] Re: glob/readdirÓ.
[27/08/2001 17:01:12]
> Hi,
>
> If you need to take directory content don't use "ls -l",
> better way is to use standard perl module "DirHandle"
> example:
>
> use DirHandle;
>
> my $dir = "/home/someuser";
> my $dh = new DirHandle;
> my @direntries = $dh->read( $dir );
> foreach my $fileentry ( @direntries )
> {
> if( -f "$dir/$fileentry )
> {
> print "$fileentry is file\n";
> }
> elsif( -d "$dir/$fileentry )
> {
> print "$fileentry is directory\n";
> }
> else
> {
> print "$fileentry is something else\n";
> }
> }
>
>
> Pinkhas
>
>
> ----- Original Message -----
> From: "nothingmuch" <nothingmuch at mac.com>
> To: <israel-pm-list at happyfunball.pm.org>; <perl at perl.org.il>
> Sent: Monday, August 27, 2001 2:17 PM
> Subject: glob/readdir
>
>
> > i need to be able to tell wether a listed file is a directory or
> normal
> > file...
> >
> > example of what i mean:
> >
> > in any shell when you do ls -l it outputs a list... on the leftmost
> > column is the file mode...
> >
> > -rwx-r--r-- file name yadda yadda
> > drwx-r--r-- directory name yadda yadda
> >
> > i need to be able to know the difference within perl...
> > -
> > to unsubscribe from israel-pm-list, do:
> > echo "unsubscribe israel-pm-list" | mail majordomo at hfb.pm.org
> >
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://www.perl.org.il/cgi/listinfo/perl
More information about the Perl
mailing list