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
In reply to Re: Re: should this backspace removal code be done better?
by antirice
in thread should this backspace removal code be done better?
by smackdab
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |