lkml.org 
[lkml]   [1998]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: /proc/cpuinfo consistency

bad boy, always use chomp() :)

--Jauder

On Mon, 21 Sep 1998, Keith Owens wrote:

> regex is your friend. In perl
>
> while (<>) {
> chop();
> $cpu = $2 if (/^cpu( family)?\s*:\s*(\S*)/i);
> $model = $1 if (/^model\s*:\s*(\S*)/i);
> $model_name = $1 if (/^model name\s*:\s*(\S*)/i);
> $bogomips += $1 if (/^bogomips\s*:\s*(\S*)/i);
> }
>
> $cpu = $model_name if($model_name);
> print "cpu=$cpu\n";
> print "bogomips=$bogomips\n";
>


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.063 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site