Look up the substitution operator. s//.
You can replace the data like so:
$myvar = "hello|world|yes!";
$myvar =~ s/|/\t/gi;
print "$myvar";
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
Cool, do me a favor and up at the top, mark the thread as solved.
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
Your absolutely right... I didn't test the code, I went off memory. So, You would need to escape the piping symbol as such:
$myvar = "hello|world|yes!";
$myvar =~ s/\|/\t/gi;
print "$myvar";
And as for the regex optional modifier's Whoopie Do. You can add it or leave it, I don't think it really matters. I think you'll find regex to be faster in operation (not that it would be noticable on small amounts of data) than nested splits and joins, but I guess it boils down to style.
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
d5e5
Practically a Posting Shark
810 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159