On Tue, Jul 29, 2008 at 05:46:09AM -0700, Jan-Henrik wrote:

> Now I would like to check wether the user really entered a number and
> not letters. What would a check like that look like? A regular
> expression like this:
> ----------------------------------------
> unless ($foo =~ /[a-zA-Z\D+][^.][\D*]/ {...};
> ----------------------------------------
> 
> Is there an easier or more beautiful way?

perldoc -q scalar number

> Also, how would I substract just a number from a string? Searched the
> net for an example but didn't succeed, so sorry for asking a question
> like that...

In general you might not have to, you can probably just use it as a number and
perl will do the right thing.  But otherwise you could just put parentheses
around your regex to capture the numeric part.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to