-
-
Save eiro/dc2e8d620290ab4757b112b6c87f02cd to your computer and use it in GitHub Desktop.
lecture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub { @{shift->{TrafficChecker}{Proxy}}{qw(Protocol Host Port)} = qw(https hello.com 1212) } | |
sub { | |
map { @$_{qw(Protocol Host Port)} = qw(https hello.com 1212) }; | |
shift>{TrafficChecker}{Proxy} | |
} | |
sub ($self) { | |
map { @$_{qw(Protocol Host Port)} = qw(https hello.com 1212) }; | |
$self->{TrafficChecker}{Proxy} | |
} |
ta version
sub ($self) {
my ($config) = @_;
map { @$config{qw(Protocol Host Port)} = qw(https hello.com 1212) };
$self->{TrafficChecker}{Proxy}
}
est ... étrange: en plus d'être fausse
- soit tu utilises les signatures, soit tu déroule @_ mais pas les deux
- dans le map, c'est $_ qui doit être traitée
j'en conclus que le map n'était pas une bonne solution non plus ... est-ce que
sub ($config) {
my $proxy = $config->{TrafficChecker}{Proxy};
@$proxy{ qw(Protocol Host Port) } = qw(https hello.com 1212);
}
te semble plus lisible ? la version la plus lourdingue serait presque du php:
sub ($config) {
my $proxy = $config->{TrafficChecker}{Proxy};
$$proxy{Protocol} = 'https';
$$proxy{Host} = 'hello.com';
$$proxy{Port} = 1212;
return @$proxy{qw( Protocol Host Port )};
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C'est dur de ne pas voir explicitement ce qu'on reçoit du premier coup d'œil.
Avec la dernière je rajouterais