Re: returns 3x the data
- From: Purl Gurl <purlgurl@xxxxxxxxxxxx>
- Date: Thu, 05 Apr 2007 09:09:25 -0700
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
.
- Follow-Ups:
- Re: returns 3x the data
- From: Purl Gurl
- Re: returns 3x the data
- References:
- returns 3x the data
- From: Rodrick Brown
- returns 3x the data
- Prev by Date: Re: simple way to manipulate a crap slinging monkey
- Next by Date: Re: returns 3x the data
- Previous by thread: returns 3x the data
- Next by thread: Re: returns 3x the data
- Index(es):