http://www.perlmonks.org?node_id=1017105

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

I found a perl script that sends sms using a third party free website. It was working fine until today. Today i noticed that the "div tag id" used to get the access of the textbox to enter the sender's phone number is changed from static to dynamic, ie, the id is dynamically generated so i can no longer use the static id. I am using the WWW::Mechanize to access the forms,so can ou tell me how do i obtain a variable value that is dynamically generated in a webpage and use in my perl script. Here is the complete sample code that i am using:

#!/usr/bin/perl use WWW::Mechanize; use Compress::Zlib; my $mech = WWW::Mechanize->new(); my $username = ""; #fill in username registered here my $keyword = ""; #fill in password here my $opt="-f"; my ($text,$mobile,$option); my @mobilenos; my $morenos = $ARGV[0]; @mobilenos = $morenos; $text = $ARGV[1]; $deb = 1; print "Total Character of message is ".length($text)."\n" if($deb); $text = $text."\n\n\n\n\n" if(length($text) < 135); $mech->get("http://wwwl.way2sms.com/content/index.html"); unless($mech->success()) { exit; } $dest = $mech->response->content; print "Fetching...\n" if($deb); if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); $mech->update_html($dest); } $dest =~ s/<form name="loginForm"/<form action='..\/Login1.action' nam +e="loginForm"/ig; $mech->update_html($dest); $mech->form_with_fields(("username","password")); $mech->field("username",$username); print "Loggin...\n" if($deb); $mech->submit_form(); $dest= $mech->response->content; if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); $mech->update_html($dest); } foreach $mobile (@mobilenos){ # for loop begins chomp($mobile); print "\nMessage sending to ".($mobile)."\n"; $mech->get("http://wwwl.way2sms.com//jsp/InstantSMS.jsp?val=0"); $dest= $mech->response->content; if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); $mech->update_html($dest); } print "Sending ... \n" if($deb); ####I AM UNABLE TO GET THE FORM WITH FIELD MobNo AS ITS rqMob WHOSE VA +LUE IS DYNAMICALLY GENERATED##### $mech->form_with_fields(("MobNo","textArea")); $mech->field("MobNo",$mobile); $mech->field("textArea",$text); $mech->submit_form(); if($mech->success()) { print "Done \n" if($deb); } else { print "Failed \n" if($deb); exit; } $dest = $mech->response->content; if($mech->response->header("Content-Encoding") eq "gzip") { $dest = Compress::Zlib::memGunzip($dest); #print $dest if($deb); } if($dest =~ m/successfully/sig) { print "Message sent successfully \n" if($deb); } # foreach loop ends } print "Message sent to all the numbers\n Bye.\n"; exit; #EOF
To run the script i type: ./sms.pl phone_number_of_reciever 'message_to_be_sent' . PLEASE HELP ME WITH THIS PROBLEM AS THIS IS A IMPORTANT PART OF MY PROJECT. THANKS IN ADVANCE..