May 30, 2017, 7:38 AM
Post #3 of 3
Yes, I agree with Bill, this is obviously homework assignment, so I'll give you just some clues.
Re: [iammgg] Two user inputs (String and Integer)
[In reply to]
does not make sense. $num is a number, say 2 in the first example provided in the pod section. It is not "e", which is what you want. So you need some function to extract the second character of the string. Look at the documentation on the substr function.
does not make more sense.
Still taking the first example supplied in the pod section, $string would contain "Hello" and $num is 2. They are not equal, and therefore your code branches to the else block. You want to compare $num with the length of the string. Look at the documentation for the length function.
In addition, you don't want to compare for equality, you want to know whether the number supplied is smaller than or equal to the number, or if it is larger.
And the $letter assignment should be done only if comparing the length of the string with the number provided the expected result.
I hope this will get you going without spoiling too much the purpose of this homework.