from a newbie to another newbie something like:

[snip]
my $newfile = "newfile name" # can get from parameters if you so desire
my $line;
unless(open( FILE, ">$newfile" ) )
{
# do fail stuff
}


foreach my $file ( @files )  # Setup @files with the list of filenames you
want to open
{

     # You may want to use some file test operators here to check for
existence and non-size and readability, etc.

     if (open( IN_FILE, $file ) )
     {

          while ( $line = <IN_FILE> )  # reads each line until EOF
          {
               print FILE $line;
          }
          close ( IN_FILE);

     }
     else
     {
          print STDERR "Failure opening: $file - $!\n";  # $! is set by the
failed open function
     }
}
-----------------------------------------
Craig Moynes
Internship Student
netCC Development
IBM Global Services, Canada
Tel: (905) 316-3486
[EMAIL PROTECTED]



                                                                                       
                            
                    Nichole                                                            
                            
                    Bialczyk             To:     [EMAIL PROTECTED]                    
                            
                    <[EMAIL PROTECTED]>        cc:                                           
                            
                                         Subject:     append a file to another file    
                            
                    06/01/01 03:30                                                     
                            
                    PM                                                                 
                            
                                                                                       
                            
                                                                                       
                            



i understand how to open and create files, but let's say that i want to
open several files and insert them all into one large file. how would i
do that?

thanks, nichole




Reply via email to