All,
This is kind of an odd issue...but, "fun" for all you guru's, I bet! This one has stumped me for awhile now.
I am writing a code converter (please keep that in mind...because that SHOULD limit the possible solutions). The issue I've run into is that I need to do a substitution "on the fly" within a line of code. For example (and this is VERY simplyfied):
Original Code
This results in A = "BHEO". The "+" means "concatenate" and notice how "L" was removed (the "-") from A before the contatenation.
What would you programmatically convert line 2 into for perl? It needs to be short and to the point...if possible.
My attempt (obviously, doesn't quite work correctly):
Thanks in advance!!
This is kind of an odd issue...but, "fun" for all you guru's, I bet! This one has stumped me for awhile now.
I am writing a code converter (please keep that in mind...because that SHOULD limit the possible solutions). The issue I've run into is that I need to do a substitution "on the fly" within a line of code. For example (and this is VERY simplyfied):
Original Code
Code:
1: A = "HELO"
2: A = "B" + (A - "L")
What would you programmatically convert line 2 into for perl? It needs to be short and to the point...if possible.
My attempt (obviously, doesn't quite work correctly):
Code:
$a = "HELO"
$a = "B" . ((index($a,"L")>=0)?substr($a,index($a,"L"),1,""):$a);
Thanks in advance!!