Short version:  Copy/paste code from list emails brings undesired characters; 
I discovered a Perl fix for it.
--

Detailed (and longer) version:  Maybe my Kmail is doing it (I copy from Kmail 
and paste into editor).

I tried two editors, Kate and Nedit so I don't think the editor is the cause.

In emails I'm receiving from this list when I've copy/pasted into editor then 
save the file as Perl script gives the file many of the decimal 160 (as 
reported by perltidy) characters.  Perl (when attempt to run said script) 
reports such character on the commandline as xA0

For the longest time, in the regex, I didn't know that escaping the xA0 would 
make it work.

At the second post here:

http://groups.google.com/group/comp.lang.perl.misc/browse_thread/thread/20efe0eb94261eb4/8ce717433dd53b18?q=xA0&rnum=7#8ce717433dd53b18

I saw and then tried (code enclosed belowthe escape of xA0 and it works!

I'm most certainly open to any further suggestions/ideas/tips.

#!/usr/bin/perl -w
use strict;

my $old = shift;
my $new = "$old.tmp";
open(OLD, "<", $old)  or die "cant open $old: $!";
open(NEW, ">", $new)  or die "cant open $new: $!";
while (<OLD>) {

$_ =~ s/\xA0/ /g; # xA0 to space

print NEW $_;
}
close(OLD)  or die "cant open $old: $!";
close(NEW)  or die "cant close $new: $!";
rename($old, "$old.orig")  or die "cant rename $old to $old.orig: $!";
rename($new, "$old")  or die "cant rename $new to $old: $!";
# end

-- 
Alan C

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to