substition in perl



Trying to figure out the substitution operator in Perl.

The documentation shows the syntax as

s/PATTERN/REPLALCEMENT/

and explains that the operator searches a string for PATTERN and
replaces that match with the REPLACEMENT text.

My question then is this. What string is being searched? The
documention goes on to say that if no string is specified, the $_
variable is search.

What is the $_ variable?


Dennis Hancy
Eaton Corporation
Cleveland, OH

.



Relevant Pages

  • TERM setting? strange chars in man page
    ... Suddenly I'm seeing strange characters in some documentation. ... It seems like it's always the same string. ... I see no pattern for where they appear other than they seem equally spaced. ...
    (comp.unix.programmer)
  • Re: substition in perl
    ... The documentation shows the syntax as ... What string is being searched? ... PATTERN is searched and replaced by REPLACEMENT. ...
    (comp.lang.perl.misc)
  • Re: Regex to remove non printable characters
    ... mycreates a new variable with no contents so there is nothing for the substitution operator to remove. ... Perl isn't a toolbox, but a small machine shop where you ...
    (comp.lang.perl.misc)
  • Re: use binary operator on ascii text string
    ... I'm pretty crap at perl, so I'd appreciate so help from you guys. ... I have a string value held in $body variable. ... What I need to do is manipulate each individual character value in the ... You'll also have to change $c to the match variable $&, and the substitution operator will need the 'g' option and the 'e' option. ...
    (comp.lang.perl.misc)
  • Re: perl reg. exp. (search and replace)
    ... I have a string which contains spaces. ... any whitespace at the end. ... The substitution operator is bound to the ...
    (perl.beginners)