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/
Sooraj S [ Di, 27 Juli 2010 16:28 ] [ ID #2045217 ]

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/
Jim Gibson [ Di, 27 Juli 2010 19:47 ] [ ID #2045221 ]
Perl » gmane.comp.lang.perl.beginners » doubts in using Getopt in perl

Vorheriges Thema: usage of Split
Nächstes Thema: array to hash array