Programmation

python et perl: comparer ce qui est comparable ...

voici un petit comparatif qu'un sympatique collègue a bien voulu me transmettre ou le script python

import sys, os, string
for name in os.listdir('/proc'):
   path = os.path.join(os.path.join('/proc', name), 'status')
   if os.path.isfile(path):
      fp = open(path, 'r')
      st = fp.read()
      fp.close()
      print string.split(st)[0]

est réécrit en perl

perl -wle '
    open F, "$_/status"
        and print +(split/\s+/,<F>)[0]
        for </proc/*>
'

Syndiquer le contenu