=Brad Rice wrote:
>  I wrote this script to take a directory of text files and append them
>  into one BBEdit text file. ...
>  Any suggestion for making this script better?I'm still
>  pretty new at PERL.
=cut



##    Hi Brad,
##             you can do this:


#!perl -w
#########################################################################################
##  ReadDir.pl
##      Basic script for opening, working on and joining all files in one directory
#########################################################################################
$/ = $\ = chr(13);   ##  Line delimiter for in- and output  (Apple: 13, Dose: 10)

opendir (DIR, '') or die "Cannot open";      ##  opens folder of this script
open D_OUT, ">BigFile.txt";

while ((defined ($FileName = readdir DIR)))  {
  print "Now in work: $FileName.";
  #if ($FileName !~ m/txt/ )    {  next  }    ## --> skip if file name DOES NOT 
contain "txt"
  if  ($FileName =~ m/BigFile/) {  next  }    ## --> skip if file name DOES contain 
"BigFile"

  open D_IN, "<$FileName" or die "Not found";

  while (<D_IN>)   {                          ##  as long as lines can be found within 
D_IN
    chomp;           ##   Here you can do some cleansing etc. on those lines
    print D_OUT $_;   }   }

print    "  D o n e . ";

##  HTH
##  Detlef

Reply via email to