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 reading: $!"; binmode *IN or die "Can't binmode $file_name: $!"; local $/ = \ 8192; while ( my $chunk = ) { 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: $!";