use Getopt::Long qw(GetOptions);
my %opts = ();
# Predeclare prototyped subs
sub debug(@);
GetOptions(\%opts,
'debug!',
);
debug "Success";
sub debug(@){
if($opts{debug}){
(my $str=join '',@_)=~s/\s*\z/\n/;
print $str;
}
}
Note:
Execute the script as follows:
perl command_line_switch.pl --debug
my %opts = ();
# Predeclare prototyped subs
sub debug(@);
GetOptions(\%opts,
'debug!',
);
debug "Success";
sub debug(@){
if($opts{debug}){
(my $str=join '',@_)=~s/\s*\z/\n/;
print $str;
}
}
Note:
Execute the script as follows:
perl command_line_switch.pl --debug
No comments :
Post a Comment