develooper Front page | perl.beginners | Postings from May 2007

Assign a delimiter variable

Thread Next
From:
Mike Blezien
Date:
May 15, 2007 09:43
Subject:
Assign a delimiter variable
Message ID:
005d01c79710$198695f0$04fea8c0@DGGTPQ11
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 ??


Mike(mickalo)Blezien
===============================
Thunder Rain Internet Publishing
=============================== 


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About