Re: Help parsing tab delimited files

2012-04-10 Thread Jim Gibson
At 5:05 AM +0100 4/10/12, Rob Dixon wrote: Jim Gibson wrote: Tiago Hori wrote: Just so I make sure I understand it correctly: So every time I use a while () loop each line of input from the file gets assigned to $_ in each iteration of the loop? Almost. <> is an operator. Each time is eva

Re: Help parsing tab delimited files

2012-04-10 Thread Rob Dixon
On 10/04/2012 07:40, Dr.Ruud wrote: On 2012-04-10 06:05, Rob Dixon wrote: while () { : } is identical to while (readline FILEHANDLE) { : } which compiles as while (defined($_ = readline FILEHANDLE)) { : } Not accurate, you can check with -MO=Deparse. Please explain what you think is ina

Re: Help parsing tab delimited files

2012-04-09 Thread Dr.Ruud
On 2012-04-10 06:05, Rob Dixon wrote: while () { : } is identical to while (readline FILEHANDLE) { : } which compiles as while (defined($_ = readline FILEHANDLE)) { : } Not accurate, you can check with -MO=Deparse. -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: Help parsing tab delimited files

2012-04-09 Thread Rob Dixon
Jim Gibson wrote: Tiago Hori wrote: Just so I make sure I understand it correctly: So every time I use a while () loop each line of input from the file gets assigned to $_ in each iteration of the loop? Almost. <> is an operator. Each time is evaluated, a line is read from the file and ass

Re: Help parsing tab delimited files

2012-04-09 Thread John W. Krahn
Jim Gibson wrote: On 4/9/12 Mon Apr 9, 2012 12:22 PM, "Tiago Hori" scribbled: Hey Jim, Makes perfect sense now. Thanks. Just so I make sure I understand it correctly: So every time I use a while () loop each line of input from the file gets assigned to $_ in each iteration of the loop? Al

Re: Help parsing tab delimited files

2012-04-09 Thread Jim Gibson
On 4/9/12 Mon Apr 9, 2012 12:22 PM, "Tiago Hori" scribbled: > Hey Jim, > > Makes perfect sense now. Thanks. > > Just so I make sure I understand it correctly: So every time I use a while > () loop each line of input from the file gets assigned to $_ in > each iteration of the loop? Almost.

Re: Help parsing tab delimited files

2012-04-09 Thread Tiago Hori
Hey Jim, Makes perfect sense now. Thanks. Just so I make sure I understand it correctly: So every time I use a while () loop each line of input from the file gets assigned to $_ in each iteration of the loop? Cheers, Tiago On Mon, Apr 9, 2012 at 1:00 PM, Jim Gibson wrote: > At 10:21 AM -0230

Re: Help parsing tab delimited files

2012-04-09 Thread Jim Gibson
At 10:21 AM -0230 4/9/12, Tiago Hori wrote: Sorry guys, Another quick question: I got this from perlmonks: #!/usr/bin/perl -w use strict; my @desired_cols = qw(colname1 colname3); #order matters here # reads first line to get actual column names my $header_line = (); my @actual_cols = split(/\

Re: Help parsing tab delimited files

2012-04-09 Thread Tiago Hori
Sorry guys, Another quick question: I got this from perlmonks: #!/usr/bin/perl -w use strict; my @desired_cols = qw(colname1 colname3); #order matters here # reads first line to get actual column names my $header_line = (); my @actual_cols = split(/\s+/,$header_line); # get column number of the

Re: Help parsing tab delimited files

2012-04-09 Thread Tiago Hori
Hi All, Thanks for all your inputs. Part of the problem I was having is that I was creating tab delimited files in excel and I forgot the excel uses a different way to create newlines, right? I remember having the same issue with MySQL. Now, i got it working! Is there way around this issue? Tha

Re: Help parsing tab delimited files

2012-04-09 Thread Dr.Ruud
On 2012-04-09 03:12, Tiago Hori wrote: Is there any way that I could parse a row at a time while ( <$fh> ) { $_ eq 'foo' and print "$.:$_\n" for split /\t/; } -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@p

Re: Help parsing tab delimited files

2012-04-08 Thread Jim Gibson
At 10:42 PM -0230 4/8/12, Tiago Hori wrote: 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

Re: Help parsing tab delimited files

2012-04-08 Thread Michael Rasmussen
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'

Re: Help parsing tab delimited files

2012-04-08 Thread John W. Krahn
Tiago Hori wrote: Hi Guys, Hello, 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

Re: Help parsing tab delimited files

2012-04-08 Thread Binish A.R
replace     @array = split (/\t/, $_);  with               @array = split;   From: Tiago Hori 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

Help parsing tab delimited files

2012-04-08 Thread Tiago Hori
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 st