Program is working . Thank you all. Date: Mon, 7 Jul 2014 15:48:48 +0530 Subject: Re: want to write to file in different format From: mukeshbarn...@gmail.com To: johndelac...@gmail.com CC: beginners@perl.org
Very nice John!!!I couldn't think it.Mukesh Kumar Member of Technical Staff Cadence Design Systems (I) Pvt. Ltd. Mob:- +91-8527749333 On 7 July 2014 15:26, John Delacour <johndelac...@gmail.com> wrote: 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/