array-1[0] array-2[0]...array-n[0] array-1[1] array-2[1]...array-n[1] . . ... . . . ... . . . ... . array-1[n] array-2[n]...array-n[n] #### array-1 . ' ' . array-2 . ' ' . array-n #### #!/usr/bin/perl use strict; use warnings; use Data::Dumper; $| = 1; my @timestamp; my @doc_read; my @result; my $write = 'write.txt'; my $line; my $text; my $arg; my $date = localtime(); sub read { foreach $arg (@_) { open (READ, "<" , $arg) or die ("Could not open: ".$arg." - $!\n"); while ( @doc_read = ) { chomp @doc_read; foreach $line (@doc_read) { @result = split (':', $line); push (@timestamp, $result[3]); } } close (READ) or die ("Could not close: ".$arg." - $!\n"); } return @timestamp; } sub write { open (WRITE , ">>" , $write ) or die ("Could not open: ".$write." - $!\n"); print WRITE "\n" . $date . "\n"; foreach $_ (@_) { print WRITE $_ . "\n"; } close (WRITE) or die ("Could not close: ".$write." - $!\n"); my $text = "Successfully writen on ".$write.".\n"; return ($text); } my @values = &read(@ARGV); print Dumper (\@values); my $final = &write(@values); print "\n" . $final . "\n"; #### Line_1:Line_1_1:Line_1_2:Line_1_3:Line_1_4 Line_2:Line_2_1:Line_2_2:Line_2_3:Line_2_4 Line_3:Line_3_1:Line_3_2:Line_3_3:Line_3_4 Line_4:Line_4_1:Line_4_2:Line_4_3:Line_4_4 #### Line_5:Line_5_1:Line_5_2:Line_5_3:Line_5_4 Line_6:Line_6_1:Line_6_2:Line_6_3:Line_6_4 Line_7:Line_7_1:Line_7_2:Line_7_3:Line_7_4 Line_8:Line_8_1:Line_8_2:Line_8_3:Line_8_4 #### $VAR1 = [ 'Line_1_3', 'Line_2_3', 'Line_3_3', 'Line_4_3' ]; #### $VAR1 = [ 'Line_1_3', 'Line_2_3', 'Line_3_3', 'Line_4_3', 'Line_5_3', 'Line_6_3', 'Line_7_3', 'Line_8_3' ]; #### #!/usr/bin/perl use strict; use warnings; use Data::Dumper qw(Dumper); use constant ARGUMENTS => scalar 2; $| = 1; my @timestamp_first; my @timestamp_second; my $write = 'output.txt'; sub first { open (FIRST, "<" , $ARGV[0]) or die ("Could not open: ".$ARGV[0]." - $!\n"); while ( my @first_read = ) { chomp @first_read; foreach $_ (@first_read) { my @result_first = split (':', $_); if (/^\s*$/) { # /^\s*$/ check for "blank" lines may contain spaces or tabs next; } push (@timestamp_first, $result_first[3]); } } close (FIRST) or die ("Could not close: ".$ARGV[0]." - $!\n"); return @timestamp_first; } sub second { open (SECOND, "<" , $ARGV[1]) or die ("Could not open: ".$ARGV[1]." - $!\n"); while ( my @second_read = ) { chomp @second_read; foreach $_ (@second_read) { my @result_second = split (':', $_); if (/^\s*$/) { # /^\s*$/ check for "blank" lines may contain spaces or tabs next; } push (@timestamp_second, $result_second[3]); } } close (SECOND) or die ("Could not close: ".$ARGV[1]." - $!\n"); return @timestamp_second; } sub write { open (WRITE , ">>" , $write ) or die ("Could not open: ".$write." - $!\n"); foreach $_ (@_) { print WRITE $_ . "\n"; } close (WRITE) or die ("Could not close: ".$write." - $!\n"); my $text = "Successfully writen on ".$write.".\n"; return ($text); } sub check { if (@ARGV < ARGUMENTS || @ARGV > ARGUMENTS) { die "Please enter ".ARGUMENTS." files to read!\n"; } } &check(@ARGV); my @first_values = &first($ARGV[0]); my @second_values = &second($ARGV[1]); my @final; my $num = @first_values; for($_ = 0; $_ < $num; $_++) { push (@final , $first_values[$_] . ' ' . $second_values[$_]); } print Dumper (\@final); my $date = time(); my $output = &write(@final); print "\nResult: ".$output.""; #### $VAR1 = [ 'Line_1_3 Line_5_3', 'Line_2_3 Line_6_3', 'Line_3_3 Line_7_3', 'Line_4_3 Line_8_3' ]; Result: Successfully writen on output.txt.