Skip to content

Commit

Permalink
Update bin/parse_asn1.pl for argv
Browse files Browse the repository at this point in the history
  • Loading branch information
hchiba1 committed Aug 20, 2024
1 parent e927f37 commit b6dd8ae
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions bin/parse_asn1.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
my %OPT;
getopts('', \%OPT);

my $INPUT_FILE;
if (@ARGV) {
$INPUT_FILE = $ARGV[0];
}

my $summary = "";
my $reading = 0;
while (<>) {
Expand All @@ -33,19 +38,34 @@
}

if ($summary) {
my $out = "";
my $src = "";

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

if ($INPUT_FILE) {
open(OUT, ">${INPUT_FILE}.en") or die;
print OUT $out;
close(OUT);
open(SRC, ">${INPUT_FILE}.src") or die;
print SRC $src;
close(SRC);
} else {
print $out;
print STDERR $src;
}
}

0 comments on commit b6dd8ae

Please sign in to comment.