4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Validation digit and string ? How ?
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
tyjtyj
Junior WebHelper
Junior WebHelper


Joined: 22 Feb 2002
Posts: 20

PostPosted: Thu Feb 06, 2003 2:59 pm (21 years, 2 months ago) Reply with QuoteBack to Top

how to check a variable is a string or a digit

using perl ?

________________________________
Justin Store
http://www.tyjtyj.com
OfflineView User's ProfileFind all posts by tyjtyjSend Personal MessageSend email
drathbun
WebHelper
WebHelper


Joined: 01 Mar 2003
Posts: 69
Location: Texas

PostPosted: Sat Mar 01, 2003 10:54 pm (21 years, 1 month ago) Reply with QuoteBack to Top

What are you actually trying to do? Perl doesn't care; it will convert numbers to characters and characters to numbers when it needs to.

If you want to figure out if a string contains nothing but numeric entries, you could use
Code:
$foo =~ tr/0-9//d;
and then take the length of the remaining string. This command (I think, anyway) will take $foo and remove all numeric characters. Suppose $foo contains 1234ABC. What's left after this is ABC. If $foo contains 1234, what's left is an empty string. Therefore the item is numeric.

________________________________
Dave
Photography Site :: Query Tools Forum :: Weekend Fun
OfflineView User's ProfileFind all posts by drathbunSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.122697 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme