This is no CGI-Skript, but a script for command-line...
And this code requires no CGI-Skript, but three modules. Which version perl are you using? (type "perl -v" on the command line).
These three required modules are standard modules of perl.
If you have a perlversion lower than 5.6.x I would recommend to upgrade!
But without any modules, test:
Code:
#! /usr/bin/perl
my $file_one = 'file1.dat';
my $file_two = 'file2.dat';
my @ids;
open(FILE1,"<$file_one") or die $!;
while(<FILE1>){
chomp;
push(@ids,(split(/\|/,$_))[0]);
}
close FILE1;
my @array;
open(FILE2,"<$file_two") or die $!;
foreach my $line(<FILE2>){
chomp $line;
my @fields = split/\|/,$line;
if(grep{$fields[$#fields] == $_}@ids){
$fields[-2] = 'Active';
$line = join("|",@fields);
}
push(@array,$line);
}
close FILE2;
open(WRITE,">$file_two") or die $!;
print $_,"\n" for(@array);
close WRITE;