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

hello All, I'm new to Perl and have written a small code. Now I want this .pl file to be converted into .exe file so that it can run on any system(only windows) without perl being installed. can someone please guide step by step ?

here is my code:

use strict; use warnings; use Cwd; my @operations = ( { label => 'Harcoded font size value !!', test => sub { $_[0] =~ /font-size\s*(:|=)\s*[^%]+$/ }, }, { label => 'Forced Line height value !!', test => sub { $_[0] =~ /line-height/ }, }, { label => 'position absolute !!', test => sub { $_[0] =~ /position\s*(:|=)\s*absolute/ }, }, ); my $dirpath = getcwd; my @filepaths = glob( "$dirpath/*.css" ); print "no css files\n" unless @filepaths; for my $filepath ( @filepaths ) { print "\n>>> $filepath <<<\n"; $_->{count} = 0 for ( @operations ); # set or reset counts. open my $filehandle, '<', $filepath or die "could not open '$filep +ath': $!"; while ( my $line = <$filehandle> ) { $_->{test}->( $line ) and $_->{count}++ for ( @operations ); # + for each operation, call the test and increment count if it returns +true. } close $filehandle; print "$_->{label} $_->{count} Instance found\n" for ( @operations + ); # for each operation, print the outcome. }

Replies are listed 'Best First'.
Re: Converting .pl to .exe file
by dasgar (Priest) on Jan 30, 2015 at 06:38 UTC

    I'd recommend installing the PAR::Packer module, which would give you the pp utility. This utility can bundle your script into a stand-alone executable. The documentation for pp does include some examples.

Re: Converting .pl to .exe file
by marto (Cardinal) on Jan 30, 2015 at 09:11 UTC

    Welcome. The pp documentation is pretty good. Install pp:

    cpan pp

    Package your script and the required modules:

    pp -x derp.pl -o derp.exe

    When using pp I always use the -x out of habbit, to check for additional run time dependencies. You should now have a executable you can run. The first time you do so it'll take longer than subsequent runs because it unpacks everything into a temporary directory. If you have packaging issues just unzip the .exe file as you would any .zip file and investigate, you can also enable verbose messages when calling pp:

    pp -x -v derp.pl -o derp.exe
Re: Converting .pl to .exe file
by regexes (Hermit) on Jan 30, 2015 at 12:34 UTC
    Just a thought... you could also try taking a look at perl2exe.
    I usually had good results using it.
      perl2exe does not work with any Strawberry Perl or Perl 5.18.x. I just got a response from tech support.
Re: Converting .pl to .exe file
by mohad (Initiate) on Jan 30, 2015 at 05:27 UTC
    Posted in the wrong group. Mod's can delete this post ! Sorry for the confusion !
      Is not the wrong group .. well to be strict is a monestery..

      Anyway is a Perl question and even if you rarely get a step by step solution you can get many useful suggestions.

      The first of such suggestion is to use Super Search with some related term, so that you can find many informative posts about the matter.
      Then, to add something to the dasagr's answer (ie using the main packer Perl utility PAR::Packer and his son pp) you can also give a try to Citrus Perl (to create Perl distributions) and to Cava Packager (to create standalone executables).

      HtH
      L*
      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: Converting .pl to .exe file
by mr_mischief (Monsignor) on Jan 30, 2015 at 16:29 UTC

    It's experimental but it may be yet another option for your needs.: perlcc