John,

Both symbols are metacharacters when used in a regexp and must be escaped.

Try:
$del="\^";

Or better, try not using a scalar variable.

Just use the delimiter:

@fields = split /\^/,$record;

Paul

I use a variable for a field delimiter when reading
CSV files... I have been wrestling with the best way
to code my split regex so that it works with all
possible values of that variable.

It is currently failing when I set the value of the
variable to ^


# if delimiter is | - this syntax works fine

$del=|
(@fields) = split /[$del]/,$record;


# if delimiter is ^ - this syntax fails - no split $del=^ (@fields) = split /[$del]/,$record;


What syntax will work for both (all) cases?

Thanks,

John




===== John V. Pataki Logged in to my Yahoo Mail account on the web.

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


--
Sincerely,

Paul Appleby

(416) 530-0070
http://www.paulappleby.com
http://myspider.ca
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to