Welcome, Guest
Username Password: Remember me

How to Open Directory and read and display all the file using perl
(1 viewing) (1) Guest
Perl Script
  • Page:
  • 1

TOPIC: How to Open Directory and read and display all the file using perl

How to Open Directory and read and display all the file using perl 9 months, 2 weeks ago #709

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44562
  • Karma: 4
  • Honor Medal 2009
Method 1


$DIR = "/home/rajesh";
$DIRHANDLE = "HANDLE";

opendir ($DIRHANDLE, "$DIR") || die "Error Opening $DIR : $!";
@dirlist = readdir ($DIRHANDLE);
foreach (@dirlist)
{
print "$_ \n";
}



Method 2


@dirlist = `ls -A $DIR`;
foreach (@dirlist)
{
print "$_ \n";
}

Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar
  • Page:
  • 1
Time to create page: 0.56 seconds

     
    
Home Forum