Processing of scalar or constant
I. Objective and result storage:
The target content of the default operation is in the default variable $ _, and the operation result is stored in $ _. If the operation succeeds $1, $2, $3, $ @ the variable also saves some of the relevant results.
A. Input (target)
$ _, For example, $ _ = "teststring"; M/\ * X [g] +/g; $ result = $ _;
One is = ~ Connection input: $ inputstring = "teststirng"; $ inputstring = ~ M/\ * X [g] +/g; $ result = $ _;
B. output.
3. Delete and replace strings
Replace the first string "X": S/^ x + //; $ STR = "* te ** st *"; $ STR = ~ S/^ * + //; $ STR is now "te ** st *"
Replace the string's tail string "X": S/x + $ //; $ STR = "* te * st ***"; $ STR = ~ S/* + $ //; $ STR is now "* te * ST"
PS:
Some references:
Pattern related: http://blog.csdn.net/utopia_wang/archive/2007/03/16/1531285.aspx