I've been coding in Perl for somewhere close to 25 years, but I'm totally self taught so I still come across things that I've never seen before (or don't remember seeing, anyway). Maybe it's Day 1 stuff for people with legit education, though, I don't know.
But here are some cool things I've learned this week:
$mod = $text =~ s///r; The /r modifier keeps it from modifying $text, so only $mod is modified. There's another added benefit, though, that it lets you chain events, like so:
$text = ' csdude is happy ';
$mod = $text
=~ s/ +/ /gr
=~ s/^ | $//gr;
print $mod;
# csdude is happy
$&, $`, and $' In a regular expression, these are predefined variables:
$& => the entire matched string
$` => everything before the matched string
$' => everything after the matched string
$text = 'csdude is happy';
$text =~ /dud/;
print $`;
# cs
print $&;
# dud
print $';
# e is happy