in reply to map split vs array split

Sigh. Read I know what I mean. Why don't you?. It has some hints for writing posts so that other people understand what you are asking and so that code you provide can be run by others with the least hassle and external dependencies.

Where are the code samples that generate the output you show?. Why can't I see the link to the tutorial you mention?

How often do you check the perlintro documentation when you have a problem? Something simple you can probably do at your command line is: perldoc -f <func name>. For example you could perldoc -f split to get split which would tell you that split works on an 'EXPR' (i.e. string in this case), not an array.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: map split vs array split
by convenientstore (Pilgrim) on Jul 30, 2007 at 23:30 UTC
    thanks for your pointer.. and you r right.. I should read up more on these..
    ** update ** I acheived what I wanted w/ below code
    I ran into this while going through map tutorial and
    wanted to see if I can write the same code using w/out map
    But you had me realize that I need to get more through with
    basic stuff as well as writing clear questions
    thanks for all your help guys~
    use strict; open (FH, 'foo.txt'); my @lines = <FH>; my @lines1; close FH; foreach (@lines) { chomp; push my @lines1, $_; } print "@lines1\n";

      Note that chomp can act on an array so you can:

      use strict; use warnings; my $file1 = <<FILE; apple goat chocolate newyork FILE open IN, '<', \$file1; my @lines = <IN>; close IN; chomp @lines; print "@lines1\n";

      Prints:

      apple goat chocolate newyork

      DWIM is Perl's answer to Gödel