Hi All,
Below are some of the way to optimize the perl code. You can add more to this 
if you have something more.
1) use a reference instead of the variable directly
Use reference in passing large arrays in a function call. Because without a 
reference it will copy the entire array or hash onto the function call stack, 
and then copy it again in the function.
Using reference will also saves MEMORY.
2) Static string Handling
use single quotes rather than doubles. Double quotes force Perl to look for a 
potential interpolation of information, which adds to the overhead of printing 
out the string.
Print ‘I am a static string I don’t want to get interpolated’;
If we want to interpolate then do it as like this
Print ‘I am a static string’ , ”\n” , ‘I don’t want to get interpolated’;
3) Many if statements can be incredibly time consuming 
if ($a > 0)
{  $c = $a; }
elsif ($b > 0)
{  $c = $b; }
else
{   $c = $d; }
This can be time consuming, waste of space. 
Can be replaced with  $c = $a || $b || $d;
If $a is a true value, Perl doesn't even look at the other variables. If $a is 
false, then Perl checks the value of $b and so on until it gets to the last 
value, which is always used, whether it's true or not.
 Best Regards,
Prabu.M.A


      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

Reply via email to