On Sun, Apr 08, 2012 at 08:44:53PM -0700, Binish A.R wrote: > replace @array = split (/\t/, $_); with > @array = split; I advise to not do that, because when you add more data - like Joe Bob \t Briggs
@array will have three elements. My output from your sample data and program is: Joe Doe Jane Doe Which looks to be what you want. Tiago - if you want to find a specified value why are you splitting the lines up? something like: while(<FILE>) { print if m/text_you_want/; } > From: Tiago Hori <tiago.h...@gmail.com> > To: beginners@perl.org > Sent: Monday, April 9, 2012 6:42 AM > Subject: Help parsing tab delimited files > > Hi Guys, > > I know there are modules for parsing tab delimited files, but I am trying to > develop a script as a learning exercise to learn the better, so any help > would be appreciated. > > Let's say I have two columns and two rows: > > Joe \t Doe > Jane \t Doe > > So here is what I got: > > #!usr/bin/perl > > use strict; > > my $name; > my $lastname; > my@array; > > open(FILE, "<", "columns.txt"); > > while (<FILE>) > { > > @array = split (/\t/, $_); > print "$array[0]\n"; > print "$array[1]\n"; > } > > > > close(FILE); > > > So right now this prints Joe and Jane. It seems the split is putting a column > in the array. Is there any way that I could parse a row at a time, with each > element becoming a entry in the array? My goal is to be able to go through > each row at a time and find a specific value. > > Thanks, > > Tiago > > > > > --------------------------- > > "Education is not to be used to promote obscurantism." - Theodonius > Dobzhansky. > > "Gracias a la vida que me ha dado tanto > Me ha dado el sonido y el abecedario > Con él, las palabras que pienso y declaro > Madre, amigo, hermano > Y luz alumbrando la ruta del alma del que estoy amando > > Gracias a la vida que me ha dado tanto > Me ha dado la marcha de mis pies cansados > Con ellos anduve ciudades y charcos > Playas y desiertos, montañas y llanos > Y la casa tuya, tu calle y tu patio" > > Vioeta Parra - Gracias a la Vida > > > Tiago S. F. Hori > PhD Candidate - Ocean Science Center-Memorial University of Newfoundland > tiago.h...@gmail.com -- Michael Rasmussen, Portland Oregon Other Adventures: http://www.jamhome.us/ or http://westy.saunter.us/ Fortune Cookie Fortune du jour: The good thing about mistakes ~ they're better than regrets. ~ http://someoneoncetoldme.com/gallery/05112007 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/