http://www.perlmonks.org?node_id=569812

Grey Fox has asked for the wisdom of the Perl Monks concerning the following question:

Hello esteemed Monks of perl
I am being stumped on why my data is being slurped in all at once instead of line by line. I am trying to pull out only the name and id number, but my array is being loaded with the entire file. Also do I need to clear the array after each record read. I know it must be something simple because I've been staring at it for an hour.
Thanks, for your wisdom
#!/prod/bin/perl use strict; use warnings; use Data::Dumper; undef $/; my @data; my $counter = 0; while (my $line = <DATA>) { @data = split (/\t/, $line); print Dumper \@data; $counter = $counter+1; print "$counter, $data[11], $data[12]\n"; } __DATA__ LIMITS LIMITS1 LIMITS2 LIMITS3 LIMITS4 LIMITS5 LIMIT +S6 LIMITS7 UPDATEDATE STEP2 DESC2 APPR2 APPRID2 +OWNR2 OWNRID2 Limits less than $1K $1K-50K $50k-$250K more than $250K + $250K-$1M $1M-$5M more than $5M 8/16/2006 2:14:00.000 PM + 111111 Cost Center 1 Stien, Franklin N 000204 Stien, Fra +nklin N 000204 Limits less than $1K $1K-50K $50k-$250K more than $250K + $250K-$1M $1M-$5M more than $5M 8/16/2006 2:14:00.000 PM + 222222 Cost Center 2 Bear, Izzy 000598 Bear, Izzy 000 +598 Limits less than $1K $1K-50K $50k-$250K more than $250K + $250K-$1M $1M-$5M more than $5M 8/16/2006 2:14:00.000 PM + 333333 Cost Center 3 Bear, Fozzy 000485 Davis, Sammy +000404 Limits less than $1K $1K-50K $50k-$250K more than $250K + $250K-$1M $1M-$5M more than $5M 8/16/2006 2:14:00.000 PM + 444444 Cost Center 4 Frog, Kermit T 000990 Frog, Kermit +T 000990 Limits less than $1K $1K-50K $50k-$250K more than $250K + $250K-$1M $1M-$5M more than $5M 8/16/2006 2:14:00.000 PM + 555555 Cost Center 5 Cleavland, Grover 000563 Cleavland, + Grover 000563

-- Grey Fox
Perl - Hours to learn lifetime to master.