-----Original Message-----
From: Gisle Aas [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 03, 2002 10:48 PM
To: Keary Suska
Cc: Libwww Perl
Subject: Re: URI-1.22
Keary Suska <[EMAIL PROTECTED]> writes:
> I don't wish to complicate issues any, but it seems to me more sensible to
> specify the desired separator string as an optional parameter to the URI
> constructor.
I think this is a clever hack. If instead of constructing objects of
the URI class you create them of URI::Semi class then the query_form
method works as if ; was the separator.
Regards,
Gisle
---------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
{
package URI::Semi;
use URI;
use NEXT;
sub new {
my $class = shift;
my $self = URI->new(@_);
$class .= "::" . ref($self);
{
no strict 'refs';
my $isa = $class . "::ISA";
unless (@$isa) {
push(@$isa, "URI::Semi", ref($self));
}
}
bless $self, $class;
}
sub query_form {
my $self = shift;
my $tmp = URI::Ampify->new($self);
$self->NEXT::query_form(@_);
}
package URI::Ampify;
sub new {
my($class, $uri) = @_;
if (defined(my $q = $uri->query)) {
$q =~ s/;/&/g;
$uri->query($q);
}
bless \$uri, $class;
}
sub DESTROY {
my $self = shift;
if (defined(my $q = $$self->query)) {
$q =~ s/&/;/g;
$$self->query($q);
}
}
}
# test it
my $uri = URI::Semi->new("http://www.example.com?a=1;b=2");
print join(":", $uri->query_form), "\n";
print "$uri\n";
use URI::QueryParam;
$uri->query_param(foo => 1 .. 4);
print "$uri\n";