Hi Monks,

I am new to Perl and going thru selected tutorials. At the moment I am trying to create an executable of my perlscript.

I am running Perl on Windows with Strawberry. Below is the version info.

This is perl 5, version 22, subversion 1 (v5.22.1) built for MSWin32-x64-multi-thread

I have installed the PAR:Packer module version 1.029

When I execute C:\>pp -o packed.exe hw.pl I get the error below.

Error removing C:/Users/DANIEL~1.LEG/AppData/Local/Temp/parl_MCNJgn.exe at C:/Strawberry/perl/lib/File/Temp.pm line 762, <DATA> line 1.

Nevertheless, the executable file is created and the script runs fine.

Does anyone know anything about this error? I could not find info about it. Since I am using a very simple script which is a combination of the tutorials I've been through I wonder if this error will do some real damage on complex scripts later on.

Please note that the path to parl_MCNJgn.exe in the error seems incorrect. The real path has my full name as supposed to DANIEL~1.LEG.

Cheers,

# Hello world program print "=======================================================\n"; use strict; use warnings; use Term::ReadLine; use feature qw(say); use Data::Dump; # -- Variable Definitions: can be done when variable is first used my $animal; my $banner; my $num; my $term; my $content; my $count; my +$email; my @animals; my @nums; my @mixed; my @sorted; my @backwards; my @fruit +s; my @colors; my @copyofFC; my %fruit_colors; my $ptime = 1; {# -- Scalars print "\n\n"; # \n must + be within "" so it interpolates the newline $animal = 'camel'; # '' and "" +are interchangeable if no special characters $banner = "hello world "; $num = 3; say $banner, $num + 1/2; say $animal; # Same as +print but ends with \n } {# -- Arrays print "\n\n"; @animals = ('camel ','llama ','owl ','dog ','shark ','ant '); @nums = (23,42,69); @mixed = ('camel',42,1.23,2.5); say $animals[0]; say $animals[1]; say $mixed[$#mixed] *2; # $#array i +s the last index in the array say @nums; # Print +all elements with no spaces in between say @animals; dd \@mixed; # Print + in array format i.e. ["camel", 42, 1.23, 2.5] Requires Data::Dump if (@animals < 10) { say $#animals+1; } # As Perl expects an sc +alar, @animals is the number of elements say @animals[0,1]; say @animals[2..$#animals]; @sorted = sort @animals; @backwards = reverse @nums; say @sorted; say @backwards; } {# -- Hashes print "\n\n"; %fruit_colors = ('apple ', 'red ', 'banana ', 'yellow ', 'kiwi ', 'gre +en ', 'coconut ', 'brown '); # Maps even indexed elements with follo +wing element e.g. apple => red say $fruit_colors{'kiwi '}; @fruits = keys %fruit_colors; # As hash +es have no particular internal order, retrieved keys don't either. @colors = values %fruit_colors; print @fruits, " => ", @colors, "\n\n"; @fruits = reverse sort @fruits; print @fruits, "\n", @fruit_colors{@fruits}, "\n"; } {# -- Conditional and looping constructs print "\n\n"; if (@fruits <5) {print "less than 5 | ";} unless (@fruits >5) {print "not greater than 5", "\n"} # "if no +t" statement print "One line if \n" if (1); print "One line unless \n" unless (0); $term = Term::ReadLine->new('Text'); $content = ''; $| = 1; # flushes p +rint as it is issued (i.e. do not wait for \n) print "\ntype input or press enter to exit"; while ( defined (my $con = $term->readline('input: '))){ last unless length $con; $content .= "$con "; # concatenate +string (i.e appends "$con " to the end of $content) } print "You entered: "; say $content; $| = 1; # Something + within previous while loop resets $| $count = 0; until($count == 5){ print 5-$count unless($count >5); print "Crashed: use Ctrl+C on Windows or Ctrl+D on Linux\n" if($co +unt >5) ; $count++; sleep($ptime); } for(my $i = 0; $i <= $count; $i++){ print $i; sleep($ptime); } print "\n"; print "$_ " foreach (@nums); # $_ points to val +ue in array foreach my $keyfruit (keys %fruit_colors){ print "\n$keyfruit\t$fruit_colors{$keyfruit}"; sleep($ptime); } } {# -- Files print "\n\n"; open(my $out, ">", "output.txt") or die "Can't open output.txt: $!"; + # ">" to write print $out %fruit_colors, "\n"; print $out "second line \n"; say $out "third line"; close $out or die "$out: $!"; print "File saved\n"; sleep($ptime); open (my $in, "<", "output.txt") or die "Can't open output.txt: $!"; + # "<" to read @copyofFC = <$in>; print "Read from file:\n", @copyofFC; } sleep($ptime); {# -- Regular Expressions and capturing print "\n\n"; $email = 'daniel@leguizamon.info'; if ($email =~ /([^@]+)@([^.]+).(.+)/) { print "Username: ", $1, "\n"; print "Server: ", $2, "\n"; print "Extension: ", $3, "\n"; }else{ say "Nop"; } } sleep($ptime); {# -- Subrutines print "\n\n"; sub square{ my $a = shift; +# Shift function by default gets @_ which is the arguments array my $result = $a*$a; return $result; # r +eturn is optional } say square($term->readline('Number to be squared: ')); } sleep($ptime); {# -- Here documents print "\n\n"; + # "" and '' rules apply. But strangely only set at statement (next +line) my $message = <<"ENDofMESSAGE"; # to cr +eate a string that spreads on multiple lines and preserves white spac +es and new-lines Dear $fruits[0], I know you are feeling $fruit_colors{$fruits[0]} but let me tell you I am $fruit_colors{$fruits[1]}. Regards, $fruits[1] ENDofMESSAGE # end of the s +tring exactly as it was at the beginning. No white-spaces before, and + no white spaces after. print $message; } {# -- executing cmd commands print "\n\n"; sleep($ptime); # -- Large comment block =begin comment print "this will NOT be printed"; method | use if ... ------------------------------------------------------------------ +------------- system() | you want to execute a command and don't want +to capture/store its output exec | you don't want to return to the calling perl +script backticks | you want to capture the output of the command open | you want to pipe the command (as input or out +put) to your script =end comment =cut print "executing ping to google.com not storing its output"; sleep($ptime); system("ping", "google.com", "-n", "1"); # system(" +command", "arg1", "arg2", "arg3"); print "\nPing failed: ", $!, "\n" if($? == 256); print "\nPing exited with value ", $? >> 8 unless ($? == 256); sleep($ptime * 2); print "\n\nexecuting pong to 10.10.1.1 and exiting hw.pl"; sleep($ptime); exec("pong", "10.10.1.1", "-n", "1"); # exec("comma +nd", "arg1", "arg2", "arg3"); print "\nPong failed: ", $!, "\n\n"; sleep($ptime * 2); print "executing png to yahoo.com capturing STDOUT\n"; sleep($ptime); my $result1 = `png yahoo.com -n 1`; # $ + context returns a single string, @ context returns a list of lines o +r an empty list if the command failed. #print "\nPing failed: ", $!, "\n" if($? == 256); #print "\nPing exited with value ", $? >> 8 unless ($? == 256); print "\nThis was stored in result1:\n $result1\n"; sleep($ptime * 2); print "\nexecuting png to yahoo.com capturing STDOUT and STDERR\n"; sleep($ptime); my @result2 = `png yahoo.com -n 1 2>&1`; # to collect m +essages sent to STDERR, 2>&1 redirects STDERR to STDOUT #print "\nPing failed: ", $!, "\n" if($? == 256); #print "\nPing exited with value ", $? >> 8 unless ($? == 256); print "\nThis was stored in result2:\n @result2\n"; say @result2[1]; } system ('pause');

In reply to PAR::Packer error by drli611

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.