Perl - Retrieving and Printing Security Token

My script below is supposed to log in to my vB account on any vB forum I'm registered on and retrieve + print my security token. However it seems to be hit and miss. The logging in works perfectly just will not retrieve and print the security token for every forum I log in to. Code Below:

#!/usr/bin/perl
use LWP::UserAgent;

my $ua = LWP::UserAgent->new(agent => q{Mozilla/5.0 (Windows; U;  Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET  CLR 3.5.30729)});
$ua->cookie_jar({});

print("Specify site URL(e.g http://site.com/): ");
chomp(my $url = <>);
print("Username: ");
chomp(my $username = <>);
print("Password: ");
chomp(my $password = <>);

my $req = HTTP::Request->new(POST => $url . '/login.php?do=login');
$req->content_type('application/x-www-form-urlencoded');
$req->content("vb_login_username=$username&vb_login_password=$password&do=login&securitytoken=guest&vb_login_md5password=&vb_login_md5password_utf=&s=");
$ua->request($req);
my $content = $ua->get("$url/index.php")->content;
my ($securityToken) = $content =~ /value="\w{10}-\w{40}" /g;
print "Security token: $securityToken\n";

You're script seems to work for me - I've just tested it with The UNIX and Linux Forums - Learn UNIX and Linux from Experts, it printed out the security-id. If it still doesn't work for you, try to print and post the content of the variable $content:

my $content = $ua->get("$url/index.php")->content;

print $content, "\n";

Yes, this is resolved. Silly mistake on my behalf. However a question I do have is there a way to show you have JS(javascript) enabled within perl?

As far as I know LWP::UserAgent doesn't parse or evaluate JavaSript.
You could find more details on how you could eventually handle such situations here.