!/usr/bin/perl use strict; use warnings; ###################### #Homework 3 #The Service Engine #Athur: Brad Duhon #Due November 9th 09 ###################### ###################### #OPEN ###################### open (LOG, '>>$/tmp/bckgnd_log.txt'); select ( ( select ( LOG ), $| = 1 ) [ 0 ] ); open FILE, '>/tmp/bckgnd_run.txt'; print FILE "$$"; close FILE; my $sig_vars = { USR1 => 0, QUIT => 0 }; my @array_ref; my $jobs; my $count = 0; ###################### #PRINT ###################### sub Print{ chomp($array_ref[$count][0]); chomp($array_ref[$count][1]); chomp($array_ref[$count][2]); print LOG "submit $array_ref[$count][0] $array_ref[$count][1] $array_ref[$count][2] \n"; $count++; } ###################### #CATCH ###################### sub catch { my ($signame) = @_; if ( exists( $sig_vars->{ $signame } ) ) { $sig_vars->{ $signame } = 1; } } ###################### #INT_CATCHER ###################### sub INT_catch { open (JOB, '/tmp/bckgnd_sub.txt')or print "Cannot open"; my @temp = <JOB>; if(@temp == 3 || $temp[0] =~ /[1-10]/){ push(@array_ref,[@temp]); } else{ print LOG "SUBMISSION FILE ERROR.\n"; } @array_ref = sort{ $a->[0] <=> $b->[0]; }@array_ref; print @array_ref; close(JOB); unlink("/tmp/bckgnd_sub.txt"); Print(); } ###################### #QUIT ###################### sub QUIT_doer { close LOG; exit; } ###################### #USR1 ###################### sub usr1{ open(DUMP, ">/tmp/bckgnd_dump.txt") or die "Couldn't Complete Action."; if(@array_ref > 0){ for(my $z = 0; $z < @array_ref; $z++){ chomp($array_ref[$z][0]); chomp($array_ref[$z][1]); chomp($array_ref[$z][2]); print DUMP "job dumped: $array_ref[$z][0] $array_ref[$z][1] $array_ref[$z][2] \n"; } } else { print DUMP "No Jobs Found."; } close(DUMP); } ###################### #ACTIONS ###################### $SIG{ INT } = \&INT_catch; $SIG{ USR1 } = \&catch; $SIG{ QUIT } = \&catch; ###################### #MAIN LOOP ###################### while(1) { if(@array_ref > 0){ #open(PIPE, "$array_ref[2] |"); #open(OUTFILE, 'array_ref[2]'); #while(<PIPE>){ #print LOG "RUN CMD array_ref[1] OUT array_ref[2]"; #} } else{ sleep(1000); if ( $sig_vars->{ USR1 } ) { USR1_doer() }; if ( $sig_vars->{ QUIT } ) { QUIT_doer() }; } } I have "Use of uninitialized value in scalar chomp" for lines 30-32 "Use of uninitialized value in concatenation(.) or string print() on closed file handle" line 33 readline() on closed filehandle JOB line 51 use of uninitialized value in pattern match (m//) line 52 And I have no idea what these are for I have tried fixing them over and over... the overall program is suppose to run in the background... and take info from a file, store it into an array of arrays, sort them by priority (found in the first line of every 'job' sent to it). then write out everything that happens to a log.