Questions about this topic? Sign up to ask in the talk tab.

Difference between revisions of "Perl/Basics/User Input/Command Line/Getopt::Long/Code"

From NetSec
Jump to: navigation, search
(Created page with "{{code|text=<source lang="perl"> use strict; use warnings; use Getopt::Long; my $message, $boolean; GetOptions('message=s' => \$message, 'boolean' => \$boolean); print $message...")
 
(No difference)

Latest revision as of 04:14, 16 July 2012

 
use strict;
use warnings;
use Getopt::Long;
 
my $message, $boolean;
GetOptions('message=s' => \$message, 'boolean' => \$boolean);
 
print $message . "\n";
print "The boolean -b option was set!\n" if defined $boolean;
print "The boolean -b option was not set!\n" if undef $boolean;