When you're splitting on any whitespace, you want to use \s+ instead of " ".except when you want to use " ", which does just what you want, including saving the hassle of the empty first element:
$ perl #!/usr/bin/perl -w use strict; my $line = " 0\t10\n 9 4 \r 1 0 0 \t0 2 2 1 1 0"; my @config = split " ", $line; for (@config) { print $_, "\n"; } __END__ 0 10 9 4 1 0 0 0 2 2 1 1 0
In reply to Re^2: split line
by ysth
in thread split line
by lil_v
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |