in reply to Re: Pass arguments in URL
in thread Pass arguments in URL

Usage is more like this:
use URI; use strict; use warnings; my $hostname = 'localhost'; my $path = '/cgi-bin/details'; my $period = 4; my $vid = 11; my $person = 'abcdef'; my @args = ( period => $period, vid => $vid, person => $person ); my $url = URI->new("http://$hostname/"); $url->path($path); $url->query_form( \@args ); print $url->canonical;
The URI accessors do not support chaining.

Update: I misread the parent as using chained accessors, which it wasn't, this is just a little more verbose than that

Replies are listed 'Best First'.
Re^3: Pass arguments in URL
by ikegami (Patriarch) on Aug 23, 2010 at 19:24 UTC
    You changed
    ->query_form(@args);
    to
    ->query_form(\@args);
    but both are ok. So that leaves the bad return value. Fixed:
    use URI qw( ); sub url_freeze { my $url = URI->new(shift, 'http'); $url->query_form(@_); return $url } my $url = url_freeze('/cgi-bin/details', %args);

    It won't freeze recursively, of course.