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

Greetings fellow monks, accolates, bishops, etc.

This is all on Windows. Sorry I didn't post that the first time.

I beseech you all for aid in my noble quest. I am writing a small script to pull out syslog records containing the flag "WARNING". The box that this will run on is a Perl-less machine, so I'm using pp to generate an .exe file. It worked well with my initial script. Now, I have changed it, and brought in the Posix module. Here's the script:

use strict; use warnings; use Posix qw(strftime); no strict 'refs'; no strict 'subs'; my $regex = 'WARNING'; my $dir = "L:\\vpn\\"; my $out = "L:\\vpn\\difflogs\\vpnwarn.out"; my $time = POSIX::strftime "%Y%m%d",localtime; my $newtime = ($time -1); my $log = $newtime.".log"; open OUT, ">$out", || die "Can't open outfile: $!"; open LOG, "$dir$log", || die "Can't open logfile: $!"; while (<LOG>) { if (m/$regex/g) { print OUT $_ . "\n"; } } close LOG; close OUT || die "Can't close VPN outfile: $!";
This script runs fine from either Cygwin or Windows with Perl. When I compile it, I get no errors. But when I attempt to run it, I get the following error:
Can't locate loadable object for module POSIX in @INC (@INC contains: CODE(0x1281fd0) CODE(0x12fd6fc) .) at ../blib/lib/PAR/Heavy.pm line 101 Compilation failed in require at script/vpnwarn.pl line 9. BEGIN failed--compilation aborted at script/vpnwarn.pl line 9.
What the Posix module is affording me is to use strftime to obtain the date and shift it into a format that matches the names of the logfiles that I am parsing automatically. For example, the script runs shortly after midnight to parse yesterday's file. It gets todays date, in the proper numeric string, YYYYMMDD, and subtracts 1.

If anyone has any wisdom, links, etc that would help diagnose this ailment, I would greatly appreciate. I looked briefly at using the the "Poor Man's strftime()" by liz http://perlmonks.org/index.pl?node_id=290054 However, I don't think it'll meet the needs of this job. I would like to get the Posix module up in the compiled version quickly!

Thanks, Monger

Replies are listed 'Best First'.
Re: Problems with PP and Posix
by flyingmoose (Priest) on Dec 19, 2003 at 17:09 UTC
    Can I ask what command line arguments you are sending to pp? Usually you have to tell it which modules you are using so that they can be included in the exe, and that error seems to indicate it can't find a module.
      Adding the module to the command line fixed it! Looking at the pod documentation, I know why I didn't do it before:

      <blockqoute> DESCRIPTION pp creates standalone executables from Perl programs, using the compressed packager provided by the PAR manpage, and dependency detection heuristics offered by the Module::ScanDeps manpage. Source files are compressed verbatim without compilation. </blockqoute>

      I thought that the dependency detection heuristics would autoload the Modules, but I realize now that it seems to autolad the Module dependencies, not script dependencies.

      Thanks again, Monger

      Hummm. I'll recompile after this and post results. What I've sent it before is

      pp -o vpnwarn.exe vpnwarn.pl

      I'll have to look at my old script and see if it used any external modules; I can't remember. But it didn't spew at me.

      Thanks, Monger