Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: string and sysread and read work differentlyby seattlejohn (Deacon) |
on Dec 24, 2002 at 00:29 UTC ( [id://222001]=note: print w/replies, xml ) | Need Help?? |
Is $ptr zero when you call sysread? What happens if you omit $ptr from the call?
If $ptr is nonzero, sysread is going to insert the characters into $c someplace other than the beginning of the string. I would suspect that $c gets filled from the left with chr(0) if needed, which is why ord then returns 0. If you wanted to reliably get the ordinal of the string you just read, I think you'd need to use something like my $x = ord(substr($c,$ptr,1));. Or get rid of $ptr (or make sure it's really 0) so you are actually reading into the beginning of $c. $perlmonks{seattlejohn} = 'John Clyman';
In Section
Seekers of Perl Wisdom
|
|