in reply to grep for windows

Hello Datz_cozee75,

Fleshing out RonW’s answer a little:

My question is what this line is doing:

$file =~ s,/,\\,g;

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,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,