title: perl code to merger multiple text files
body: <p>i have multiple text files.I have written code to input 2 files through shell and merge them.But how do i merge multiple files.Is system command useful in this purpose.</p>
  
  <pre><code>my @a = read_file($file1)
      or die "couldn't read $file1 - $!";
  my @b = read_file($file2)
      or die "couldn't read $file2 - $!";
  
  my $combined = {}; # hashref
  
  my $i=0;
  foreach (@a) {
      chomp;
      $combined-&gt;{$i}{b} = '' unless defined $combined-&gt;{$i}{b};
      $combined-&gt;{$i++}{a} = $_;
  }
  
  $i=0;
  foreach (@b) {
      chomp;
      $combined-&gt;{$i}{a} = '' unless defined $combined-&gt;{$i}{a};
      $combined-&gt;{$i++}{b} = $_;
  }
  
  foreach my $i (sort {$a&lt;=&gt;$b} keys %$combined) {
      print $combined-&gt;{$i}{a}, ("\t" x 2), $combined-&gt;{$i}{b}, "\n";
  } 
  </code></pre>