How would I append one file to another in perl

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

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

    Accepted Solution

    open F2,"<$file2" or die "$file2 $!";
    open F1,">>$file1" or die "$file1 $!"
    print F1 while <F2>;
    close F1;
    close F2;
    LVL 19

    Expert Comment

    system("cat $file1 $file");  # run unix cat command

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

    Expert Comment

    perl -pe '' dog >>cat


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    Title # Comments Views Activity
    Capturing SMDR data into MySQL 4 398
    perl search and replace 6 152
    Port 80 requests 16 74
    rename outfile before writing 2 64
    I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
    Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
    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…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now