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

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

Aloha, I am trying to iterate through a simple array of 5 lines (read from a text file). I know the array always starts with 0. So when using the for each loop it skips 0. Why? This makes it leave out the first line, I only get 4 lines. I need to use PERL more often! I use BBEdit. I just opened my names.txt in Firefox also confirming 5 names. and added print scalar of @data.
foreach $name (@data) { print "$name"; }
#!/usr/bin/perl use strict; use warnings; my @data; my $name; open (JOE, "</Users/mrg/Desktop/names.txt") or die "No can!"; while (<JOE>) { @data = <JOE>; } foreach $name (@data) { print "$name"; }
This is names.txt
Joseph.Guillaume Fred.Flintsone Barney.Rubble George.Jetson ElRoy.Jetson
This is the Ouput:
Last login: Wed Jul 23 13:44:11 on ttyp1 Welcome to Darwin! G4-2:~ mrg$ /var/tmp/folders.507/Cleanup\ At\ Startup/test-238549606.0 +74.pl.command; exit Fred.Flintsone Barney.Rubble George.Jetson ElRoy.Jetsonlogout [Process completed]
Problem solved! by injunjoe Mahalo (Thank You)