Generated: Tue Feb 2 17:54:58 2010 from test14.pl 2006/04/16 1.6 KB.
#!/Perl print "Hello, World...\n"; $root_dir = 'C:\\FG0910-1\\source\\'; my ($LOG); my $outfile = 'temptest14.txt'; open $LOG, ">$outfile" or die "Unable to open $outfile LOG ...\n"; amend_vcproj(); close(LOG); sub amend_vcproj { my $src_lib = $root_dir . 'projects\VC8\FlightGearLib.vcproj'; my $src_main = $root_dir . 'projects\VC8\FlightGear.vcproj'; my $line = ''; my $line1 = ''; my @lines = (); my @xml_main = (); if ( ! -f $src_lib ) { print "AWK: Unable to locate [$src_lib] file ...\n"; return 1; } if ( ! -f $src_main ) { print "AWK: Unable to locate [$src_main] file ...\n"; return 2; } open IF, "<$src_lib" or die "Can not OPEN $src_lib!\n"; my @lib_lines = <IF>; # slurp whole file, to an array of lines close(IF); open IF, "<$src_main" or die "Can not OPEN $src_main!\n"; my @main_lines = <IF>; # slurp whole file, to an array of lines close(IF); my $lc_lib = scalar @lib_lines; my $lc_main = scalar @main_lines; print "Loaded $src_lib of $lc_lib lines ...\n"; print "Loaded $src_main of $lc_main lines ...\n"; foreach $line1 (@main_lines) { chomp $line1; # remove any return (\n) character ... $line1 =~ s/\r$//; # and remove CR, if present $line .= $line1; if ($line =~ />$/) { $line =~ s/\t/ /g; $line =~ s/\s\s/ /g while ($line =~ /\s\s/); $line = substr($line,1) while ($line =~ /^\s/); push(@xml_main, $line); $line = ''; } } foreach $line (@xml_main) { prt( $line."\n" ); } return 0; } sub prt { my $msg = shift; print $msg; print $LOG $msg; }