I am a perl noob still. I am getting a string which can be man_1, man_2, woman1, woman2 etc.. (no commas and there will be only one string as input to the function).
I need to check man_ or woman as substring in if statements to make sure appropriate number is extracted and some offset is added.
the number i can extract as below
$num =~ s/\D//g
if (<need the substring extracted> == "man_")
$offset = 100;
else if (<need the substring extracted> == "woman")
$offset = 10;
return $num + $offset;
Now how do I extract the substring. I looked at substr and it requires offsets and what not. Couldnt figure out. Appreciate the help
Solution:
In your example there is couple of problems: