There are 2 problems there: you are using bge1 as a bareword and you are escaping the dollars in the regex thus preventing them from doing what you want. Here's the working version:
#!/usr/bin/env perl use strict; use warnings; my $Interface = 'bge1'; $Interface =~ s/[0-9]$/:$&/; print $Interface . "\n";
which outputs "bge:1".
In reply to Re: find a substring using regex and then replace it
by hippo
in thread find a substring using regex and then replace it
by swissknife
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |