I BioKid wrote:

I made it !!! Thanks to my buddy Arshad - Buddy you're a true-perl-buddy !!! Here comes an easy way, not exactly the way I want it - but I can do it this
way too,
After all :*There's more than one day to do it in perl*:We used
WWW::Mechanize module: A scrap version of the code we used  is here :

use WWW::Mechanize();
$me=new WWW::Mechanize();
$url='http://server.foo.com';
$me->get($url);
$aa=$me->content();
#open a file to get the output after passing my file - I wrote another
parser to extract the info i need
open(A,">goo1");
my $form = $me->form('1');
$me->set_fields( 'file name in the form' =>'ur file name');
$me->click_button(name=>'Submit');
$aa=$me->content();
#here is the file wiht the out put
print A $aa.'html';

Oi, clean that up :) and use strict and warnings and check for errors, don't use indirect objects either:

You'll liek this much better in 6 months when you have to revisit it:

#!/usr/bin/perl

use strict;
use warnings;
use WWW::Mechanize;

my $me  = WWW::Mechanize->new();
my $url = 'http://server.foo.com';

$me->get($url);

my $form = $me->form('1'); # you never use $form, why not ?
$me->set_fields( 'file name in the form' => 'ur file name' );
$me->click_button( name => 'Submit' );

# no need to set $aa befor the submit, not use itm then change it after the suubmit so hre you do it once
my $aa   = $me->content(); # what the heck is "aa"? use better names

open my $goo_fh, '>', 'goo1' or die "Could not open goo1: $!";
print {$goo_fh} $me->content(), 'html';
close $goo_fh;


Also, hwy not just do a post with LWP and have it save it to a file, it'd make all of that above in like one or two lines or so...

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to