http://qs321.pair.com?node_id=700658


in reply to split line

you should read the perldoc of split. It can do some magic..., especially when you use $_ as expression; you don't need to bother with leading whitespaces (which might be unwanted in the resulting list)

my $line = " 0 10 9 4 1 0 0 0 2 2 1 1 0"; my @config = (); { # dedicated block because localizing some variables ($_) local $_ = $line; @config = split; } # some code using @config { # dedicated block because localizing some variables ($, and $\) # show result; local $, = local $\ = $/; print @config; }

update: code comments added

update2: see moritz' answer for the better solution whithout localizing $_