Re: returns 3x the data



Rodrick Brown wrote:

I have a data file with the following about a thousand or so records.

=============== XXXXXXXXXX01 ===============
0
xxxxxxxxx01


I performing the following match to just pick out the xxxx strings

while(<DATA>)
{
if( $_ =~ m/^=+\s(\w+)/ )
{
$hostname = lc $1;
}
print $hostname . "\n";
}

some odd reason my data is returned 3x instead of once why does this happen?

Move your print inside your "if" block,

while(<DATA>)
{
if( $_ =~ m/^=+\s(\w+)/ )
{
$hostname = lc $1;
print $hostname . "\n";
}
}


Your original code prints for each while loop.

Purl Gurl

.