in reply to Re: Appending strings
in thread Appending strings

There are strings that I don't need appending the $path, such as "else" "if" "1'b0", is there a way to add this to the expression or do I have to split ' ' and check each string? Also, how do I treat "ABC_DEF" "b_C_D_E" as one word and append $path only to the beginning of the string? Thanks

Replies are listed 'Best First'.
Re^3: Appending strings (Verilog)
by toolic (Bishop) on Sep 17, 2015 at 01:15 UTC
Re^3: Appending strings
by Anonymous Monk on Sep 17, 2015 at 01:57 UTC

    Including _ and ignoring some keywords...

    #!/usr/bin/perl # http://perlmonks.org/?node_id=1142266 use strict; use warnings; my $path = "XX.YY.ZZ"; my $s = "(ABC | (~dEf & hIJ)) & ~LMn if foo while bar"; my %ignore = map { $_, $_ } qw( if while for ); (my $answer = $s) =~ s/(\w+)/$ignore{$1} || "$path.$1"/ge; print "$answer\n";