in reply to Appending strings

s///g
use warnings; use strict; my $path = "XX.YY.ZZ"; my $s = "(ABC | (~dEf & hIJ)) & ~LMn"; $s =~ s/([a-z]+)/$path.$1/gi; print "$s\n"; __END__ (XX.YY.ZZ.ABC | (~XX.YY.ZZ.dEf & XX.YY.ZZ.hIJ)) & ~XX.YY.ZZ.LMn

Verilog equation?

Replies are listed 'Best First'.
Re^2: Appending strings
by doofus (Acolyte) on Sep 17, 2015 at 00:25 UTC
    works great and yes it's verilog thank you
Re^2: Appending strings
by doofus (Acolyte) on Sep 17, 2015 at 00:47 UTC
    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

      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";