Mike Blezien 写道:
Hello,

this one has been driving me nuts and I'm sure it's something very simple I maybe overlooking. I need to assign a delimiter variable IE: Pipe or Comma delimiter:

my $del         = '|'; # use either a '|' or ','
my $dataline  = "0|1|2|3|4|5|6|7|8|9";
my @data     = split(/$del/, $dataline);

This does not work, it won't split the file line with the '|' delimiter, and get no errors. But if I do this:

my $dataline  = "0|1|2|3|4|5|6|7|8|9";
my @data     = split(/\|/, $dataline);

Then it works prefectly, it splits the line as expected. What am I missing ??


Hello,

Change one of the lines to:
my @data     = split(/\Q$del/, $dataline);

This would work.

from perldoc perlre,
\Q          quote (disable) pattern metacharacters till \E


--
Jeff Pang
http://home.arcor.de/jeffpang/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to