Question : Grab a specific link from <a> tag (with multiple <a> tags in one line) not working

I have a html file that has multiple <a> tags in one line. I am trying to grab a link from one specific <a> tag and am not able to

From the code, you''ll notice that we have three <a> tags and I am trying to get the links from second <a> tag. The link that I am trying to get is "http://www.email.com/Opt.jsp?mid=548&zi=90210"

Everytime I run this command
perl -ne 'if (m!href="(.*?)".*Unsubscribe!gms){ print "$1\n"}' file.html - where file contains the code which is attached

This always grabs contents from first <a> tag and not the second one as I specifically said that I want the one with Unsubscribe in it.

Also, If I put each <a> in separate line the command works fine.


Any suggestions?
1:
<td align="center" style="padding-top: 10px; text-align: center; font-family: Arial,Helvetica,sans-serif; font-size: 11px; background-color: #6fb2c4; color: #ffffff; margin: 0px;">How are you&nbsp; - &nbsp;<u><a style="color: #ffffff;" href="http://images.cnn.com/email/index061509.html">Add us</a></u>&nbsp;&nbsp;|&nbsp;&nbsp;<u><a style="color: #ffffff;" href="http://www.email.com/Opt.jsp?mid=548&zi=90210">Unsubscribe</a></u>&nbsp;&nbsp;|&nbsp;&nbsp;<u><a style="color: #ffffff;" href="http://www.cnn.com/Where?to=343">View in browser</a></u></td>

Answer : Grab a specific link from <a> tag (with multiple <a> tags in one line) not working

m!href="([^<]*?)"[^<]*Unsubscribe!gms  
Random Solutions  
 
programming4us programming4us