in reply to sysread and null characters
I'm trying to figure out why you want the "++$i" on your sysread line. Eliminate that - you'll probably be much closer to what you want.
What's happening is that you're reading into an offset of $digit. Perl sees that $digit is empty, and prepends all the nulls to that point.
Then you won't need to do any funkiness. Such as the next bit, which I'll pretend is still needed (it shouldn't be):
You're assigning $digit to the global $_, then changing the digit in it to ... itself (and not changing anything else), then reassigning back. Choices:$_ = $digit; s/(\d)/$1/; $digit = $_;
Hope that helps!#1 $_ = $digit; s/.*(\d).*/$1/; # change everything to the captured digit $digit = $_; #2 $_ = $digit; m/(\d)/ && $digit = $1 # change $digit to be the captured digit #3 $digit =~ m/(\d)/ && $digit = $1 #4 $digit =~ s/.*(\d).*/$1/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sysread and null characters
by ggg (Scribe) on Mar 24, 2005 at 15:58 UTC | |
by Tanktalus (Canon) on Mar 24, 2005 at 16:31 UTC | |
by ggg (Scribe) on Mar 24, 2005 at 17:18 UTC | |
by Tanktalus (Canon) on Mar 24, 2005 at 18:10 UTC | |
by ggg (Scribe) on Mar 24, 2005 at 18:50 UTC |