catfish1116 has asked for the wisdom of the Perl Monks concerning the following question:
In the following code I am trying to substitute Fred for Barney, then capitalize Barney and then output it to screen. I can do the initial substitution but when I add a second substitution the output isn't what I want.
#! /usr/bin/perl use v5.14; use warnings; $_ = "He's out bowling with Fred tonight."; s/Fred/Barney/; s/with (\w+)/against $1's team/; #This is the line of code that screws up ouptut s/$1/\U$1/gi; print "$_\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Having issues with substitutions
by choroba (Cardinal) on Feb 05, 2019 at 17:57 UTC | |
|
Re: Having issues with substitutions
by Your Mother (Archbishop) on Feb 05, 2019 at 18:03 UTC |