Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How would I append one file to another in perl

Posted on 2006-03-22
Medium Priority
Last Modified: 2008-01-09
my $file1 = "cat";
my $file2 = "dog";

How would I append dog to cat?
Question by:ckaspar
LVL 85

Accepted Solution

ozo earned 400 total points
ID: 16264472
open F2,"<$file2" or die "$file2 $!";
open F1,">>$file1" or die "$file1 $!"
print F1 while <F2>;
close F1;
close F2;
LVL 19

Expert Comment

by:Kim Ryan
ID: 16264773
system("cat $file1 $file");  # run unix cat command

system("copy $file1t + $file2"); # or ms-dos version
LVL 48

Expert Comment

ID: 16265773
perl -pe '' dog >>cat


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question