CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [Rancho] Perl script to compare file contents of dirA with file contents of dirB and output the difference in a separate file: Edit Log



g4143
Novice

Apr 8, 2013, 3:05 AM


Views: 365
Re: [Rancho] Perl script to compare file contents of dirA with file contents of dirB and output the difference in a separate file

Won't it make sense to filter your the reply of readdir with grep?


Code
#!/usr/bin/perl 

use warnings;
use strict;

print "Enter dir->";
chomp(my $dir = <STDIN>);

opendir(my $DIR1, $dir) or die ("Could not open directory handle! $!\n");

my @dir_entries = sort grep { -r -f } readdir $DIR1;

foreach ( @dir_entries )
{
print $_, "\n";
}

__END__



(This post was edited by g4143 on Apr 8, 2013, 3:07 AM)


Edit Log:
Post edited by g4143 (Novice) on Apr 8, 2013, 3:06 AM
Post edited by g4143 (Novice) on Apr 8, 2013, 3:07 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives