Subject: | Problem passing arguments to backends |
Date: | Tue, 29 Jun 2010 11:12:37 +1200 |
To: | <bug-Net-xFTP [...] rt.cpan.org> |
From: | "Paul Findlay" <Paul.Findlay [...] fonterra.com> |
Hi again
I am trying to pass arguments through to backends to provide the SSH
identity file for example:
my $xftp = Net::xFTP->new(
'Net::SFTP::Foreign',
$config->{remote_host},
Debug => $PINS::Debug::g_debug_level,
user => $config->{user},
foreign_more => [-i => $file]
);
But your argument parsing code passed foreign_more unmodified so
Net::SFTP::Foreign throws an error.
I replaced all instances of this:
foreach $i (keys %args)
{
foreach $j (@supported_mods)
{
if ($i =~ /^${j}_/o)
{
if ($j eq 'local')
{
($t = $i) =~ s/^${j}_//;
$args{$t} = $args{$i};
}
delete $args{$i};
}
}
}
With this:
my $pattern = join('|', sort(@supported_mods));
$supported_arg = qr/\A($pattern)_(.*)\Z/m;
...
foreach my $arg (keys %args)
{
my ($prefix, $key) = ($arg =~ $supported_arg);
next unless ($prefix && $prefix eq 'local');
$args{$key} = delete $args{$arg};
}
And it seems to work..
Regards
Paul Findlay
DISCLAIMER:
This email contains confidential information and may be legally privileged. If you are not the intended recipient or have received this email in error, please notify the sender immediately and destroy this email.
You may not use, disclose or copy this email or its attachments in any way.
Any opinions expressed in this email are those of the author and are not necessarily those of the Fonterra Co-operative Group.
http://www.fonterra.com/