in reply to Re^3: Perl Code Runs Extremely Slow
in thread Perl Code Runs Extremely Slow

Yes but you don't have to chomp the lines because split removes all whitespace, including any terminating newlines.

Replies are listed 'Best First'.
Re^5: Perl Code Runs Extremely Slow
by jeffa (Bishop) on Jun 15, 2006 at 20:11 UTC

    This particular usage of split removes all whitespace, not split in general. If you split on something more specific such as a space or a tab then the newline will still be found in the last element of the list.

    use Data::Dumper; while (<DATA>) { my @foo = split; my @bar = split / /, $_; print Dumper \@foo, \@bar; } __DATA__ hello world foo bar baz

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)