Statistics of OEIS
Michele Dondi
blazar at pcteor1.mi.infn.it
Thu Nov 18 15:18:53 CET 2004
> then (on unix systems) do:
> cat eisBTfry* | grep "^%A" | ./cauthor.pl | sort -n
You know, I'm not fanatic about not mixing perl with shell cmds and indeed
it can be useful in some cases. But it should not be abused, especially
not to do something that perl can perfectly do by iteself.
> where ./cauthor.pl is the following short peperl script.
>
> #!/usr/bin/perl -w
With recent enough perls it's much better to
use warnings;
instead. Also *always*
use strict;
for everything but possibly the most elementary one-liners.
> while(<>) {
> chop;
Aarhg!! Nowadays it's almost always better to use chomp() instead.
> s/ \(.*//;
> s/^...........//;
Huh?!? Ever heard about .{11}?!?
> for($i=0;$i<12;$i++) {
C-style C<for> loops are allowed but it's almost always more convenient to
use Perlish code in perl code:
for (0..11)
> s/[,]* $mon[$i] .*//;
Oh! then it could have been
for my $mon (@mon) {
# ...
s/,* $mon .*//
(it's also more efficient!)
BTW: no need for the charachter class [,]. But are you sure you want to
match on zero or more (including any number) commas? Isn't it that you
mean
s/,? $mon .*//;
instead?
> foreach $a (keys(%c)) {
> print "$c{$a} $a\n";
> }
Doesn't do any real harm here, but $a (as well as $b) shouldn't be used a
general purpose variable. See 'perldoc perlvar'.
All in all I'd rewrite the script as the one attached here. You can call
it directly as
./cauthor.pl eisBTfry00*
To be fair I've run noticed that there's such a variability in the %A
lines that parsing them reliably could be a hell. Of course in this sense
even my program is far from being perfect and would require at least some
more efforts to handle some cases...
HTH,
Michele
--
> Why should I read the fucking manual? I know how to fuck!
In fact the problem is that the fucking manual only gives you
theoretical knowledge which is useless in practice ;)
- Giuseppe "Oblomov" Bilotta on a bunch of usenet groups.
More information about the SeqFan
mailing list