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

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

How can i write the usage function to run the file in perl.
./html.pl -root="/home/data/multiple/" -out="/home/data/output" -file= +"/home/data/file.txt"

I have the above perl file.I have to run the same file in the terminal as i mentioned above.How can i include usage of the script inside the perl file.
code which i have tried
use strict; use warnings; use Getopt::Long qw(GetOptions); sub usage { if (@_) { my ($msg) = @_; chomp($msg); print(STDERR "$msg\n"); } GetOptions( 'root=s' => \my $dir, 'out=s' => \my $out, 'file=s' => \my $file, ) or usage();