Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Printing last two characters

by moritz (Cardinal)
on Jan 03, 2008 at 11:41 UTC ( [id://660170]=note: print w/replies, xml ) Need Help??


in reply to SOLVED Printing last two characters

The best solution using substr was already posted, so let me just add an explanation why m/\Z{2}/ doesn't work.

\Z matches not a character, but a position. So it's useless to say "match end of the string, and then again end of the string".

With warnings enabled perl would have told you:

Quantifier unexpected on zero-length expression in regex; marked by <-- HERE in m/\Z{2} <-- HERE / at -e line 1.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://660170]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2024-04-18 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found