Here is some code I've written:

#!/bin/perl -w
use strict;

sub choose_vi {
    print "Use vi?\n";
    print "Y/y for yes.  Any other key quits: ";
    chomp(my $answer = <STDIN>);
    if ($answer =~ /^[yY]$/) {
        print "Enter line number? (Y for yes):";
        chomp(my $answer = <STDIN>);
        print "\n";
        if ($answer =~ /^[yY]$/) {
            print "Enter line number: ";
            chomp(my $line_number = <STDIN>);       
            system "vi", "+".$line_number, $ARGV[0],
"caught_errors";            
        } else {
            system "vi", $ARGV[0], "caught_errors";
        }           
    } else {
        print "Goodbye!\n";
    }
}

sub read_ce {
   print "Errrors:\n";  
   open CAUGHT, "caught_errors" or die "Can't open
file: $!";
   my @lines = readline CAUGHT;
   my $number_of_lines = @lines;
   for (my $i = 0; $i < $number_of_lines; $i++) {
      print $lines[$i]."\n";
   }
}   

my $number_of_args = @ARGV; 

open STDERR, ">./caught_errors" or die "Can't create
caught_errors: $!";

if ($number_of_args == 0) {
    print "Not enough arguments!\n";
    print "Usage: ./cedit somefile.C++\n";
    print "Usage (optional): ./cedit somefile.C++
outputfile\n";
} elsif ($number_of_args == 1) {
    system "g++", $ARGV[0];
    &read_ce;
    &choose_vi;    
} elsif ($number_of_args == 2) {
    system "g++", $ARGV[0], "-o", $ARGV[1];
    &read_ce;
    &choose_vi;
} else {
    print "Too many arguments!\n";
    print "Usage: ./cedit somefile.C++\n";
    print "Usage (optional): ./cedit somefile.C++
outputfile\n";
}

Basically, I'm trying to automate g++.  This script
works, but when I run it, I get the following error
message:

Name main::CAUGHT used only once: possible typo at
/home/Christopher Spears/C++_code/tools/cedit line 26.

My guess is that the error is in my read_ce
subroutine.  Other than that, I'm not sure what is wrong.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to