Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: checking the end of line

by Basilides (Friar)
on Jul 20, 2002 at 14:59 UTC ( #183600=note: print w/replies, xml ) Need Help??

in reply to checking the end of line

flounder's explanation was really thorough, but just to build on it a bit, it looks like you want to first make sure that your string ends in a digit (good practice), then, as long it it does, do different things depending on which number it is. That would look something like this:
if ($path =~ m/(\d+)$/) { my $end_num = $1; if ($end_num == 0) { etc. } and so on for other numbers } else { print "Oh dear, my path doesn't end with a number\n"; }
One other thing to note is that this'll check for one *digit* at the end of your string, so if your end number might go into double figures remember to stick a '+' sign into your regex:
Hope that helps

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2023-03-20 18:39 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (59 votes). Check out past polls.