I'm trying to remove a specific character from a string in Perl:
my $string="MATTHATBAT";
substr($string, 2, 1, '');
EDIT: This does work, sorry. Leaving this here in case someone needs to know how to do this.
Also, is there a more efficient way of doing this?
The string should now be MATHATBAT.
Am I missing something? I know that I can use regex s///, but I am iterating through the string, looking for a certain character (this char changes), then removing the character (but only that character at that offset). So eventually, I will be removing the second or third occurence of the character (i.e. MATTHABAT, MATTHATBA and even MATHABAT etc)
Can I maybe do this using search and replace? I am using a for loop to iterate through offsets.