Code:
$
$
$ cat -n file1
1 SV,22,20100501140000,JFK,RUH
2 SV,29,20100501073000,BOM,RUH
3 SV,29,20100501073000,SIN,RUH
$
$ cat -n file2
1 JFK,+,0500
2 BLR,-,0530
3 SIN,-,0800
$
$
$ ##
$ perl -F, -M"Date::Calc qw(Add_Delta_DHMS)" -lane '
> if ($ARGV eq "file2") {
> $os{$F[0]} = $F[1].join($F[1], unpack("A2A2",$F[2]));
> } else {
> @x = unpack("A4A2A2A2A2A2",$F[2]);
> if (defined $os{$F[3]}) {
> @x = Add_Delta_DHMS(@x,0,substr($os{$F[3]},0,3),substr($os{$F[3]},3),0);
> }
> printf("%s,%s,%04d%02d%02d%02d%02d%02d,%s,%s\n",$F[0],$F[1],@x,$F[3],$F[4]);
> }
> ' file2 file1
SV,22,20100501190000,JFK,RUH
SV,29,20100501073000,BOM,RUH
SV,29,20100430233000,SIN,RUH
$
$