in reply to Which one is best for optimization

See Perl.com: Optimizing Your Perl. "Best" can vary by input, easiest to just test it, but 2 definitively uses more memory :)