Hi all,<br><br>I'm going through logs seeing if a change improved a particular SQL statements execution time. The part I'm interested looks like this:<br><br> insert into foo..bar_440_5678_D<br> select<br> a.pd,<br>
<a href="http://a.tg">a.tg</a>,<br> ....<br> Elapsed time: 0m27.485s<br><br>I'm interested in the "5678" and the time it took. Seems like the flip-flip ".." is perfect for a quick hack to extract that info:<br>
<br>perl -ne 'if(/insert into foo\.\.bar_440_(\d+)/../time: (.+)/&&$1){print "$1\n"}' SQL.log<br><br>The thing is, it prints "5678" many times, until it gets to the "Elapsed time" portion. I would expect that the lines between the start and the end, which don't match, to clear $1.<br>
<br>I ended up with a longer one-liner to extract the info I was looking for-<br><br>perl -ne 'if(((/insert into foo\.\.bar_440_(\d+)/ and $a=$1)..(/time: (.+)/ and $b=$1))&&$b){print "$a took $b\n";$b=0}' SQL.log<br>
<br>Now I'm curious why I couldn't rely on $1 being undefined for the intermediate lines. Anyone have a good explanation?<br><br>-y<br><br><br>