in reply to SOLVED Printing last two characters
What you should try to match, is two characters, followed by the end of the string. I can do it like this:
with capturing parens to capture these two characters:/..\z/
or maybe like this:/(..)\z/
After it matches, you can read the captured value out of $1, or you can put it directly into a variable like this:/(.{2})\z/
which will leave $sight undefined if it fails to match. Note the parens on the left, it tells the assignment operator = it's being called in list context, so the regexp returns a list of captures, and it assigns the first item in the returned list to the variable $sight.($sight) = /(.{2})\z/;
HTH.
|
|---|