/* trivial grep implementation */ int main(string argv[]) { string buf, regexp; int ret = 1; // not found is default unless (regexp = argv[1]) die("usage: grep regexp [files]"); undef(argv[1]); // left shift down the args /* * Example perl goodness, the iterate through files and regexp */ while (buf = <>) { if (buf =~ /${regexp}/) { puts(buf); ret = 0; } } return (ret); }