fame has asked for the wisdom of the Perl Monks concerning the following question:

I have a question.. I have perl bot thats uses IRC. One of the functions that I have it do upon a command is it opens a file with random emails and fills the form on a website.

This is how I have it read the file and select a random line.

open FILE, "emails.txt" or die "Error Opening: Cannot open file!"; @emails = <FILE>; close FILE; $email = $emails[int(rand($#emails + 1))];

This is how I have it form fill.

my $agent = WWW::Mechanize->new( autocheck => 1 ); my $formfiller = WWW::Mechanize::FormFiller->new(); $agent->env_proxy(); $agent->get('http://www.somewebsite.com'); $agent->form_number(2); $agent->current_form->value("email", "$email");

My problem is this: When it fills the form, it fills in the email address and the return html coding will look something like this:

name="email" id="email" value="blahblah@email.com

" size="35" maxlength="255" class="formFld" />

The email address is entered within the " " and then for some reason jumps to a next line like above. I need it for when it fills the form that it stays all on the same line within the " ". Example:

name="email" id="email" value="blahblah@email.com" size="35" maxlength="255" class="formFld" />

Does anyone have a solution for me? Any help would be GREATLY appreciated. Thanks

Replies are listed 'Best First'.
Re: Open file and formfill
by Anonymous Monk on Apr 26, 2012 at 04:07 UTC

    Hi,

    It looks like you've got some newlines in your $email. Check for this and, if they are there, remove them before proceeding.

    A simple regex should do the trick. I leave that to you.

    J.C.

      i solved problem with chomp();

      Thanks for your response J.C.