in reply to How to get split $var to work like split ' '?
There's always the eval solution.
my $sep = ' '; $, = ', '; $\ = $/; my $string = " Hello World"; print split ' ', $string; print split $sep, $string; # This does not work print eval qq< split '$sep', \$string >;
This could do the trick as long as you don't try to use regexes. And maybe escaping the quotes in $sep would be a good idea too :PHello, World , , , , , , , , , , Hello, World Hello, World
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to get split $var to work like split ' '?
by QM (Parson) on Sep 11, 2013 at 08:12 UTC |