[ic] Testing UserTags without restart
Christian Brink
cbrink at brinkrods.com
Tue Oct 11 21:19:30 EDT 2005
This is a program I wrote awhile ago to syntax check UserTags without a
restart. You do need the File::Temp perl module.
Change the location of the 'lib' directory if needed.
#!/usr/bin/perl
use strict;
use warnings;
use File::Temp;
my $fn = $ARGV[0] || die "File Name Required\n";
my $debug = $ARGV[1] || 0;
my @lines;
push(@lines,"use lib qw| /usr/local/interchange/lib/ |; \n"); #Change if
needed
push(@lines,"use strict; \n");
push(@lines,"use warnings; \n");
push(@lines,'my $Session;'," \n");
push(@lines,'my $Tag;'," \n");
push(@lines,'my $Variable;'," \n");
my $line_in = scalar(@lines);
my $line_out = 0;
open(FH,"<$fn") or die "Could not open $fn\n";
while (my $line = <FH>) {
$line =~ s/^sub\s+{/sub foobar {/;
++$line_out && next if ( $line =~ /^UserTag/ );
++$line_out && next if ( $line =~ /^EOR/ );
++$line_out && next if ( $line =~ /^EOD/ );
push @lines, $line;
}
print @lines if $debug;
my $cnt = $line_out - $line_in;
my $tmp = new File::Temp();
print $tmp @lines;
my @report = `perl -c $tmp 2>&1 `;
foreach (@report) {
if ( /line (\d+)/ ) {
my $was = $1;
my $now = $was + $cnt;
s/line $was/line $now/;
}
print "$_";
}
$tmp->DESTROY;
More information about the interchange-users
mailing list