Perl: the Markov chain saw | |
PerlMonks |
Re: grep for windowsby Athanasius (Archbishop) |
on Oct 15, 2016 at 03:05 UTC ( [id://1174052]=note: print w/replies, xml ) | Need Help?? |
Hello Datz_cozee75, Fleshing out RonW’s answer a little: My question is what this line is doing: It’s replacing / (forward slash) with \\ (backslash) throughout the string $file. Here, s introduces the substitution operator. It’s normally written s///, but since the string to be substituted is itself a forward slash, a different delimiter has been chosen: a , (comma). See perlretut#Simple-word-matching. The backslash is doubled because a single backslash introduces an escape sequence — see perlop#Quote-and-Quote-like-Operators. So two consecutive backslashes represent an actual (single!) backslash character. And of course the /g modifier on the regex causes the substitution to be made globally throughout the string. See perlre#Modifiers. Hope that helps,
In Section
Seekers of Perl Wisdom
|
|