[ILUG] Linux desktop percentage
kevin lyda
kevin+dated+1032116047.501b9b at ie.suberic.net
Tue Sep 10 19:54:13 IST 2002
On Tue, Sep 10, 2002 at 06:30:30PM +0100, Paul Jakma wrote:
> On Tue, 10 Sep 2002, kevin lyda wrote:
> and look at the below! perl is just such a damn ugly language! awk is
> much nicer on the eye, and there's nothing that perl has that awk
> doesnt that a few years of polishing and developing a library of
> modules wouldnt fix.
awk is a subset of perl.
> > kevin at owsla( 5:57)% perl -ne '$m.=$_;
> what on eath is "$m.=$_" and why on earth would anyone love syntax
> like that? :)
the scalar variable "m" has the scalar variable _ appended to it.
i'm using the -n flag to perl which has it implicitly loop over the input.
without -n the loop could be written like so:
while ($line = <>) {
$m = $m . $line;
}
however it's a "one liner" so i used a shorthand.
> > $m=~/^From: (.*?)$/m;
> > $s{$s=$1}=1;
> urg.... that is just sick. :)
how? the hash part or using the result value of an assignment?
that's possible in awk:
awk 'END {a=3;print a, a=5, a}' /dev/null
3 5 5
interestingly enough similar code in perl and c give different results:
% perl -ne 'END {$a=3;printf "%d %d %d\n", $a, $a=5, $a}' /dev/null
5 5 5
% cat foo.c
main(){int a=3;printf("%d %d %d\n", a, a=5, a);}
% ./foo
5 5 3
of course that's all related to order of evaluation. the perl code you
pointed out is pretty straightforward.
> > $m=~
> > /(Mailer|User-Agent).*(Microsoft|QUALCOMM|DMailWeb|WebMail)/m
> > ) {
> You've missed "Internet Mail".
/(Mailer|User-Agent).*(Microsoft|QUALCOMM|DMailWeb|WebMail|Internet Mail)/m
better?
kevin
--
kevin at suberic.net that a believer is happier than a skeptic is no more to
fork()'ed on 37058400 the point than the fact that a drunken man is happier
meatspace place: home than a sober one. the happiness of credulity is a
http://ie.suberic.net/~kevin cheap & dangerous quality -- g.b. shaw
More information about the ILUG
mailing list