On 7 Jul 2014, at 09:18, Sunita Pradhan <sunita.pradhan.2...@hotmail.com> wrote:

> I have a file of contents:
> -----------
> 1 6
> 2 7
> 3 8
> 4 9
> 5 10
> ----------
> I want a file with content:
> 
> 1 2 3 4 5
> 6 7 8 9 10

Try this:


#!/usr/local/bin/perl
use strict;
my (@col1, @col2);
while (<DATA>) {
  chomp;
  my @words = split / /;
  push @col1, $words[0];
  push @col2, $words[1];
}
print join " ", @col1;
print "\n";
print join " ", @col2;
__DATA__
1 6
2 7
3 8
4 9
5 10

#JD




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to