Hi Jacinta and Hamish,<br><br>Thanks for pointing out to use the chomp function.  That has done the trick.  As I am fairly new to Perl, I could not for the life of me work this out.<br><br>Jacinta, thanks also for explaining other items related to the code.  I have modified it accordingly.<br>
<br>Thanks for your assistance. <br><br><div class="gmail_quote">2009/3/27 Jacinta Richardson <span dir="ltr">&lt;<a href="mailto:jarich@perltraining.com.au">jarich@perltraining.com.au</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Camillo Pereira wrote:<br>
<br>
&gt; This is something that I had tried as well, however, the format of the<br>
&gt; file ends up looking like the following:<br>
<br>
&gt; <a href="http://cpploupoi09.my.domain.com.au" target="_blank">cpploupoi09.my.domain.com.au</a><br>
&gt;     <a href="http://1cabloupoi08.my.domain.com.au" target="_blank">1cabloupoi08.my.domain.com.au</a><br>
&gt;     <a href="http://1cacloupoi07.my.domain.com.au" target="_blank">1cacloupoi07.my.domain.com.au</a><br>
&gt;     <a href="http://1cadloupoi06.my.domain.com.au" target="_blank">1cadloupoi06.my.domain.com.au</a><br>
&gt;     <a href="http://1caeloupoi05.my.domain.com.au" target="_blank">1caeloupoi05.my.domain.com.au</a><br>
&gt;     <a href="http://1cafloupoi06.my.domain.com.au" target="_blank">1cafloupoi06.my.domain.com.au</a><br>
&gt;     1<br>
<br>
</div>This suggests that the lines with your domain names on them have newlines still<br>
attached.  You&#39;ll need to chomp these newlines off (perldoc -f chomp).  For example:<br>
<br>
foreach (@DEVICE_LIST)<br>
{<br>
    foreach my $t (@critical_device_def)<br>
<div class="im">    {<br>
        my ($site, $device, $flag) = @$t;<br>
        if ($_ =~ m/\G($device)/gc)<br>
        {<br>
</div>            chomp;<br>
            print UPDATE &quot;$_\t1\n&quot; ;<br>
            next;<br>
        }<br>
    }<br>
}<br>
<br>
I&#39;m a bit worried about this line:<br>
<div class="im"><br>
        if ($_ =~ m/\G($device)/gc)<br>
<br>
</div><div class="im">(which we&#39;d normally write:<br>
<br>
        if( m/\G$device/gc )<br>
<br>
</div>because you don&#39;t seem to be using $1 and matches work on $_ by default).<br>
<br>
It&#39;s very rare to need to use \G and /g, and I can&#39;t think of any way you&#39;d need<br>
to be using it if you&#39;re going to call next; straight after a match.  \G allows<br>
you to restart the regular expression from the end of the last successful match<br>
and try to match again from there.  For example this code, with the repeating \G<br>
match line commented out:<br>
<br>
my $str = &quot;catsatmat&quot;;<br>
<br>
foreach (1..3) {<br>
        #if( $str =~ m{\G(\wat)}g ) {<br>
        if( $str =~ m{(\wat)} ) {<br>
                print &quot;$1\n&quot;;<br>
        }<br>
}<br>
<br>
gives us:<br>
<br>
cat<br>
cat<br>
cat<br>
<br>
If we swap the if statements, then we get:<br>
<br>
cat<br>
sat<br>
mat<br>
<br>
Since you&#39;re calling next after your successful match, I&#39;d rewrite your inner<br>
loop to be:<br>
<br>
    foreach my $t (@critical_device_def)<br>
<div class="im">    {<br>
        my ($site, $device, $flag) = @$t;<br>
</div>        if ($_ =~ m/$device/)<br>
        {<br>
            chomp;<br>
            print UPDATE &quot;$_\t1\n&quot; ;<br>
        }<br>
    }<br>
<br>
I&#39;m assuming that since you don&#39;t appear to know what $device matched you don&#39;t<br>
need to capture it.  If you&#39;ve simplified your code a lot, I might be wrong.<br>
I&#39;m also assuming that you won&#39;t now need the next, but if you&#39;re doing extra<br>
stuff after the if() that you don&#39;t want to do on a match, you&#39;ll need to put it<br>
back in.<br>
<br>
Finally, you define a bunch of patters:<br>
<div class="im"><br>
        my @critical_device_def = (<br>
                [AAA =&gt; qr{...apb09}    ],<br>
                [BBB =&gt; qr{...avggd09}  ],<br>
                [CCC =&gt; qr{...uytwop09} ],<br>
</div>                [DDD =&gt; qr{...loupoi09} ],<br>
        );<br>
<br>
Using fat-comma here - while completely appropriate - may cause some people to<br>
misread this as a number of hash references.  I just recommend to you that you<br>
keep that in mind.<br>
<br>
All the best,<br>
<br>
        J<br>
<font color="#888888"><br>
--<br>
   (&quot;`-&#39;&#39;-/&quot;).___..--&#39;&#39;&quot;`-._          |  Jacinta Richardson         |<br>
    `6_ 6  )   `-.  (     ).`-.__.`)  |  Perl Training Australia    |<br>
    (_Y_.)&#39;  ._   )  `._ `. ``-..-&#39;   |      +61 3 9354 6001        |<br>
  _..`--&#39;_..-_/  /--&#39;_.&#39; ,&#39;           | <a href="mailto:contact@perltraining.com.au">contact@perltraining.com.au</a> |<br>
 (il),-&#39;&#39;  (li),&#39;  ((!.-&#39;             |   <a href="http://www.perltraining.com.au" target="_blank">www.perltraining.com.au</a>   |</font></blockquote><div><br><br>===============================================================<br>
<br><br>---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Hamish Carpenter</b> <span dir="ltr"></span><br>Date: 2009/3/27<br>Subject: Re: [Melbourne-pm] Writing array data to file with appended information<br>
To: Camillo Pereira <br>Cc: <a href="mailto:melbourne-pm@pm.org">melbourne-pm@pm.org</a><br><br><br>Camillo,<br>
<br>
I believe the output you are getting has a newline at the end of each
domain.  You will need to chomp() each line of output to remove the
newline and then manually append a new line.<div class="im"><br>
<br>
chomp;<br>
print UPDATE &quot;$_\t1\n&quot;;<br>
<br></div>
See `perldoc -f chomp` for more info on chomp.<br>
<br>
Hamish <br></div></div><br>