Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://328881]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-13 19:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found