#! /usr/local/bin/perl -w
print "Hello, world\n";
####
#! /usr/local/bin/perl -w
use strict;
my $thing = shift(@ARGV);
print "Hello, $thing\n";
##
##
#! /usr/local/bin/perl -w
use strict;
my $thing = shift;
print "Hello, $thing\n";
##
##
#! /usr/local/bin/perl -w
use strict;
my $thing = shift || 'world';
print "Hello, $thing\n";
##
##
#! /usr/local/bin/perl -w
use strict;
my $thing = shift or die "Nothing specified on the command line.\n";
print "Hello, $thing\n";
##
##
my $thing = shift || 'default';
##
##
my $thing = shift;
$thing ||= 'default' unless defined $thing;
##
##
#! /usr/local/bin/perl -w
use strict;
my( $switch, $thing );
$switch = shift;
if( $switch and $switch eq "-g" ) {
$thing = shift || 'world';
} else {
$thing = $switch || shift || 'world';
$switch = undef if $switch;
}
print $switch ? 'Goodbye' : 'Hello', ", $thing\n";
##
##
#! /usr/local/bin/perl -sw
use strict;
use vars qw/$g/;
my $thing = shift || 'world';
print $g ? 'Goodbye' : 'Hello', ", $thing\n";
##
##
#! /usr/local/bin/perl -w
use strict;
use Getopt::Std;
use vars qw/$opt_g/;
getopt('g');
my $thing = shift || 'world';
print $opt_g ? 'Goodbye' : 'Hello', ", $thing\n";
##
##
#! /usr/local/bin/perl -w
use strict;
use Getopt::Std;
my %args;
getopt('g', \%args);
my $thing = shift || 'world';
print $args{g} ? 'Goodbye' : 'Hello', ", $thing\n";
##
##
Getopt::Mixed::init( 'j=s l:s p=i s=s t=s logfile>l d>p date>p period>p project>
j type>t');
##
##
while( my( $option, $value, $pretty ) = Getopt::Mixed::nextOption() ) {
OPTION: {
$option eq 'j' and do {
$Project = $value;
last OPTION;
};
$option eq 'l' and do {
$Logfile = $value if $value;
last OPTION;
};
# ...
}
}
Getopt::Mixed::cleanup();
die "No project specified via -j.\n" unless $Project;