dReKurCe has asked for the wisdom of the Perl Monks concerning the following question:
#! /usr/bin/perl use LWP; use HTTP::Request; use HTTP::Response; use HTML::Form; $con=new LWP::UserAgent; $con->agent('n3u7digit'); $request=new HTTP::Request(GET=>"http://www.<site>.org"); $reply=$con->request($request); @forms=HTML::Form->parse($reply); for $formh(@forms){@keys=keys %$formh; for $name(@keys){ print "\t---$name\n"; } }
....the second version ..
for $formh(@forms){@keys=values %$formh; for $name(@keys){ process($name); print "--$name--\n"; } + sub process{$return=shift;return $return;}
the output: CASE 1
CASE 2---enctype ---action ---method ---attr ---inputs ---enctype ---action ---method ---attr ---inputs
So the utility of a closure seems evident, but why?--application/x-www-form-urlencoded-- --http:/<site>.org/-- --GET-- --HASH(0x84d3d4c)-- --ARRAY(0x85190e4)-- --application/x-www-form-urlencoded-- --http://<site>.org/en/video?destination=node%xxxxxx-- --POST--- --HASH(0x852232c)-- --ARRAY(0x852ac40)--
#! /usr/bin/perl use LWP; use HTTP::Request; use HTTP::Response; use HTML::Form; $con=new LWP::UserAgent; $con->agent('n3u7digit'); $request=new HTTP::Request(GET=>"http://www.<site>.org"); $reply=$con->request($request); @forms=HTML::Form->parse($reply); for $formh(@forms){@keys=values %$formh; for $name(@keys){ process($name); print "--$name--\n"; } sub process{ $return=shift; return $return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::Form Phenomena
by eric256 (Parson) on Mar 28, 2007 at 13:37 UTC | |
|
Re: HTML::Form Phenomena
by Anno (Deacon) on Mar 29, 2007 at 08:35 UTC |