#!/usr/bin/perl -w use strict; sub do_something { print "This is what I do.\n"; exit; } $SIG{INT} = \&do_something; while (1) {}