November 24th, 2007

  • evan


At you will find an evening's hack by xaosenkosmos and me. Prompted by noticing in gcc's manual that identifiers may use $, we decided to see how much more Perl support we could do. The C file #includes the following program and runs it properly, without any preprocessing other than that built into GCC:
my $desc = "A wc-like program. Use 'perl -n < file'.";
my $letters;
my $lines;

sub process_line ($) {
  my $line = shift;
  $letters += length($line);


  printf("letters: %d; lines: %d\n", $letters, $lines);
You can browse the source of the C program for more information. We went to great pains for exact Perl syntax.