timothy adigun wrote:
On Mon, May 7, 2012 at 8:36 AM, lina<lina.lastn...@gmail.com> wrote:
I have two files, one with
3
2
1
another is:
3 1
3 2
6 3
How can I insert the first file into the middle of the second file,
This is one way to do it:
#!/usr/bin/perl
use warnings;
use strict;
my $part1 = get_data( $ARGV[0] ); # get f1.txt from CLI
my $part2 = get_data( $ARGV[1] ); # get f2.txt from CLI
my $cot = () = @{$part1};
There is no need to copy the array to a list in order to get the number
of elements in the array because an array in scalar context will return
the number of elements.
foreach ( 0 .. ( $cot - 1 ) ) {
But you don't need the $cot variable anyways because you can just do this:
foreach ( 0 .. $#$part1 ) {
my @rec = split /\s+/, $part2->[$_];
print $rec[0], " ", $part1->[$_], " ", $rec[1], $/;
}
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/