Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings;
- our (%replace_list);
- sub BEGIN {
- our %replace_list;
- $replace_list{'a'..'z'} = (1..9, map {0} 1..17)
- }
- sub replace_abc_123 {
- my $string = shift;
- my $output = "";
- for my $e (split //, $string) {
- if ($e =~ /[[:alpha:]]/) {
- $output .= $replace_list{lc $e};
- }
- else {
- $output .= $e
- }
- }
- return $output;
- }
- while (my $line = <DATA>) {
- $line =~ s{rename ([\w_]+) "([\w\.]+)"}
- {"rename " . replace_abc_123($1) .
- " \"" . replace_abc_123($2) . "\"" }e;
- $line =~ s{instanceRef ([\w_]+)}
- {"instanceRef " . replace_abc_123($1)}e;
- print "$line";
- }
- __END__
- (port I0 (direction INPUT))
- (instance (rename ABC_1def "CBA.gh3") (viewRef X)
- (portRef I0 (instanceRef ABC_1def))
- (portRef I1 (instanceRef iJk_1def))
- (port LO (direction OUTPUT))
- (portRef O (instanceRef ABC_1def))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement