in reply to Re: should this backspace removal code be done better?
in thread should this backspace removal code be done better?
Small bug:
#!/usr/bin/perl -wl $s = "this is an\b\b not correct usage"; $s =~ s[.\cH][]g; print $s; print "and one's still there" if grep { ord == ord"\b" } split //,$s; __END__ output: this is not correct usage and one's still there
It looks correct at first glance, but the second backspace is still there.
Update: Much better. Only problem is in the case of a leading \b, you can get into an infinite loop. However only the regex needs alteration.
$s =~ s/(?:[^\cH]\cH|^\cH+)//g while ...
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: should this backspace removal code be done better?
by smackdab (Pilgrim) on Oct 05, 2003 at 06:46 UTC | |
by antirice (Priest) on Oct 05, 2003 at 07:07 UTC | |
by eyepopslikeamosquito (Archbishop) on Oct 05, 2003 at 07:59 UTC | |
by antirice (Priest) on Oct 05, 2003 at 08:27 UTC | |
by shenme (Priest) on Oct 05, 2003 at 10:18 UTC | |
by eyepopslikeamosquito (Archbishop) on Oct 05, 2003 at 07:38 UTC |