Lister les répertoires

From Tuxunix
Jump to: navigation, search

Exemple


$./listeRep.pl ../
../C
../C++
../Cours
../FreeBSD_6.2


Code


1.#!/usr/bin/perl 
2. 	 
3.# 
4.#@Name          listeRep.pl 
5.#@Authors       Tuxedo 
6.#@Date          08/08/2007 
7.#@Brief         Unknow 
8.#@Note          liste les rep du repertoire donn� en argument 
9.# 
10. 	 
11.# 
12.#Includes 
13.# 
14.use strict; 
15. 
16.!($ARGV[0]) ? die("usage: $0 \n") : '' ; 
17.
18.#delete last caractere "/" if exist 
19.if( "$ARGV[0]" =~ /\/$/){ chop($ARGV[0]); } 
20.
21.    foreach (<$ARGV[0]/*>){ 
22.        next if(! -d $_); 
23.        print("$_" . "\n"); 
24.    }