in reply to removing square brackets

Do you mean the grep program or Perl's grep? Whatever, the answer is no. As I feel kind, the correct solution is (or {s,c}ould be)
s/[\[\]]//g;
Since this is only a hint I'll also tell you about
perl -lpi -e '...'
separately. It is left as an exercise to the reader to check up the documents or any introductory Perl book and put it all together.