#!/usr/bin/perl -w use strict; my $file = shift or die "must supply body file"; open F, $file; my $text = join '', ; my $regex = '(procedure|function)\b(.*?)\((.*?)\)'; while ($text =~ /$regex/mgs) { print $1,$2,"($3);",$/; }