in reply to removing square brackets

perl -i -pe 'y/[]//d' yourfile
Boris

Replies are listed 'Best First'.
Re^2: removing square brackets
by kwaping (Priest) on Oct 20, 2005 at 14:49 UTC
    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.)
      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] ]