#!usr/bin/perl -w use DBI; use File::Copy; @files=; foreach my $file (@files){ my @arr=split(/\//,$file); print "\n"; my @field=split(/%/,$arr[2]); print $arr[2]; my $length_arr=length($arr[2]); my $fname=substr($arr[2],0,($length_arr-4)); print "\n$fname"; my $sysacc=$field[0]; my $rid=$field[2]; my $jid=$field[1]; my $oldloc=$file; my $key=$sysacc."%".$jid."%".$rid; print "\n\nLOOKING UP KEY: $key \n"; $dbh =DBI->connect("dbi:Oracle:host=abc123;sid=test","scott","tiger!") or die "cannot connect to oracle"; $dbh->{AutoCommit}=0; my $query= "select * from lookup where name_key=\'$key\'"; my $sth=$dbh->prepare($query) or die "prepare failed"; $sth->execute() or die "execute failed"; my $status=0; while(@row=$sth->fetchrow_array()){ $status=1; $print=$row[1]; $not_print=$row[2]; $action1=$row[3]; $action2=$row[4]; $action3=$row[5]; $action4=$row[6]; } $sth->finish(); $dbh->disconnect(); if($status==0){ print "\nFile moved to print\n"; } else{ if( $action4 eq "yes"){ $newloc="h:/HOT/TO BE PROCESSED/$arr[2]"; move($oldloc,$newloc)or die "fail to move"; } my $asciiloc="h:/Ascii/$fname.txt"; print "\n\n$asciiloc\n"; if ($action2 eq "yes"){ $newloc="h:/HOT/cold/$arr[2]"; move($asciiloc,$newloc)or die "fail to move"; } elsif ($action1 eq "yes"){ $newloc="h:/HOT/action2/$arr[2]"; copy($oldloc,$newloc)or die "fail to move"; } if ($action3 eq "yes"){ $newloc="h:/HOT/action3/$arr[2]"; copy($oldloc,$newloc)or die "fail to move"; } if( $not_print eq "yes"){ $newloc="h:/HOT/not_print/$arr[2]"; move($oldloc,$newloc)or die "fail to move"; print "\n+---------------------+\n Moved file to Not print folder \n+---------------------+\n"; } if( $print eq "yes"){ $newloc="h:/HOT/print/$arr[2]"; move($oldloc,$newloc)or die "fail to move"; print "\n+---------------------+\n Moved file to print \n+---------------------+\n"; } } }