| Bio-Das documentation | Contained in the Bio-Das distribution. |
Bio::Das::Util - Das Utilities
none
This module contains yet another implementation of the rearrange() call, which is used to convert -name=>argument style argument passing into positional arguments.
Lincoln Stein <lstein@cshl.org>.
Copyright (c) 2004 Cold Spring Harbor Laboratory
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.
Bio::Das::Request, Bio::Das::HTTP::Fetch, Bio::Das::Segment, Bio::Das::Type, Bio::Das::Stylesheet, Bio::Das::Source, Bio::RangeI
| Bio-Das documentation | Contained in the Bio-Das distribution. |
package Bio::Das::Util; use strict; require Exporter; use Carp 'croak'; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); @ISA = qw(Exporter); @EXPORT = qw(rearrange); @EXPORT_OK = qw(rearrange); $VERSION = '0.01'; # utility routine sub rearrange { my($order,@param) = @_; return unless @param; my %param; if (ref $param[0] eq 'HASH') { %param = %{$param[0]}; } else { return @param unless (defined($param[0]) && substr($param[0],0,1) eq '-'); my $i; for ($i=0;$i<@param;$i+=2) { $param[$i] =~ s/^\-//; # get rid of initial - if present } %param = @param; # convert into associative array } my(@return_array); local($^W) = 0; my($key)=''; foreach $key (@$order) { my($value); if (ref($key) eq 'ARRAY') { foreach (@$key) { last if defined($value); $value = $param{$_}; delete $param{$_}; } } else { $value = $param{$key}; delete $param{$key}; } push(@return_array,$value); } push (@return_array,{%param}) if %param; return @return_array; } 1; __END__