Too geeky

Matts on 2002-10-22T11:54:30

Am I too much of a perl geek? Whenever I have to do a calculation I never ever fire up the calculator - I always use:

  perl -le 'print ...'
Wbat lengths do you go to to use perl for any given problem?


system, system, system...

mir on 2002-10-22T12:12:11

The script I use to upload a new version of XML::Twig to my site:
#!/usr/bin/perl
use XML::Twig;

my $MIRROR_DIR = "/web/mirror/infotree/xmltwig";
my $WEB_DIR    = "mirlin:/web/infotree/";

my $version  = $XML::Twig::VERSION; # can't get this from the shell!
my $tar      = "XML-Twig-$version.tar.gz";
my $dev_text = "twig_dev.txt";
my $dev_html = "twig_dev.html";
my $readme   = "XML-Twig-$version.README";

system "make clean; rm Twig.pm; perl speedup Twig.pm.slow > Twig.pm; perl Makefile.PL; make";
sleep 2;
system "touch Twig.pm.slow; make tardist";
system "pod2text Twig.pm > $dev_text; pod2html Twig.pm > $dev_html";

system "cp $tar $dev_text $dev_html Changes $MIRROR_DIR/";

system "cp README $MIRROR_DIR/$readme";

# this one pushes it one step forward!
system "perl -i -p -e's{updated: [^)]*}{ q{updated: } . scalar localtime()}e;' $MIRROR_DIR/index.html";

system "scp -r $MIRROR_DIR $WEB_DIR";

lazier

darobin on 2002-10-22T12:52:13

Like you, I do my calculations from the shell using Perl, but I at least turned the "perl -le 'print...'" into a shell alias to make it easier to type ;)

Re:lazier

entropic on 2002-10-22T15:13:42

used to use solar calculator
then pen and paper
then xcalc
then perl -e 'print '
then just perl and typed on stdin
now bc

wish i knew about bc before

Re:lazier

darobin on 2002-10-22T15:21:37

I've known about bc before, but somehow I can't wrap my head around it... I know, it's probably due to my stupidity as I can't say it looks that difficult.

Maybe I'm not good at simple things, maybe that's why I now work where I do.

Hmmmmmm...

Debugger

jdavidb on 2002-10-22T17:35:25

My calculator is perl -de 1. Earlier this semester I had a bit of a disaster in software engineering class as I was sitting on the front row doing COCOMO calculations for the class and coming up with the wrong answer because I didn't understand the use of Perl's ** operator. :)

bc & awk

ask on 2002-10-23T01:08:08

Occassionlly I use shell scripts for build processes. Usually they grow into a perl thing though. Always using a system() wrapper that dies nicely on errors.

For calculations I use "bc". The 3 second bc guide will instruct you to use

scale=10

as your first command.

I also use awk '{print $1}' once in a while instead of "perl ... (split)[0]". Why? No clue. :-) The fingers are doing it.

dc

ziggy on 2002-10-23T16:24:56

I've been using dc for years. It got to the point where I had an xterm alias in my WindowMaker menu for dc that I used constantly.

Unfortunately, I don't have a three-key shortcut to bring up dc on OS X yet...