For my programming class, I need to program a Perl script to generate a Makefile.deps file from the C files from the current directory. I've finished a lot of the code, but a few things still need to be implemented. Because it's Thanksgiving weekend, I won't have time to complete it. I will pay anyone $20 via Paypal if they can do the job. Please PM me ASAP because this assignment is due tomorrow morning at 9am PST. I'll provide more information via AIM, MSN, or Skype contact. The current code below works halfway. It takes in an argument, which should be *.c and prints them to STDOUT. The proper output for the program though is supposed to be cc -xM1 *.c | grep -v /usr/local/sunstudio/sunstudio Code (markup): I have some psuedocode written as well as the program specifications. 3 loops are needed: The outer loop iterates over @ARGV, the list of C programs to search The middle loop iterates over @worklist, which is an array of files to search for a particular dependency The inner loop iterates over a file, picking up #includes To prepare for the middle loop, create a target variable (ending in .o) and push the C program name onto the work list : push @worklist, $source; Code (markup): The inner loop repeatedly shifts a source file (.c or .h) from the work list and opens it. If it can’t be opened, an error message is printed, and next. To shift from the worklist : my $source = shift @worklist; Code (markup): Otherwise, a dependency is created : $dependencies{"$target: $source"} = 1; Code (markup): Then we search the file for #includes using the inner loop. For every include file found, a dependency is created, and the file name is pushed onto the work list. In this way, we are including files recursively. The work list is essentially a queue, and we are doing a breadth first traversal over the depen- dency tree. Add code after the outer loop to print out the dependencies in sorted order. To test the final working code, you would need to type in include.perl *.c Code (markup): #!/usr/bin/perl use strict; use warnings; use Getopt::Std; $0 =~ s|^(.*/)?([^/]+)/*$|$2|; my $exit_status = 0; END {exit $exit_status} sub note (@) {print STDERR "$0: @_"} $SIG{"__WARN__"} = sub {note @_; $exit_status = 1}; $SIG{"__DIE__"} = sub {warn @_; exit}; my %options; getopts "h", \%options; print <DATA> and exit if $options{"h"}; @ARGV = grep {m/\.c$/} @ARGV; die "No input files specified, no output generated\n" unless @ARGV; for my $source (@ARGV) { open my $file, "<$source" or warn "$source: $!\n" and next; while (defined (my $line = <$file>)) { next unless $line =~ m/^\s*#include\s+"(.*?)"\s*$/; my $header = $1; print "$source: $header\n"; } close $file; } __END__ NAME include.perl -- generate make dependencies from C source files SYNOPSIS include.perl [-h] filename... DESCRIPTION The include.perl utility scans C source files for #include directives and does a search through recursively included header files in order to generate gmake(1) dependencies. OPTIONS -h Help information is printed out in the form of a Unix man page. The program then exits and ignores any other option or operand. OPERANDS Each operand is a filename to be searched for #include "...". preprocessor directives. The filenames are expected to be C source code files and therefore must end with the suffix ``.c''. An error message is printed if not. There must be at least one filename operand. Only user-level includes are recognized. Includes of the form #include <...> are ignored. EXIT STATUS 0 No errors were detected. 1 Errors were detected and messages were printed. Code (markup):