in reply to removing comments

^ means normally means "beginning of string", not "beginning of line". The m modifier changes that. (See perlre.) That gives you two options:

$TheFile =~ s/^'//mg;

and

while (my $TheLine = <>) { $TheLine =~ s/^'//; ... }

Update: You probably want to use '.* instead of just ' unless you only want to delete the '.