[rrd-users] Re: problems with "float" to rrd

Alex van den Bogaerdt alex at ergens.op.het.net
Sun Feb 22 01:53:36 MET 2004


On Sun, Feb 22, 2004 at 02:18:44AM +0200, mrugan wrote:

> in my perl script it would complain about:
> $procs=(`find /proc -maxdepth 1 -name '[1-9]*' -print | wc -l | sed 's/\t +//' | sed 's/ *//'`);
> which outputs with couple blank spaces.(if u try it u will see what i
> am talking about)  ... and the error was scalar to float ... something.

You are having problems with the usual unix tools.

First of all:
"\t +" ...  this matches a tab followed by one or more spaces. Why?

Check if your sed really cannot handle this more efficiently:

   sed 's/[\t ]*//'

(match tab or space, zero or more times)

   sed 's/\s*//'

(match whitespace, zero or more times)


Try to use a more efficient pipe:
  ls -d /proc/[1-9]* | wc -l
in stead of
  find /proc -maxdepth 1 -name '[1-9]*' -print | wc -l


OTOH I cannot reproduce your problem with both perl and bash:

[long lines wrapped; commands are all on one line]

bash$ find /proc -maxdepth 1 -name '[1-9]*' -print | wc -l |
                                   sed 's/\t +//' | sed 's/ *//'|od -tx1
0000000 32 39 35 0a
0000004

bash$ perl -e '$procs=(`find /proc -maxdepth 1 -name "[1-9]*" -print |
   wc -l | sed "s/\t +//" | sed "s/ *//"`);' -e 'print $procs' | od -tx1

0000000 32 39 32 0a
0000004

cheers,
Alex
-- 
begin  sig
http://www.googlism.com/index.htm?ism=alex+van+den+bogaerdt&type=1
This message was produced without any <iframe tags

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list