in reply to How to remove trailing white space when =~ s/\s+$//g; doesn't work
sysread($rh,$buf,4096) || syslog ( "crit", "$prog : $!" );
You do realize that if sysread returns 0 it is not a critical error and $! will not be set.
if($buf) {
You do realize that the string "0" is also false?
my $client_hostname=unpack('a*', $buf); $client_hostname =~ s/\s+$//g;
If you change the unpack format from 'a*' to 'A*' you won't need the substitution on the next line and it will also remove "\0" characters.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to remove trailing white space when =~ s/\s+$//g; doesn't work
by Plankton (Vicar) on Oct 22, 2010 at 22:04 UTC |