First, you may want to switch from calling chop() to chomp() instead (the latter will only strip off an end-of-line character, as defined by the variable $/).
Next you probably don't need the unnecessary variable $row, since both chomp() and split() operate on $_ implicitly.
Now, to answer your question, you can skip every other line by testing $. for odd/even-ness (use experimentation to decide which one -- odd or even -- you need to skip). For example, if the first line and every *other* line thereafter should be skipped:
open (DB, "<$data_file") or die "$data_file: $!"; while (<DB>) { next if $. % 2; # change 'if' to 'unless' to skip even lines chomp; my @fields = split /\|/; print "$fields[0]"; } close DB;
dmm
You can give a man a fish and feed him for a day ...In reply to Re: Environment Variables
by dmmiller2k
in thread Environment Variables
by n4mation
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |