<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1491" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=639143202-21112008><FONT face=Arial size=2>Hi
All,</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial size=2> Can anybody
give me an idea of just how much impact using $& can have on a
program?</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial size=2>I have a function
which does something like this:</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial size=2>foreach my
$this_line(@an_array)</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008> <FONT face=Arial
size=2>next if ($this_line=~m/something which indicates we're not
interested/); </FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008> <FONT face=Arial
size=2>if ($this_line =~m/something we are interested in
\d*\.*\d*)
</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008> <FONT face=Arial
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008>
<FONT face=Arial size=2>my $foo=$&;</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008>
<FONT face=Arial size=2># Do some stuff with $foo</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008> <FONT face=Arial
size=2>}</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008> <FONT face=Arial
size=2>elsif ($this_line=~m/something else interesting
\d*\.*\d*/)</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008> <FONT face=Arial
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial
size=2> my
$bar=$&;</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008>
<FONT face=Arial size=2># Do something with $bar</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008> <FONT face=Arial
size=2>}</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial
size=2>}</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial size=2>@an_array could be
anything up to about 50 elements.</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial size=2>This is the only
place in the whole program which uses a regex, so the impact on other parts of
the program should be nil.</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial size=2>I just don't know if
it's going to be worth removing those references to $&, and how much it will
benefit the running of the program.</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial size=2>Obviously, the
bigger @an_array is, the larger the impact, but I can safely say it won't be
much bigger than about 50.</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial size=2>So, are we talking
an order of magnitude slower? More? Less? Anybody even want to take an
educated guess?</FONT></SPAN></DIV>
<DIV><SPAN class=639143202-21112008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV align=left>
<DIV align=left><FONT face=Arial
size=2>Regards,<BR>
Leigh</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Leigh Sharpe<BR>Network Systems Engineer<BR>Pacific
Wireless<BR>Ph +61 3 9584 8966<BR>Mob 0408 009 502</FONT></DIV>
<DIV><FONT face=Arial size=2>Helpdesk 1300 300 616<BR>email <A
title=mailto:lsharpe@pacificwireless.com.au
href="blocked::mailto:lsharpe@pacificwireless.com.au">lsharpe@pacificwireless.com.au</A><BR>web
<A title=http://www.pacificwireless.com.au/
href="blocked::http://www.pacificwireless.com.au/">www.pacificwireless.com.au</A></FONT></DIV></DIV>
<DIV> </DIV></BODY></HTML>