in reply to Re: How do I cut single characters out of a string
in thread How do I cut single characters out of a string
in which case a simple regular expression match is probably what you want:
if ($string =~ s/(\d)//) { my $digit = $1; ... } else { print "No digit in '$string'\n"; }
which finds and removed the first digit from $string. Putting the substitution inside an if allows you to deal with not finding a digit.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do I cut single characters out of a string
by akechnie (Initiate) on Jan 16, 2012 at 06:12 UTC | |
by GrandFather (Saint) on Jan 16, 2012 at 10:40 UTC | |
by tobyink (Canon) on Jan 16, 2012 at 10:49 UTC |