17 cze 2009

Porówniane dwóch plików w perlu.

open (FH,"<lista_01.txt");
while(<FH>){
@arr=split(" ",$_);
$hash{$arr[0]}=$_;
}
close(FH);

open (FO, ">lista_wynikowa.txt");

open (FH,"<lista_02.txt");
while(<FH>){
@arr=split(" ",$_);

if(exists($hash{$arr[0]})){
#    print $hash{$arr[2]} . "";
#    print FO $_;
print FO $_;
}
}
close(FH);
25 lip 2008

Lista plików w katalogu

 $sDir = "d:\\do_wysylki" if($sDir eq '');

opendir(SEND_DIR, $sDir)  or die "Couldn't open $dir for reading: $!";

@files = ();
while( defined ($file = readdir(SEND_DIR)) ) {

    next if ($file eq '.' or $file eq '..');

    my $filename = $file;
    push(@files, $filename);
}

closedir(SEND_DIR);

my $count  = @files;