Perl Turn Array Into String Javascript Substring