in reply to Regex with variables?
but if all are in domain-computer form, you could just usemy $re = qr/.+\-(.+)/; $foo =~ s/$re/$1/;
Update: but on second thought the first way could run in a loop and you could just define the regex before the loop using qr//. That would probably be more efficient.$foo =~ s/.+\-(.+)/$1/;
Output:use strict; my $re = qr/.+\-(.+)/; while(<DATA>){ s/$re/$1/; print; } __DATA__ domain-comp1 domain-comp2 domain-comp3
comp1 comp2 comp3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regex with variables?
by Quadzilla (Initiate) on Aug 22, 2003 at 15:13 UTC |