in reply to problems with the "switch" module

Your use for Switch.pm could be done as well with a dispatch table. That is a hash of code references, like so,

my %dispatch = ( SQUID => sub { $web_proxy = $proxy_address; }, EZPROXY => sub { if ($proxy_credentials){ ($user_name, $password) = split /\//, $proxy_credentials; $prefix = $proxy_address."user=$user_name&pass=$password& +url="; } else { $prefix = $proxy_address."url="; } } ); $dispatch{$proxy_type}->();
Your functions should take arguments and return values, rather than modifying global variables, but I didn't know enough about your app to change that.

CountZero++ is right, repaired. Paste confusion.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: problems with the "switch" module
by CountZero (Bishop) on Jul 10, 2006 at 18:20 UTC
    I think the $prefix = $proxy_address."url="; is part of the EZPROXY case, so it should go into the EZPROXY sub.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law