Chris Knipe wrote:
So, this is more of a block question I think, but how I can get the above
example to show the help screen FIRST, and THEN complain about the missing
value for -s ????

Why?

Here's an example of how to do it:

#!/usr/bin/perl

use strict;
use warnings;

use File::Basename;
use File::Copy 'copy';

my $TmpDir = '/tmp';  # Change to 'C:\TEMP' for MS DOS

my $Self = basename( $0 );
my $SaveOutFile = "$TmpDir/$Self.$$.out";
my $SaveErrFile = "$TmpDir/$Self.$$.err";

open SAVE_OUT, ">&STDOUT";
open SAVE_ERR, ">&STDERR";

my $umask = umask 0600;
open STDERR, "> $SaveErrFile";
open STDOUT, "> $SaveOutFile";
umask $umask;

my $string = '';
unless( GetOptions(
  'help'  => \&ShowHelp,
  'b=s'   => \$string,
)){
  open STDOUT, ">&SAVE_OUT";
  open STDERR, ">&SAVE_ERR";
  copy( $SaveErrFile, STDERR );
  copy( $SaveOutFile, STDOUT );
  ShowHelp;
}

if( $string ){
  open STDOUT, ">&SAVE_OUT";
  open STDERR, ">&SAVE_ERR";
  copy( $SaveErrFile, STDERR );
  copy( $SaveOutFile, STDOUT );

  # Place string munging here

}else{
  open STDOUT, ">&SAVE_OUT";
  open STDERR, ">&SAVE_ERR";
  ShowHelp;
  copy( $SaveErrFile, STDERR );
  copy( $SaveOutFile, STDOUT );
}

__END__


--

Just my 0.00000002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to