in reply to Re: removing square brackets
in thread removing square brackets

This gets my vote. I have a rule, "never use s/// when a tr/// (or y/// in this case) will do." I ran some benchmark tests a while ago on s vs tr and tr is much faster at deleting characters from a string. (This might be stating the obvious.)

Replies are listed 'Best First'.
Re^3: removing square brackets
by softworkz (Monk) on Oct 20, 2005 at 23:42 UTC
    I agree with kwaping, I would use tr/// for this solution.
    #!/usr/bin/perl -w use strict; while (<DATA>) { chomp; tr/[]//d; $_ = join(" ",split " ", $_); print "$_\n"; } __DATA__ [ [ 0.039543323] [ 0.068993981] [ 0.086558227] [ 0.12252527] [ 0.14724698] [ 0.16631099] [ 0.18877556] [ 0.20234162] [ 0.18110326] [ 0.13155017] [ -4.0316574] [ -3.6178487] [ -3.1186917] ]