Plankton has asked for the wisdom of the Perl Monks concerning the following question:
Dear Wise Monks,
I have this code ...
... where I read a string from a socket and write it out to the syslog but in my syslog I get this ...sysread($rh,$buf,4096) || syslog ( "crit", "$prog : $!" ); if($buf) { my $client_hostname=unpack('a*', $buf); $client_hostname =~ s/\s+$//g; syslog( "crit", "client_hostname=[$client_hostname]" ); } else {
... the space did not get truncated. Why?Oct 21 14:33:26 karen serverd[2384]: client_hostname=[onetwothree ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to remove trailing white space when =~ s/\s+$//g; doesn't work
by morgon (Priest) on Oct 21, 2010 at 22:45 UTC | |
|
Re: How to remove trailing white space when =~ s/\s+$//g; doesn't work
by halfcountplus (Hermit) on Oct 21, 2010 at 22:11 UTC | |
|
Re: How to remove trailing white space when =~ s/\s+$//g; doesn't work
by jwkrahn (Abbot) on Oct 22, 2010 at 01:30 UTC | |
by Plankton (Vicar) on Oct 22, 2010 at 22:04 UTC | |
|
Re: How to remove trailing white space when =~ s/\s+$//g; doesn't work
by snape (Pilgrim) on Oct 21, 2010 at 23:13 UTC | |
by Anonymous Monk on Oct 21, 2010 at 23:36 UTC | |
|
Re: How to remove trailing white space when =~ s/\s+$//g; doesn't work
by Anonymous Monk on Oct 22, 2010 at 02:55 UTC |