Domanda

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

È stato utile?

Soluzione

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.

Altri suggerimenti

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 $_.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top