http://qs1969.pair.com?node_id=328866


in reply to File Copy/Merge Question

I don't know of a module but this is dirt easy to do with standard perl. Here's a quicky program for you. I tried to demonstrate good habits - 5.005 compliance, safe-two-arg open, localizing filehandles before use, platform independance with binmode, and checking system calls for errors.

use strict; use vars qw( $DESTINATION @SOURCES ); $DESTINATION = pop @ARGV; @SOURCES = @ARGV; local *DEST; open DEST, "> $DESTINATION\0" or die "Can't overwrite $DESTINATION: $!"; binmode *DEST or die "Can't binmode $DESTINATION: $!"; for my $file_name ( @SOURCES ) { local *IN; open IN, "< $file_name\0" or die "Can't open $file_name for readin +g: $!"; binmode *IN or die "Can't binmode $file_name: $!"; local $/ = \ 8192; while ( my $chunk = <IN> ) { print DEST $chunk or die "Can't write to $DESTINATION: $!"; } close IN or warn "Can't close $file_name after reading: $!"; } close DEST or warn "Can't close $DESTINATION after writing: $!";