HI,
i am new to perl world.
And i am trying to compress a file, as given below procedure.
INPUT FILE:
1 1 2 1 ==> R1
2 1 3 1 ==> R2
3 1 4 1 ==> R3
OUTPUT FILE:
1 1 4 1
PROCEDURE:
R1-> C3 == R2->C1
R1->C4 == R2->C2
AND IF
R1->C2 == R1->C4 && R2->C2 == R2->C4
THEN OUTFILE FILE BECOMES
1 1 3 1
3 1 4 1
once again case 1 is applied and it output will become
11 41
ANYBODY HAVE ANSWER !!!
:wall:
Here you go:
$, = ' ';
$\ = "\n";
$_ = <>;
my @R = split;
while (<>) {
my @N = split;
if ($P[2] == $R[0] && $P[3] == $R[1]) { @N[0..1] = @R[0..1]; }
@R = @N;
}
print @R;
1 Like
Hi,
Thanks for your reply.
But it is printing last , but required output is different one.
How to get the proper value.
Thanks
Vasanth
---------- Post updated at 05:31 AM ---------- Previous update was at 04:20 AM ----------
Hi m.d.ludwig,
The desired output is different one..
Can you guide for the correct output.
Hi m.d.ludwig,
I got your approach.
And instead of p, i have to use R ..thts ..it solved..
Thanks
vasanth