jms53 has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
I'm trying to understand what the following regex does,
$temp is a string, $temp1 is the same string but entirely lowercase, and %words is populated (word => 1, word2 => 1, word3 =>1 ...).
Thank you!
Where @line contains all the words in a line of input.
I'm trying to understand what the following regex does,
print s/$temp1/$words{$temp1} ? "$temp " : "[$temp]"/ex;
$temp is a string, $temp1 is the same string but entirely lowercase, and %words is populated (word => 1, word2 => 1, word3 =>1 ...).
Thank you!
EDIT 22:26
Using toolic's suggestion I fixed it by setting it as follows:
for my $temp (@line) { $_ = lc($temp); s/$_/$words{$_} ? "$temp " : "[$temp] "/ex; print; }
Where @line contains all the words in a line of input.
J -
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: help with a regex
by toolic (Bishop) on Feb 01, 2013 at 18:16 UTC | |
by Athanasius (Archbishop) on Feb 02, 2013 at 03:27 UTC | |
by AnomalousMonk (Archbishop) on Feb 02, 2013 at 12:29 UTC | |
Re: help with a regex
by 7stud (Deacon) on Feb 01, 2013 at 18:52 UTC |
Back to
Seekers of Perl Wisdom