[EMAIL PROTECTED] writes:

> I've been using LWP::UserAgent to submit forms and come accross the
> situation where the form value I submit might contain ampersand character, &.
> It may contain anything but I'm stuck with this character first.   
> 
> Is there a way to do this.  Here is a sample code.
> 
> -------------------------------------
> $ua = LWP::UserAgent->new;
> $ua->agent("browser -infinity");
> $reqq = new HTTP::Request 'POST','http://bla.foo/sbin/halt';
> $reqq->content_type('application/x-www-form-urlencoded');
> $d='&';
> $form_data = "a=b&c=$d&e=f";
> $reqq->content($form_data);
> $A=$ua->request($reqq)->content;
> --------------------------------

If you use the HTTP::Request::Common module it will take care of the
escaping for you.

   use HTTP::Request::Common qw(POST);

   my $reqq = POST('http://bla.foo/sbin/halt',
                   [ a => "b",
                     c => $d,
                     e => "f",
                   ]);
   print $reqq->as_string; #DEBUG
   
   $A=$ua->request($reqq)->content;


> 
> Also is there any module like HTML::Escape analogous to URI::Escape?

It is called HTML::Entities.

> I searched for 'escape' on cpan and I just get URI::Escape.  What I
> want to do is translate back and forth between &#DD and regular characters.

Regards,
Gisle

Reply via email to