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?
It is not odd at all. You are printing for every line in the file regardless of whether or not the pattern matched. You should probably only print *when* the pattern matches: while ( <DATA> ) { print "\L$1\n" if /^=+\s(\w+)/; } John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/