One way to replace is to use s///:
use strict;
use warnings;
my $text;
while ( my $text = <DATA> ) {
# match a word that contain 'ou' or #
if ( $text =~ m/(ou)|(#)$/ ) {
$text =~ s{[/\\]}{-}g;
print $text;
}
}
__DATA__
hello.world#
world\tour
Game.started
That replaces the \ and the / with -. You can add the rest.
UPDATE: added alternate delimiters in response to OP private msg. | [reply] [d/l] |
Utter nonsense. This is not the question of a seeker of Perl wisdom. It seems, in fact, to be seeking a means of avoiding acquiring Perl wisdom.
You have identified that you wish to do a substitution. You seem to be aware of regular expressions. So read the documentation, perlretut for example, and take a stab at it. The worst that can happen if you try is you make a mistake, and with a little effort, you'll learn from the mistake. The best that can happen if you don't try is you'll learn nothing and remain dependent on others to solve your problem for you.
| [reply] |
| [reply] |
"you'll learn from the mistake"
i must be learning alot then :)
hopefully i am learning the "right" way lol
| [reply] |
HI
Two things one must do
1. Read perldoc perlre documentation. Its all covered there.
2. check existing perlmonks posts for similar solutions. I am very confident you will find many answers.
If you still face a problem , look no further. ask away.
| [reply] |