in reply to Removing only the first instance with RegEx
And the output isuse strict; while (<DATA>) { chomp; my ($c1, $c2) = (substr($_,0,1), substr($_,length($_)-1,1)); if ($c1 == '(' && $c2 != ')') { substr($_,0,1) = undef; } elsif ($c1 != '(' && $c2 == ')') { substr($_,length($_)-1,1) = undef; } print "$_\n"; } __DATA__ (1.3.56.84 56.38.m.26) (56.2.3.59)
1.3.56.84 56.38.m.26 (56.2.3.59)
|
|---|