in reply to Re: help with a regex
in thread help with a regex
You should print $_ instead
Or, just add the /r modifier to the substitution:
#! perl use v5.14; use warnings; use strict; my %words = (word => 1, word2 => 1, word3 => 1); my ($temp, $temp1) = qw(WORD2 word2); $_ = 'here is word2'; say s/$temp1/$words{$temp1} ? "$temp " : "[$temp] "/er;
Output:
13:14 >perl 515_SoPW.pl here is WORD2 13:15 >
From s/PATTERN/REPLACEMENT/msixpodualgcer in Regexp Quote Like Operators:
r Return substitution and leave the original string untouched.
Hope that helps,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: help with a regex
by AnomalousMonk (Archbishop) on Feb 02, 2013 at 12:29 UTC |
In Section
Seekers of Perl Wisdom