diff options
author | Daniel Stenberg <daniel@haxx.se> | 2001-05-28 21:49:45 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2001-05-28 21:49:45 +0000 |
commit | 7bb7550e23e70528f8c138d7e65275ac970a0351 (patch) | |
tree | 33b9529790820840843ed896f982177baae59a6f /tests/getpart.pm | |
parent | adf00f5b2e662241316fca8428c560a778974dbe (diff) | |
download | curl-7bb7550e23e70528f8c138d7e65275ac970a0351.tar.gz |
fixes
Diffstat (limited to 'tests/getpart.pm')
-rw-r--r-- | tests/getpart.pm | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/getpart.pm b/tests/getpart.pm index 1012ced5d..0edb6c9b5 100644 --- a/tests/getpart.pm +++ b/tests/getpart.pm @@ -3,6 +3,46 @@ use strict; my @xml; +sub getpartattr { + my ($section, $part)=@_; + + my %hash; + my $inside=0; + + # print "Section: $section, part: $part\n"; + + for(@xml) { + # print "$inside: $_"; + if(!$inside && ($_ =~ /^ *\<$section/)) { + $inside++; + } + elsif((1 ==$inside) && ($_ =~ /^ *\<$part([^>]*)/)) { + $inside++; + my $attr=$1; + my @p=split("[ \t]", $attr); + my $assign; + + foreach $assign (@p) { + # $assign is a 'name="contents"' pair + + if($assign =~ / *([^=]*)=\"([^\"]*)\"/) { + # *with* quotes + $hash{$1}=$2; + } + elsif($assign =~ / *([^=]*)=([^\"]*)/) { + # *without* quotes + $hash{$1}=$2; + } + } + last; + } + elsif((2 ==$inside) && ($_ =~ /^ *\<\/$part/)) { + $inside--; + } + } + return %hash; +} + sub getpart { my ($section, $part)=@_; @@ -16,7 +56,7 @@ sub getpart { if(!$inside && ($_ =~ /^ *\<$section/)) { $inside++; } - elsif((1 ==$inside) && ($_ =~ /^ *\<$part/)) { + elsif((1 ==$inside) && ($_ =~ /^ *\<$part[ \>]/)) { $inside++; } elsif((2 ==$inside) && ($_ =~ /^ *\<\/$part/)) { |