Convert Perl to Java or C++

Discussion in 'Programming' started by phelixx, Jan 11, 2007.

  1. #1
    I have a perl script that needs converted into Java or C++ any takers? or anyone know a place where i can find someone to do something like this?
     
    phelixx, Jan 11, 2007 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Hmm... how big is it? Post the Perl Script here if it's under 150 lines and we could probably convert it for yah :)
     
    ccoonen, Jan 12, 2007 IP
  3. bhavi

    bhavi Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Can u pls convert this Perl script into java or C++?
    thank u... pls help

    #!/usr/bin/perl
    use LWP::UserAgent;
    use HTTP::Cookies;
    use HTTP::Request::Common;

    $URL = "https://www.example.com/w/signup.php";
    $UA = LWP::UserAgent->new();
    $myCookies = HTTP::Cookies->new(
    file => "cookies.txt",
    autosave => 1,
    ignore_discard => 1,
    );
    $UA->cookie_jar($myCookies);


    sub findCookie {
    my (
    $version, $key, $val, $path, $domain, $port,
    $path_spec, $secure, $expires, $discard, $rest
    ) = @_;

    if ( ( $domain eq $find::domain )
    and ( $path eq $find::path )
    and ( $key eq $find::key ) )
    {
    print "$version, $key, $val, $path, $domain, $expires\n";
    @find::cookie = @_;
    }
    }

    my $version = 0;
    my $key = "session_id";
    my $val = "1234567890abcdef";
    my $path = "/";
    my $domain = "example.com";
    my $expires = "123412345";

    $myCookies->set_cookie(
    $version, $key, $val, $path, $domain, undef,
    undef, undef, $expires, undef, undef
    );

    $req = HTTP::Request->new( GET => $URL );
    $UA->prepare_request($req);
    $resp = $UA->request($req);

    $find::domain = "example.com";
    $find::path = "/";
    $find::key = "session_id";

    $myCookies->scan( \&findCookie );
    if ( ( $domain eq $find::cookie[4] )
    and ( $path eq $find::cookie[3] )
    and ( $key eq $find::cookie[1] ) )
    {
    # We have one. See if it contains our value.
    if ( $val eq $find::cookie[2] ) {
    print "Test failed: cookie returned was ours.\n";
    } else {
    print "Test passed: cookie returned was new.\n";
    }
    } else {
    print "Test script failure: no matching cookie found.\n";
    }
     
    bhavi, Feb 8, 2010 IP