Oh that's great,
thank you
What if is there another file (fh3) to merge with fh1 and fh2?
How should i fix that line: my @out = map { chomp; $_ . ' ' . <$fh2> }
<$fh1>;
regards,
Jeff Pang wrote:
One solution,see the code and result below:
$ cat 1.txt
aaa
bbb
xxx
$ cat 2.txt
ccc
ddd
yyy
$ cat t1.pl
use strict;
use warnings;
open my $fh1,'1.txt' or die $!;
open my $fh2,'2.txt' or die $!;
my @out = map { chomp; $_ . ' ' . <$fh2> } <$fh1>;
close $fh1;
close $fh2;
print @out;
$ perl t1.pl
aaa ccc
bbb ddd
xxx yyy
Hope it helps.
-----Original Message-----
From: Onur Sirin <[EMAIL PROTECTED]>
Sent: Jan 24, 2008 9:57 PM
To: beginners@perl.org
Subject: merging the columns
Hi all,
i have two snmp-walk commands and i want to merge its output in one file.
For example,
_First command's output:
_aaa
bbb
xxx
_Second command's output:
_ccc
ddd
yyy
How can i merge these outputs like
aaa ccc
bbb ddd
xxx yyy
--
Jeff Pang [EMAIL PROTECTED]
http://home.arcor.de/jeffpang/
--
Onur Sirin
IT Department, Systems Specialist
Sabanci University
Phone : +90.216.483 9202
Fax : +90.216.483 9186
e-mail: [EMAIL PROTECTED]