Hi M, > I'm horrified by the code repetition. Doesn't Perl allow 'functions'?
Yes, that's those sub foo { ... } you see. It can also hold a regexp in a variable so a `$pid_regexp' could be defined once and used repeatedly. $ perl -e ' > $re = qr/^(food|drink|famine)\d*$/; > while (<>) { > /$re/ and print "$. $_"; > } > ' abc food 2 food drink42 3 drink42 xyz $ BTW, given your private email, you might be interested to know the Regular Expressions, of which regexps are an extension, are essentially a "little language" for describing a regular grammar, level 3 in Chomsky's hierarchy. These are grammars that can be matched with a finite-state automaton, and implementations are either non-deterministic, like Perl's, or deterministic, like Go's. As such, they're a succinct way of expressing many text matching problems, just as BNF is a convenient method for programming language grammars. It's interesting to compare the simple one above to the alternative long-hand imperative programming form. -- Cheers, Ralph. https://plus.google.com/+RalphCorderoy _______________________________________________ get_iplayer mailing list get_iplayer@lists.infradead.org http://lists.infradead.org/mailman/listinfo/get_iplayer