What is the value of $ testModule = ~ s @ / @ :: @ig; in Perl?

I am new to Perl and I am reading some perl codes, I find one line below, I couldn't figure out if anyone can tell what does

s@/@::@ig 

      

I know I'm =~

trying to match some regex. normally I would see code like s/<regular express>//gi

, so I confused the following code a bit. can anyone help with the development?

$testModule =~ s@/@::@ig;

      

+1


source to share


1 answer


You can use many different characters as regex delimiters.

This one is used @

instead /

, so it can be used /

as data inside a regex without leaving it.

This is equivalent to:



$testModule =~ s/\//::/ig;

      

See the quote and quote operators in the Perl documentation for details .

+6


source







All Articles