Question

I am using someone else's text parsing perl code and I'd like to make some modifications. Could someone explain what =~ symbol is doing?

$xmlfile =~ s/value="{(.*?)}"/'value="'.&subst($1).'"'/ge;

EDIT:

So I found this thread that explains part of the regex string.

http://www.perlmonks.org/?node_id=24640

Was it helpful?

Solution

By default, matching, substitution, or transliteration act on $_; to use them on another variable, the binding operator =~ is used. In your case, the variable the substitution will be performed on is $xmlfile.

OTHER TIPS

According to perlop:

Binary "=~" binds a scalar expression to a pattern match. Certain operations search or modify the string $_ by default. This operator makes that kind of operation work on some other string. The right argument is a search pattern, substitution, or transliteration. The left argument is what is supposed to be searched, substituted, or transliterated instead of the default $_.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top