Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] insertion of data in files

Expand Messages
  • merlyn@stonehenge.com
    ... Mirza I have two file, first.txt and second.txt Mirza first.txt Mirza Hello i am first text file Mirza ----------- Mirza ------- Mirza ---
    Message 1 of 2 , Apr 4, 2006
      >>>>> "Mirza" == Mirza Abdullah Jan <jan576pk@...> writes:

      Mirza> I have two file, first.txt and second.txt
      Mirza> first.txt
      Mirza> Hello i am first text file
      Mirza> -----------
      Mirza> -------
      Mirza> ---

      Mirza> Second.txt
      Mirza> Hello i am second text file
      Mirza> --------
      Mirza> -------
      Mirza> -------



      Mirza> i want to insert data from first.txt into second.txt (The data from
      Mirza> first.txt must be insert first row of second.txt)

      The simplest (but not most efficient, except from a programmer's perspective)
      is Tie::File:

      use Tie::File;
      tie @file1, 'Tie::File', "filename1" or die " ... ";
      tie @file2, 'Tie::File', "filename2" or die " ... ";
      unshift @file2, @file1;

      That's it!

      --
      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
      Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
      See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Your message has been successfully submitted and would be delivered to recipients shortly.