in reply to How Perl Optimize your code & some code TIPS ;-P

Now how to paste variables. If you have a big variable, let's say with the content of a file, and you need to paste it to a sub. Paste the reference, or you will use more memory duplicating the varialbe inside the loop

Another approach is using variable aliasing to @_ array in subroutine calls:

$data = 'foo' x (1024*1024) ; test($data) ; sub test { if ( $_[0] =~ /foo/s ) { print "bar\n" ;} };
This is memory efficient too.

--
Ilya Martynov, ilya@iponweb.net
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org