Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: File Copy/Merge Question

by Art_XIV (Hermit)
on Feb 13, 2004 at 21:13 UTC ( [id://328881] : note . print w/replies, xml ) Need Help??

in reply to File Copy/Merge Question

Here's the extra-quick but naughty version. It should work just peachy with concatenating text files.

use strict; use warnings; my $destination = pop @ARGV; open OUT, ">$destination" or die "Couldn't create the concatenated file $destination: $!\n"; print OUT while (<>); close OUT;

The '<>' is a spicy bit of Perl that uses your command-line args as file names.

Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"

Replies are listed 'Best First'.
Re: Re: File Copy/Merge Question
by diotalevi (Canon) on Feb 13, 2004 at 21:27 UTC
    That's actually rather unsafe. See Dangerous diamonds!. This is why I was using the "< $file\0" form. If I were coding to 5.8 then I'd use three-arg open. You also just destroyed any binary data if this is to be done on a Windows computer.