Simple Question

They have: 117 posts

Joined: Mar 2000

Just a simple question here...

In Perl, how would I isolate the first letter of a word to a variable??

Thanks!

--Edge

tmay's picture

They have: 75 posts

Joined: Sep 2001

$first = substr($string, 0, 1);

They have: 117 posts

Joined: Mar 2000

Hey, Thanks! That works great. Could you tell me how to determine if that letter is a number?

tmay's picture

They have: 75 posts

Joined: Sep 2001

$first = substr($string, 0, 1);

if($first =~ /[0-9]/)
{ ..do something if it's a number.. } else { ..do something else.. }

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.