#!/usr/bin/perl use strict; use warnings; use Pod::Usage; pod( -pod => 'test', -verbose => 2 ); sub pod { my(%options)= @_; my $pod_text; SWITCH: for ($options{-pod}) { /^main$/ && do { $pod_text=<<'POD'; =head1 NAME Main =head1 SYNOPSIS main.pl [options] =head1 DESCRIPTION This is main =cut POD last SWITCH; }; /^test$/ && do { $pod_text=<<'POD'; =head1 NAME Test =head1 SYNOPSIS Test.pl [options] =head1 DESCRIPTION This is Test =cut POD last SWITCH; }; return; } delete $options{-pod}; delete $options{-input}; open my $pod_file, '<', \$pod_text; pod2usage( -input => $pod_file, %options ) }