#!/bin/env perl use strict; use warnings; # toy filter that replaces USC with an img tag my $FORMAT_FUNC = $ARGV[0]; # name of format function is passed in while() { chomp; if ($_ =~ s/USC//g ) { # argv[0] is the name of the formatting function if ($FORMAT_FUNC =~ m/groff/) { printf("'nf\n%s\n'fi\n",$_); } else { printf("%s\n",$_); } } else { printf("%s\n",$_); } }