I tried to fetch the file with folder name(i.e pro) and location(i.e “/c/lol/ap/a/ds/crent/stup/pjects/DEMO/mfile.txt) and run the script(i.e perl readfile.pl) using command line arguments.So i tried for the following sample script by my own.But i feel my script is totally wrong.Could anyone help me the right way to approach.
Sample Script:(perl readfile.pl)
use strict;
use warnings;
use Getopt::Long qw(GetOptions);
my $pro;
my $mfile;
my $odir;
GetOptions('pro' => \$pro) or die "Usage: $0 --pro\n";
GetOptions('mfile' =>\$mfile) or die "Usage:$0 --mfile\n";
GetOptions('odir' =>\$odir) or die "Usage:$0 --odir\n";
print $pro ? 'pro' : 'no pro';
Error:
Unknown option: mfile
Unknown option: odir
Usage: readfile.pl --pro
To run command line as follows :
I should create the script to run the command line as follows.
perl readfile.pl -pro “pr1” -mfile “/c/lol/ap/a/ds/crent/stup/pjects/DEMO/mfile.txt” -odir “/home/html_files”