#!/usr/bin/perl

## search in code

use strict;
use warnings;

my $term=shift;
if(not $term) {
  print "I need a search term.";
  exit;
}

foreach my $line (`grep -r $term .`) {
  chomp $line;
  $line=~m|^([^:]+):\s*(\S+)|;
  my $file=$1;
  my $contents=$2;
  if($file=~m|~$|) {
    next;
  }
  if($file=~m|/obsolete/|) {
    next;
  }
  if($contents=~m|^#|) {
    next;
  }
  print "$line\n";
}
