[tpm] getopt question?

Jim Graham james.a.graham at gmail.com
Thu Aug 7 11:56:19 PDT 2008


Nice one!

Nothing like reinspecting the perldoc every once and a while to see  
new features.

BTW, Herman, the original code had some extraneous markers: you don't  
need 'f=s@' if you are pointing to an array reference (\@local_files).  
You only need the '@' if you are pointing to a scalar reference (\ 
$local_files) to tell Getopt::Long to put an array reference into that  
scalar.


Getopt::Long::GetOptions(
       'd:s' => \$dest_dir,
       'P:s' => \$port,
       'f=s@' => \@local_files, #-- replace with 'f=s' => \@local_files,
       'i=s' => \$dest_host,
       );

Jim



On 7-Aug-08, at 2:35 PM, Zoffix Znet wrote:

> Use this:
>
> Getopt::Long::GetOptions(
>        'd:s' => \$dest_dir,
>        'P:s' => \$port,
>        'f=s{,}' => \@local_files,
>        'i=s' => \$dest_host,
>        );
>
> print "@local_files\n";
>
> Note the '{,}' syntax. Keep in mind that the docs mark it as
> "experimental feature"
>
>
>
>
>
>
>
>
>
> On Thu, 2008-08-07 at 14:30 -0400, Herman Anker wrote:
>> Hi Jim,
>>
>> great suggestion,
>>
>> unfortunatly, I cannot split up that syntax because there are  
>> applications
>> calling it with
>>
>> perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming
>>
>>
>>
>>
>>
>>
>>             Jim Graham
>>             <james.a.graham at g
>>              
>> mail.com>                                                  To
>>             Sent by:                  toronto-pm at pm.org
>>             toronto-pm- 
>> bounce                                          cc
>>             s+hanker=ifdsgrou
>>             p.com at pm.org                                           
>> Subject
>>                                       Re: [tpm] getopt question?
>>
>>             08/07/2008 02:05
>>             PM
>>
>>
>>
>>
>>
>>
>>
>> Hi
>>
>>   Use multiple -f options
>>
>> $ perl_script -i ftp.host.com -f file1 -f files2 -p 760
>>
>>   - Jim
>>
>>
>> On 7-Aug-08, at 1:58 PM, Herman Anker wrote:
>>
>>>
>>> How do I get "file2" into @local_files???
>>>
>>> $ perl_script -i ftp.host.com -f file1 file2 -p 760 -d incoming
>>> file1
>>>
>>> ----------------------------------------------------
>>>
>>> Code:
>>> Getopt::Long::GetOptions(
>>>       'd:s' => \$dest_dir,
>>>       'P:s' => \$port,
>>>       'f=s@' => \@local_files,
>>>       'i=s' => \$dest_host,
>>>       );
>>>
>>> print "@local_files\n";
>>>
>>>
>>> Any suggestions appriciated.
>>>
>>>
>>> -----------------------------------------
>>> This e-mail and any attachments are intended only for the
>>> individual or company to which it is addressed and may contain
>>> information which is privileged, confidential and prohibited from
>>> disclosure or unauthorized use under applicable law.  If you are
>>> not the intended recipient of this e-mail, you are hereby notified
>>> that any use, dissemination, or copying of this e-mail or the
>>> information contained in this e-mail is strictly prohibited by the
>>> sender.  If you have received this transmission in error, please
>>> return the material received to the sender and delete all copies
>>> from your system.
>>> _______________________________________________
>>> toronto-pm mailing list
>>> toronto-pm at pm.org
>>> http://mail.pm.org/mailman/listinfo/toronto-pm
>>
>> _______________________________________________
>> toronto-pm mailing list
>> toronto-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/toronto-pm
>>
>>
>> _______________________________________________
>> toronto-pm mailing list
>> toronto-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/toronto-pm
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm



More information about the toronto-pm mailing list