in reply to Re^2: Comparing masses in two txt files
in thread Comparing masses in two txt files

The grep is there to skip blank lines hence the length. Putting the chomp in the grep in that fashion avoids a map:

my @data1 = grep length, map chomp, <$in1>;

You don't "pass out" the value from grep. It tests the result returned for each element of the source list to determine if the element is placed in the output list.


Perl reduces RSI - it saves typing

Replies are listed 'Best First'.
Re^4: Comparing masses in two txt files
by johngg (Canon) on Nov 05, 2008 at 23:32 UTC
    Doh! I must have taken some "stupid" pills with breakfast today :-(

    However, that map chomp, <$in1>; will result in a load of '1's being emitted to the grep denoting the success of the chomps. The whole line should perhaps be

    my @data1 = grep length, map {chomp; $_} <$in1>;

    Obviously, your original line was fine and I'm sorry my buffle-headed senior moment got us into this :-/

    Cheers,

    JohnGG