convenientstore has asked for the wisdom of the Perl Monks concerning the following question:
open (FH, "foo.txt") ; while (<FH>) { chomp; @lines1 = split / /, $_; } close FH; print "@lines1\n";
###### map code ############ open (FH, "foo.txt"); my @words = map { split } <FH>; close FH; print "@words\n"; ############### array split########## open (FH, "foo.txt"); my @lines = <FH>; close FH; my @lines1 = split(' ', @lines); print "\@lines1 is @lines1";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: map split vs array split
by FunkyMonk (Bishop) on Jul 30, 2007 at 23:03 UTC | |
by convenientstore (Pilgrim) on Jul 30, 2007 at 23:18 UTC | |
by FunkyMonk (Bishop) on Jul 30, 2007 at 23:54 UTC | |
by radiantmatrix (Parson) on Jul 31, 2007 at 15:18 UTC | |
|
Re: map split vs array split
by GrandFather (Saint) on Jul 30, 2007 at 23:20 UTC | |
by convenientstore (Pilgrim) on Jul 30, 2007 at 23:30 UTC | |
by GrandFather (Saint) on Jul 31, 2007 at 00:19 UTC | |
|
Re: map split vs array split
by ikegami (Patriarch) on Jul 31, 2007 at 00:09 UTC |