in reply to Re: How to get split $var to work like split ' '?
in thread How to get split $var to work like split ' '?
UPDATE: Pls ignore this post. Thanks to LanX above I now understand what the problem is.
Can you explain what the supposedly special behavior of split ' ' is? I cannot find any documentation saying anything about it. For me this works:
use strict; use warnings; use Data::Dumper; my $str = "I want a split pattern"; my $pattern = $ARGV[0] // ' '; my @pieces = split /$pattern/, $str; print Dumper \@pieces;
hdb$ perl split4.pl $VAR1 = [ 'I', 'want', 'a', 'split', 'pattern' ]; hdb$ perl split4.pl a $VAR1 = [ 'I w', 'nt ', ' split p', 'ttern' ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to get split $var to work like split ' '?
by brianski (Novice) on Sep 11, 2013 at 00:24 UTC | |
|
Re^3: How to get split $var to work like split ' '?
by brianski (Novice) on Sep 11, 2013 at 00:19 UTC |