1 |
One thing I want to say - avoid using perl at all costs. |
2 |
Even though Perl is pretty much standard on any Linux machine these days, |
3 |
there are still situations where one may not want it. For one thing, I |
4 |
don't want |
5 |
to be building perl during stage building, just so that some ebuild can |
6 |
run one-line |
7 |
script with it ;-) |
8 |
|
9 |
Ed Grimm wrote: |
10 |
|
11 |
>On Thu, 18 Nov 2004, kosmikus wrote: |
12 |
> |
13 |
><snip what everyone's talked about already> |
14 |
> |
15 |
> |
16 |
> |
17 |
>>function get-memory-total() { |
18 |
>> cat /proc/meminfo | grep MemTotal | sed -r "s/[^0-9]*([0-9]+).*/\1/" |
19 |
>>} |
20 |
>> |
21 |
>> |
22 |
> |
23 |
>cat | grep | (sed|awk) lines have always bothered me to no end. How |
24 |
>about, instead, one of the following function bodies: |
25 |
> |
26 |
> awk '/MemTotal/ { print $2}' /proc/meminfo |
27 |
> sed -r -e '/MemTotal/!d' -e 's/[^0-9]*([0-9]+).*/\1/' /proc/meminfo |
28 |
> perl -ne '/MemTotal:\s+(\d+)/ && print "$1\n"' /proc/meminfoo |
29 |
> grep MemTotal | (read tag size units; echo $size) |
30 |
> |
31 |
>Normally, I wouldn't bring it up, but there's *so* many ways to do that |
32 |
>better, it's sad. Note that I could've listed many more, but that |
33 |
>would've been sad as well. (Actually, even this much is somewhat sad.) |
34 |
>Personally, I'd vote for the first or third of this group. |
35 |
> |
36 |
>Ed |
37 |
> |
38 |
>-- |
39 |
>gentoo-dev@g.o mailing list |
40 |
> |
41 |
> |
42 |
> |
43 |
> |
44 |
|
45 |
|
46 |
-- |
47 |
gentoo-dev@g.o mailing list |