[Bio] / FigKernelPackages / ClientThing.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/ClientThing.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14, Thu Jul 29 17:35:51 2010 UTC revision 1.15, Mon Aug 9 13:46:06 2010 UTC
# Line 346  Line 346 
346      return $retVal;      return $retVal;
347  }  }
348    
349    =head3 FixOptions
350    
351        my %options = ClientThing::FixOptions(@options);
352    
353    This method allows more options for the specification of parameters to a server's
354    client module. First, the input can be specified as a hash or a hash reference,
355    and the keys can optionally have hyphens prefixed. (So, for example, the key
356    C<-url> would be converted to C<url>.)
357    
358    =cut
359    
360    sub FixOptions {
361        # Get the parameters.
362        my (@options) = @_;
363        # Create the return hash.
364        my %retVal;
365        if (@options == 1 && ref $options[0] eq 'HASH') {
366            my $optionHash = $options[0];
367            # Here the user specified a hash reference. Transfer its to
368            # the return hash, removing hyphens from key names.
369            for my $key (keys %$optionHash) {
370                if ($key =~ /^-(.+)/) {
371                    $retVal{$1} = $optionHash->{$key};
372                } else {
373                    $retVal{$key} = $optionHash->{$key};
374                }
375            }
376        } else {
377            # Here the user specified a regular hash. We need to convert it
378            # from a list.
379            for (my $i = 0; $i < @options; $i += 2) {
380                # Get the key of the current pair.
381                my $key = $options[$i];
382                # Strip off the hyphen (if any).
383                if ($key =~ /^-(.+)/) {
384                    $key = $1;
385                }
386                # Store the value with the key in the output hash.
387                $retVal{$key} = $options[$i + 1];
388            }
389        }
390        # Return the computed hash.
391        return %retVal;
392    }
393    
394  =head3 _call_method  =head3 _call_method
395    
396      my $result = $server->_call_method($method, $args);      my $result = $server->_call_method($method, $args);

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3