my $split_pattern = ' '; # default ... # $split_pattern might get changed here from a command line option $split_pattern = $foo if $bar; ... $line = " one two three \n"; my @words = split $split_pattern, $line; for my $i (0..$#words) { print "$i: ($words[$i])\n"; } # Expected output for default case 0: one 1: two 2: three # Actual output for default case 0: () 1: () 2: () 3: (one) 4: (two) 5: (three) 6: () 7: () 8: ( )
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to Re^2: How to get split $var to work like split ' '?
by QM
in thread How to get split $var to work like split ' '?
by QM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |