Advertisement

06.25.2008 at 01:27PM PDT, ID: 23516106
[x]
Attachment Details

Help with Perl substitution or translate

Asked by datastarstar in Perl Programming Language

Tags: Perl

Not being an expert in pattern-matching, I've been struggling with this for a while and I think there's a simple solution.  I want to substitute a letter A-J for any number 0-9 which appears as the first character in a string.

For example:
3STRING would become CSTRING
ASTRING would not be changed.

I've been trying variations of:
$string =~ tr/^[0-9]/[A-J]/;

...using tr, s, etc.
Start Free Trial
[+][-]06.25.2008 at 02:25PM PDT, ID: 21870001

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2008 at 03:48PM PDT, ID: 21870508

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.25.2008 at 03:59PM PDT, ID: 21870564

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: Perl
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.25.2008 at 04:01PM PDT, ID: 21870580

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628