perlUser345 has asked for the wisdom of the Perl Monks concerning the following question:
I've used the s/// operator with great success before. However, this time I'm getting some weird results.
I have this:
$test = "mouse_eatsCat_andDog.txt"; $test =~ s/"_(.+)"/$1/; #because I want to get "eatsCat_andDog.txt" print "$test"; #result is "mouse_eatsCat_andDog.txt"
I'm very puzzled by this! I've tried this with no success as well:
$test =~ s/"^mouse_(.+)"/$1/;I made it work using a different method so that I got only "eatsCat_andDog.txt" but I want to know why the above method doesn't work. Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: s/// operator
by BrowserUk (Patriarch) on Nov 19, 2015 at 19:22 UTC | |
by perlUser345 (Acolyte) on Nov 19, 2015 at 19:25 UTC | |
|
Re: s/// operator
by stevieb (Canon) on Nov 19, 2015 at 19:26 UTC | |
by perlUser345 (Acolyte) on Nov 19, 2015 at 19:31 UTC | |
|
Re: s/// operator
by GotToBTru (Prior) on Nov 19, 2015 at 19:26 UTC |