http://www.perlmonks.org?node_id=496268

ghenry has asked for the wisdom of the Perl Monks concerning the following question:

Dear Master Monks,

Why does pod2usage("$0: No files given.") if ( ( @ARGV == 0 ) && ( -t STDIN ) ); render my menu useless?

#!/usr/bin/perl ########################################################## # # # Author: Gavin Henry # # Web: http://www.perl.me.uk # # # # Version: 0.1 - 29.09.05 # # # # Quick wrapper script to convert an avi # # to a dvd image, using howto at: # # # # http://mightylegends.zapto.org/dvd/dvdauthor_howto.php # # # # Licence: GPL # # # ########################################################## use strict; use warnings; use IO::Prompt; use Pod::Usage; use Getopt::Long; # Straight from the Pod::Usage docs ###################### my $man = 0; my $help = 0; ## Parse options and print usage if there is a syntax error, ## or if usage was explicitly requested. GetOptions( 'help|?' => \$help, man => \$man ) or pod2usage(2); pod2usage(1) if $help; pod2usage( -verbose => 2 ) if $man; ## If no arguments were given, then allow STDIN to be used only ## if it's not connected to a terminal (otherwise print usage) pod2usage("$0: No files given.") if ( ( @ARGV == 0 ) && ( -t STDIN ) ) +; ########################################################## # After we have tested to see we were given a filename and to be # used for later my $avi = $ARGV[0]; # use menu option from IO::Prompt my $choice = prompt 'Please choose your format...', -1, -menu => [ 'PAL', 'NTSC', 'Quit', ]; print "You chose: [$choice]\n\n"; # This is where all the encoding will go once I have figured # out what's wrong with the menu above if ( $choice eq 'PAL' ) { print "You must be in Europe or Australia, encoding to PAL format\ +n"; } elsif ( $choice eq 'NTSC' ) { print "You must be in America, encoding to NTSC format\n"; } elsif ( $choice eq 'Quit' ) { print "Bye, bye\n"; exit 0; } else { print "Nothing selected.\n"; exit 0; } __END__ =head1 NAME avi2dvd - a Perl wrapper script for converting an avi to dvd image =head1 SYNOPSIS ./avi2dvd avifile =head1 DESCRIPTION Following http://mightylegends.zapto.org/dvd/dvdauthor_howto.php I got sick of typing all the commands, so wrote this little wrapper script. It uses: IO::Prompt Pod::Usage Getopt::Long =head1 SEE ALSO http://mightylegends.zapto.org/dvd/dvdauthor_howto.php =head1 VERSION This man page documents avi2dvd version 0.1 =head1 CREDITS Rick Harris: http://mightylegends.zapto.org/dvd/dvdauthor_howto.php =head1 AUTHOR name : Gavin Henry email : ghenry at perl dot me dot uk web : http://www.perl.me.uk PM : http://aberdeen.pm.org =head1 COPYRIGHT Copyright (c) 2005 by Gavin Henry =head1 LICENSE This package is free software; you can redistribute it and/or modify i +t under the terms of the "GNU General Public License". Please refer to http://www.gnu.org/licenses/gpl.txt for details. =head1 DISCLAIMER This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "GNU General Public License" for more details.
Thanks.

Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!