in reply to Split Help
ormy $sep_re = quotemeta($sep); my @fields = split(/$sep_re/, $_);
my @fields = split(/\Q$sep/, $_);
For example,
$\ = "\n"; $, = ";"; for my $sep (",", "\t", "|") { my $line = join($sep, qw( a b c )); print $line; my @fields = split(/\Q$sep/, $line); print @fields; print ''; }
a,b,c a;b;c a b c a;b;c a|b|c a;b;c
Or maybe you are trying to split on the two characters "\" and "t" instead of an actual tab character?
$\ = "\n"; $, = ";"; for my $sep ('\t', "\t") { print split(/\Q$sep/, "foo\tbar\\tbaz"); }
foo bar;baz foo;bar\tbaz
|
|---|