What language is this code?

Discussion in 'Programming' started by itisme1760, Oct 2, 2008.

  1. #1
    What language is this code and how can i compile it to an .exe?

    I have the .exe compiled already but I want to change a few things and recompile. What do would I need? Thanks, props if correct answer comes along!

    ###############################################################################
    #
    # Import "LWP::Simple" for basic network access - explicitly import the "$ua"
    # user-agent object, the "get" command to get web-page text, and the "getstore"
    # command to download files
    #
    ###############################################################################
    
    use LWP::Simple qw|$ua get getstore|;
    
    ###############################################################################
    #
    # Import "Parallel::Simple" for basic multi-threading - explicitly import the
    # "prun" command for forking processes
    #
    ###############################################################################
    
    use Parallel::Simple qw|prun|;
    
    ###############################################################################
    #
    # Initialize user-agent object; set network timeout parameter; set version
    #
    ###############################################################################
    
    $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)');
    $ua->timeout(30);
    my $version = '0.0.0.6';
    
    ###############################################################################
    #
    # Introduce the program name and version and cover basic functionality
    #
    ###############################################################################
    
    print 'PhotoFucket version ' . $version . "\n";
    print 'by phatBastard' . "\n\n";
    print 'PhotoFucket is a completely public source project developed for' . "\n";
    print 'educational purposes. This program illustrates using Perl\'s LWP' . "\n";
    print 'and Parallel modules along with regular expressions. The function' . "\n";
    print 'of the program is to "fusk" JPG images from photobucket.com by' . "\n";
    print 'using these Perl modules with basic procedural programming.' . "\n\n";
    print 'This program was originally written in Perl and is targeted for' . "\n";
    print 'Win32 and UNIX-style platforms. PhotoFucket is OS-independent.' . "\n";
    print 'It makes NO OS-dependent system calls for any purpose, meaning' . "\n";
    print 'the source code can run on ANY machine with a Perl interpreter' . "\n";
    print '(version >= 5.8.4, and you will need LWP and Parallel modules).' . "\n\n";
    print 'Feel free to modify and distribute this program as you like.' . "\n";
    print 'Enjoy, share, and learn!' . "\n\n\n"; 
    
    ###############################################################################
    #
    # Get username of target PhotoBucket account from user; verify valid account
    # and get random letter-number combo associated with user; display URL build
    #
    ###############################################################################
    
    my $id = '';
    my $random = 'FALSE';
    while ((length($id) < 1) || ($random eq 'FALSE'))
            {
            print "\n\nEnter target PhotoBucket username:       ";
            chomp ($id = <STDIN>);
    	$random = &getRandID(\$id);
            }
            
    print "\n[build: http://img.photobucket.com/albums/$random/$id/xx/]\n";
    
    ###############################################################################
    #
    # Get target photo album name from user (or none); display URL build
    #
    ###############################################################################
    
    my $album = '';
    my $albsym = '';
    while (length($album) < 2)
            {
            print "\n\nEnter target image album (-1 for none):  ";
            chomp ($album = <STDIN>);
            }
    if ($album == -1)
            {
            $albsym = "/";
            }
    else
            {
            $albsym = "/$album/";
            }
            
    print "\n[build: http://img.photobucket.com/albums/$random/$id$albsym]\n";
    
    ###############################################################################
    #
    # Get starting index number from user
    #
    ###############################################################################
    
    my $start = -1;
    while (($start < 0) || ($start > 99999))
            {
            print "\n\nEnter starting index number (0-99999):   ";
    	chomp ($start = <STDIN>);
            }
    
    ###############################################################################
    #
    # Build the base target URL to be used by the program during scanning
    #
    ###############################################################################
    
    $urlbase = "http://img.photobucket.com/albums/$random/$id/$album/";
    $urlbase =~ s%/-1/%/%;
    
    ###############################################################################
    #
    # Create and/or change path to a directory for target user's images
    #
    ###############################################################################
    
    $dirmake = $id."_Bucket";
    if (! -e $dirmake)
    	{
    	mkdir ($dirmake);
    	}
    chdir ($dirmake);
    
    ###############################################################################
    #
    # Initialize lists of commonly used camera filename prefixes
    #
    ###############################################################################
    
    my @pref0 = ('DCP', 'Dcp', 'dcp', 'DSC', 'Dsc', 'dsc', '_MG_', '_mg_', 'MVC',
                 'Mvc', 'mvc',);
    my @pref1 = ('DSCN', 'Dscn', 'dscn', 'CRIM', 'Crim', 'crim', 'DSCF', 'Dscf', 'dscf',
                 'PANA', 'Pana', 'pana', 'DSCI');
    my @pref2 = ('Dsci', 'dsci', 'PDRM', 'Pdrm', 'pdrm', 'CIMG', 'Cimg', 'cimg', 'IMAG',
                 'Imag', 'imag', 'IMGP', 'Imgp', 'imgp',);
    my @pref3 = ('', 'IMG_', 'Img_', 'img_', 'PICT', 'Pict', 'pict',  'IMAGE', 'Image',
                 'image', 'PICTURE', 'Picture');
    my @pref4 = ('picture', 'PHOTO_', 'Photo_', 'photo_', 'PIC', 'Pic', 'pic', 'PHOTO',
                 'Photo', 'photo', 'IMAGE_', 'Image_');
    my @pref5 = ('image_', 'PICTURE_', 'Picture_', 'picture_', 'PIC_', 'Pic_', 'pic_',
                 'PICT_', 'Pict_', 'pict_');
    
    ###############################################################################
    #
    # Fork to 17 child processes + parent process for scanning (18 Total)
    #
    ###############################################################################
    
    prun(
         sub {exit;},
         [ \&fuskAlbum, 5, \@pref0, \$start ],
         [ \&fuskAlbum, 4, \@pref1, \$start ],
         [ \&fuskAlbum, 4, \@pref2, \$start ],
         [ \&fuskAlbum, 1, \@pref3, \$start ],
         [ \&fuskAlbum, 2, \@pref3, \$start ],
         [ \&fuskAlbum, 3, \@pref3, \$start ],
         [ \&fuskAlbum, 4, \@pref3, \$start ],
         [ \&fuskAlbum, 5, \@pref3, \$start ],
         [ \&fuskAlbum, 1, \@pref4, \$start ],
         [ \&fuskAlbum, 2, \@pref4, \$start ],
         [ \&fuskAlbum, 3, \@pref4, \$start ],
         [ \&fuskAlbum, 4, \@pref4, \$start ],
         [ \&fuskAlbum, 5, \@pref4, \$start ],
         [ \&fuskAlbum, 1, \@pref5, \$start ],
         [ \&fuskAlbum, 2, \@pref5, \$start ],
         [ \&fuskAlbum, 3, \@pref5, \$start ],
         [ \&fuskAlbum, 4, \@pref5, \$start ]
        );
    
    &fuskAlbum(5, \@pref5, \$start);
    
    exit;
    
    ###############################################################################
    #
    # End main driver code
    #
    ###############################################################################
    
    ###############################################################################
    #
    # Procedure for scanning target album. Takes 3 arguments - number of zeroes
    # to use to fill in index numbers, list of camera filename prefixes, and a
    # starting index number. Returns control to main, but no explicit return value
    # used or needed.
    #
    ###############################################################################
    
    sub fuskAlbum($$$)
            {
    
    	#######################################################################
    	#
    	# Initialize variables lexically scoped to the procedure. "$limit" is
    	# determined by building a string of 9s equal in width to the size of
    	# the zero-filling for this process.
    	#
    	#######################################################################
    
            my $fill = shift (@_);
    	my $prefixes = shift (@_);
            my $track = shift (@_);
            my $limit = '';        
            for (my $j = 0; $j < $fill; $j += 1)
                    {
                    $limit .= '9';
                    }                
    
    	#######################################################################
    	#
    	# Begin iterating through index number range
    	#
    	#######################################################################
          
            while ($$track <= $limit)
                    {
    
    	#######################################################################
    	#
    	# Fill appropriate number of zeroes in the index number
    	#
    	#######################################################################
    
                    my $refill = $fill - length($$track);
                    for (my $i = 0; $i < $refill; $i += 1)
                            {
                            $$track = '0' . $$track;
                            }
    
    	#######################################################################
    	#
    	# Begin iterating through camera filename prefixes
    	#
    	#######################################################################
    
                    my $prefix = '';
                    foreach $prefix (@{$prefixes})
                            {
    
    	#######################################################################
    	#
    	# Establish URL target and corresponding filename to be used on local
    	# machine
    	#
    	#######################################################################
    
                            my $file = $prefix . $$track . '.jpg';
                            my $target = $urlbase . $file;
    
    	#######################################################################
    	#
    	# Detect duplicate image filename; create new unique filename
    	#
    	#######################################################################
    
                            my $dupe = 2;
                            print "\n" . 'Scan: ' . $target . "\n";
                            while (-e $file)
                                    {
                                    $file = $prefix . $$track . '_' . $dupe . '.jpg';
                                    $dupe += 1;
                                    }
    
    	#######################################################################
    	#
    	# Download the image (if it exists on PhotoBucket)
    	#
    	#######################################################################
    
                            getstore ($target, $file);
                            }
    
    	#######################################################################
    	#
    	# Increment the index number
    	#
    	#######################################################################
    
                    $$track += 1;            
                    }
    
    	#######################################################################
    	#
    	# Return control to main
    	#
    	#######################################################################
    
            return;
            }
    
    	#######################################################################
    	#
    	# End procedure code
    	#
    	#######################################################################
    
    ###############################################################################
    #
    # Procedure for getting the random letter-number combo associated with a
    # PhotoBucket user's account. Takes one argument - a PhotoBucket username.
    # If the user exists, the return value will be the letter-number combo,
    # otherwise returns a value of 'FALSE'.
    #
    ###############################################################################
    
    sub getRandID($)
    {
    
    	#######################################################################
    	#
    	# Initialize variables lexically scoped to the procedure
    	#
    	#######################################################################
    
    	my $user = shift (@_);
    	my $target = 'http://photobucket.com/images/' . $$user . '/';
    	my $data = '';
    	my $randid= '';
    
    	#######################################################################
    	#
    	# Make search request for user on PhotoBucket
    	#
    	#######################################################################
    
    	while (length($data) < 32)
    	{
    		$data = get($target);
    	}
    
    	#######################################################################
    	#
    	# Determine if user was found or not; set return value accordingly
    	#
    	#######################################################################
    
    	if ($data =~ m/http:\/\/\S{1,3}\.photobucket\.com\/albums\/(\S{1,5})\/$$user\//g)
    	{
    		$randid= $1;
    	}
    	else
    	{
    		print "\n" . 'USER  "' . $$user . '"  NOT FOUND';
    		$randid= 'FALSE';
    	}
    
    	#######################################################################
    	#
    	# Return the letter-number combo or 'FALSE' to main
    	#
    	#######################################################################
    
    	return $randid;=
    }
    
    	#######################################################################
    	#
    	# End procedure code
    	#
    	#######################################################################
    
    ###############################################################################
    #
    # End program code
    #
    ###############################################################################
    Code (markup):
     
    itisme1760, Oct 2, 2008 IP
  2. zassman

    zassman Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's a PERL script
     
    zassman, Oct 2, 2008 IP
  3. lol749

    lol749 Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Can you read? Its PERL.
    It tells you everything you need to know in the file.
    "the source code can run on ANY machine with a Perl interpreter version >= 5.8.4, and you will need LWP and Parallel modules"
    HTH
     
    lol749, Oct 3, 2008 IP
  4. daman371

    daman371 Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yeah I was looking at the code and it is definitely PERL. I didn't even notice the information that was printed. I wonder why the shebang line was left out though.
     
    daman371, Oct 3, 2008 IP
  5. itisme1760

    itisme1760 Greenhorn

    Messages:
    74
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    23
    #5
    The thing is, this program came compiled as an .exe (separate from the source code), how would I compile this as an .exe?
     
    itisme1760, Oct 3, 2008 IP
  6. Masterful

    Masterful Well-Known Member

    Messages:
    1,653
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #6
    Well, after seeing that, I can safely say that I won't be trying to learn Perl any time soon! :eek:
     
    Masterful, Oct 3, 2008 IP
  7. itisme1760

    itisme1760 Greenhorn

    Messages:
    74
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    23
    #7
    Ok, I figured out how to compile as an .exe, using perl2exe. Now I need to install the Parallel and LWP modules, which I found and downloaded. I need to compile these scripts. Anyone know how to do this? I tried doing a perl, MakeInstall but didn't work, gave me some error.
     
    itisme1760, Oct 3, 2008 IP
  8. leska

    leska Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #8
    Does it really has sense to compile PERL scripts to EXE files?
     
    leska, Oct 11, 2008 IP