On Wed, Dec 05, 2007 at 04:31:55PM +0100, Kjeldgaard Morten wrote:
1. perl's startup costs compared to awk isn't that high, unless
you require a whole slew of modules... . In addition, you should
prefer whatever's more likely to have been recently used, as that's
what already is paged in. If dpkg.* avoids .*awk and sed, but uses
perl throughout, perl's suddenly VERY cheap.
2.
> board. Then I came up with another suggestion:
>
> sed 's/.*(//; s/-.*//;q' < changelog
>
> Let's examine the regexp again. It is a series of "substitute"
> statements, separated by semicolons. These are executed on every line
> in the file. The first deletes everything up to, and including, the
> first '('. The next deletes from the dash to end-of-line. The third
> statement quits the program after the first line.
>
> But persia was still not happy. He was using his MOTU powers, driving
> me forward, at every step, for perfection! I started to look at
> persia's oneliner again, and finally got it twisted so it worked for me:
>
> sed 's/.*(\(.*\)-.*).*/\1/;q' < changelog
>
> Let's analyse the regexp again. We are using "grouping" again, but
> unlike awk (unfortunately) sed has a reversed interpretation of
> parentheses. In sed, they have to be escaped to signify a grouping.
> Inside the first pair of /'s is the regexp that recognized the whole
> first line. There is a grouping around the characters between the '('
> and the '-' in that line, in other words, the version. The sed
> statement thus a substitution, where the whole line is replaced by
> grouping 1, which is referenced as an escaped nr. 1. Voila!
you DID notice that the semantics of the 2 sed statements have
a very significant difference for some nice version strings. Plus
nice failures. Such as
base-files 4.0.0ubuntu5
a2ps 1:4.13c~rc5-1 [hmmm. maintainer suffers from bit-rot?]
apache2-mpm-itk 2.2.3-04-3build4
automake 1:1.10+nogfdl-1
autotools-dev 20070306.1
hmmm. Maybe enforcing the use of a single centrally maintained
perl ain't that bad...
--
cu
Peter
[EMAIL PROTECTED]
--
Ubuntu-motu mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/ubuntu-motu