doubts in using Getopt in perl
Hi,
I have a script which copies files from local machine to remote
machine.
parameteres : "-d" for directories, "-f" for files..
GetOptions ('d=s{,}' => \ [at] dir,
'f=s{,}' => \ [at] fil);
I want one more rename option "-r" which should be used only if "-d"
is specified ie only for directories... Please help me..
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: doubts in using Getopt in perl
On 7/27/10 Tue Jul 27, 2010 7:28 AM, "Sooraj S"
<soorajspadmanabhan [at] gmail.com> scribbled:
> I have a script which copies files from local machine to remote
> machine.
> parameteres : "-d" for directories, "-f" for files..
>
> GetOptions ('d=s{,}' => \ [at] dir,
> 'f=s{,}' => \ [at] fil);
>
> I want one more rename option "-r" which should be used only if "-d"
> is specified ie only for directories... Please help me..
>
Which Getopt module are you using? (there are 91 on CPAN). The syntax looks
like Getopt::Long, but it is better to be sure.
What is the logic for combining the -d and -r arguments? Can you give some
examples?
Obviously, the following will parse a -r option:
GetOptions ('d=s{,}' => \ [at] dir,
'f=s{,}' => \ [at] fil,
'r=s{,}' => \ [at] rename,
);
It is then up to you to apply the logic for combining the elements of [at] dir
and [at] rename, taking into account the possible presence of -f arguments. To
help further, we would need to know the logic involved.
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/