Skip to content

Commit

Permalink
Add bin/parse_asn1.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
hchiba1 committed Aug 20, 2024
1 parent cce6d7e commit e927f37
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions bin/parse_asn1.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/perl -w
use strict;
use File::Basename;
use Getopt::Std;
my $PROGRAM = basename $0;
my $USAGE=
"Usage: $PROGRAM
";

my %OPT;
getopts('', \%OPT);

my $summary = "";
my $reading = 0;
while (<>) {
chomp;
if (/^ summary "(.*)/) {
$summary = $1;
$summary =~ s/^ //;
$summary =~ s/ $//;
if ($summary =~ /^ /) {
print STDERR "$summary\n";
}
if ($summary =~ / $/) {
print STDERR "$summary\n";
}
$reading = 1;
} elsif (/^ \S+ {/) {
$reading = 0;
} elsif ($reading) {
$summary .= $_;
}
}

if ($summary) {
if ($summary =~ /",$/) {
$summary =~ s/",$//;
if ($summary =~ /(.*)\[(.*)\]/) {
my ($text, $comment) = ($1, $2);
if ($text =~ / $/) {
$text =~ s/ $//;
}
print "$text\n";
print STDERR "$comment\n";
} else {
print "$summary\n";
}
} else {
die $summary;
}
}

0 comments on commit e927f37

Please sign in to comment.