[31352] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2604 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 19 06:09:42 2009

Date: Sat, 19 Sep 2009 03:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 19 Sep 2009     Volume: 11 Number: 2604

Today's topics:
    Re: Anyone care to explain this one? <bmdavll@gmail.com>
        FAQ 4.53 How do I manipulate arrays of bits? <brian@theperlreview.com>
        FAQ 6.17 How do I efficiently match many regular expres <brian@theperlreview.com>
        FAQ 8.19 Why doesn't my sockets program work under Syst <brian@theperlreview.com>
    Re: Newbie: Perl script to Windows and Linux executable <ace@invalid.com>
    Re: Newbie: Perl script to Windows and Linux executable <ben@morrow.me.uk>
    Re: Newbie: Perl script to Windows and Linux executable <simonsharry@gmail.com>
    Re: Newbie: Perl script to Windows and Linux executable <ben@morrow.me.uk>
    Re: Newbie: Perl script to Windows and Linux executable <simonsharry@gmail.com>
    Re: Newbie: Perl script to Windows and Linux executable <hjp-usenet2@hjp.at>
    Re: Newbie: Regular expresion <ben@morrow.me.uk>
    Re: perl script execution take a long time <hjp-usenet2@hjp.at>
    Re: regex match for same number of opening and closing  sln@netherlands.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 18 Sep 2009 16:36:44 -0700 (PDT)
From: David Liang <bmdavll@gmail.com>
Subject: Re: Anyone care to explain this one?
Message-Id: <a9525095-81dd-4548-a4a1-8ca0ee0d3c73@12g2000pri.googlegroups.com>

On Sep 11, 3:53 am, pac...@kosh.dhis.org (Alan Curry) wrote:

> I don't know if it would ever be a good idea to use the /c modifier, the /d
> modifier, and a non-empty replacement list all in a single tr/// operation.
> Having explained in detail what it did and why, it seems like even if that's
> what you wanted to do, you should find a less obfuscated way to do it.
>

I was trying out those strange cases because I was writing a semi-
clone of the transliteration operator for Python:

http://github.com/bmdavll/StringTransform

Thanks again for the explanation--it really cleared up the whole
complements deal for me.


------------------------------

Date: Sat, 19 Sep 2009 10:00:03 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 4.53 How do I manipulate arrays of bits?
Message-Id: <DY1tm.7281$tG1.2005@newsfe22.iad>

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.53: How do I manipulate arrays of bits?

    Use "pack()" and "unpack()", or else "vec()" and the bitwise operations.

    For example, you don't have to store individual bits in an array (which
    would mean that you're wasting a lot of space). To convert an array of
    bits to a string, use "vec()" to set the right bits. This sets $vec to
    have bit N set only if $ints[N] was set:

            @ints = (...); # array of bits, e.g. ( 1, 0, 0, 1, 1, 0 ... )
            $vec = '';
            foreach( 0 .. $#ints ) {
                    vec($vec,$_,1) = 1 if $ints[$_];
                    }

    The string $vec only takes up as many bits as it needs. For instance, if
    you had 16 entries in @ints, $vec only needs two bytes to store them
    (not counting the scalar variable overhead).

    Here's how, given a vector in $vec, you can get those bits into your
    @ints array:

            sub bitvec_to_list {
                    my $vec = shift;
                    my @ints;
                    # Find null-byte density then select best algorithm
                    if ($vec =~ tr/\0// / length $vec > 0.95) {
                            use integer;
                            my $i;

                            # This method is faster with mostly null-bytes
                            while($vec =~ /[^\0]/g ) {
                                    $i = -9 + 8 * pos $vec;
                                    push @ints, $i if vec($vec, ++$i, 1);
                                    push @ints, $i if vec($vec, ++$i, 1);
                                    push @ints, $i if vec($vec, ++$i, 1);
                                    push @ints, $i if vec($vec, ++$i, 1);
                                    push @ints, $i if vec($vec, ++$i, 1);
                                    push @ints, $i if vec($vec, ++$i, 1);
                                    push @ints, $i if vec($vec, ++$i, 1);
                                    push @ints, $i if vec($vec, ++$i, 1);
                                    }
                            }
                    else {
                            # This method is a fast general algorithm
                            use integer;
                            my $bits = unpack "b*", $vec;
                            push @ints, 0 if $bits =~ s/^(\d)// && $1;
                            push @ints, pos $bits while($bits =~ /1/g);
                            }

                    return \@ints;
                    }

    This method gets faster the more sparse the bit vector is. (Courtesy of
    Tim Bunce and Winfried Koenig.)

    You can make the while loop a lot shorter with this suggestion from
    Benjamin Goldberg:

            while($vec =~ /[^\0]+/g ) {
                    push @ints, grep vec($vec, $_, 1), $-[0] * 8 .. $+[0] * 8;
                    }

    Or use the CPAN module "Bit::Vector":

            $vector = Bit::Vector->new($num_of_bits);
            $vector->Index_List_Store(@ints);
            @ints = $vector->Index_List_Read();

    "Bit::Vector" provides efficient methods for bit vector, sets of small
    integers and "big int" math.

    Here's a more extensive illustration using vec():

            # vec demo
            $vector = "\xff\x0f\xef\xfe";
            print "Ilya's string \\xff\\x0f\\xef\\xfe represents the number ",
            unpack("N", $vector), "\n";
            $is_set = vec($vector, 23, 1);
            print "Its 23rd bit is ", $is_set ? "set" : "clear", ".\n";
            pvec($vector);

            set_vec(1,1,1);
            set_vec(3,1,1);
            set_vec(23,1,1);

            set_vec(3,1,3);
            set_vec(3,2,3);
            set_vec(3,4,3);
            set_vec(3,4,7);
            set_vec(3,8,3);
            set_vec(3,8,7);

            set_vec(0,32,17);
            set_vec(1,32,17);

            sub set_vec {
                    my ($offset, $width, $value) = @_;
                    my $vector = '';
                    vec($vector, $offset, $width) = $value;
                    print "offset=$offset width=$width value=$value\n";
                    pvec($vector);
                    }

            sub pvec {
                    my $vector = shift;
                    my $bits = unpack("b*", $vector);
                    my $i = 0;
                    my $BASE = 8;

                    print "vector length in bytes: ", length($vector), "\n";
                    @bytes = unpack("A8" x length($vector), $bits);
                    print "bits are: @bytes\n\n";
                    }



--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


------------------------------

Date: Sat, 19 Sep 2009 04:00:02 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 6.17 How do I efficiently match many regular expressions at once?
Message-Id: <6HYsm.35667$nP6.32936@newsfe25.iad>

This is an excerpt from the latest version perlfaq6.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

6.17: How do I efficiently match many regular expressions at once?

    ( contributed by brian d foy )

    Avoid asking Perl to compile a regular expression every time you want to
    match it. In this example, perl must recompile the regular expression
    for every iteration of the "foreach" loop since it has no way to know
    what $pattern will be.

            @patterns = qw( foo bar baz );

            LINE: while( <DATA> )
                    {
                    foreach $pattern ( @patterns )
                            {
                            if( /\b$pattern\b/i )
                                    {
                                    print;
                                    next LINE;
                                    }
                            }
                    }

    The "qr//" operator showed up in perl 5.005. It compiles a regular
    expression, but doesn't apply it. When you use the pre-compiled version
    of the regex, perl does less work. In this example, I inserted a "map"
    to turn each pattern into its pre-compiled form. The rest of the script
    is the same, but faster.

            @patterns = map { qr/\b$_\b/i } qw( foo bar baz );

            LINE: while( <> )
                    {
                    foreach $pattern ( @patterns )
                            {
                            if( /$pattern/ )
                                    {
                                    print;
                                    next LINE;
                                    }
                            }
                    }

    In some cases, you may be able to make several patterns into a single
    regular expression. Beware of situations that require backtracking
    though.

            $regex = join '|', qw( foo bar baz );

            LINE: while( <> )
                    {
                    print if /\b(?:$regex)\b/i;
                    }

    For more details on regular expression efficiency, see *Mastering
    Regular Expressions* by Jeffrey Freidl. He explains how regular
    expressions engine work and why some patterns are surprisingly
    inefficient. Once you understand how perl applies regular expressions,
    you can tune them for individual situations.



--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


------------------------------

Date: Fri, 18 Sep 2009 22:00:03 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.19 Why doesn't my sockets program work under System V (Solaris)?  What does the error message "Protocol not supported" mean?
Message-Id: <DpTsm.12823$6f4.8671@newsfe08.iad>

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

8.19: Why doesn't my sockets program work under System V (Solaris)?  What does the error message "Protocol not supported" mean?

    Some Sys-V based systems, notably Solaris 2.X, redefined some of the
    standard socket constants. Since these were constant across all
    architectures, they were often hardwired into perl code. The proper way
    to deal with this is to "use Socket" to get the correct values.

    Note that even though SunOS and Solaris are binary compatible, these
    values are different. Go figure.



--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


------------------------------

Date: Fri, 18 Sep 2009 20:22:52 +0200
From: ace <ace@invalid.com>
Subject: Re: Newbie: Perl script to Windows and Linux executable versions.
Message-Id: <h90j65$e7d$1@ss408.t-com.hr>

Harry wrote:

> What I want is
>     an EXE for Windows, and
>     an ELF for Linux
> each of which runs without any dependence on the Perl installation.

I've used strawberry for windows recently and there was no problem with
 .exe "compiling".

http://strawberryperl.com/



------------------------------

Date: Fri, 18 Sep 2009 19:31:58 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Newbie: Perl script to Windows and Linux executable versions.
Message-Id: <u90do6-0dq.ln1@osiris.mauzo.dyndns.org>


Quoth Harry <simonsharry@gmail.com>:
> 
> I have a perl script that I'd like to be able to run on Windows and
> Linux. Is this easily possible?
> 
> Here's what I've tried so far... unsuccessfully!
> 
> I've tried to install PAR::Packer from CPAN. After having successfully
> installed all its dependencies manually, I discovered that I couldn't
> install PAR::Packer itself. I got the message:
>     Can't locate ExtUtils/Embed.pm in @INC ...

ExtUtils::Embed comes with the perl distribution, so something's gone
wrong with yours. What happens if you run

    perl -MExtUtils::Embed -e1

What does perl -V say? Do you actually have an ExtUtils\Embed.pm
anywhere in your perl installation?

Ben



------------------------------

Date: Fri, 18 Sep 2009 11:44:35 -0700 (PDT)
From: Harry <simonsharry@gmail.com>
Subject: Re: Newbie: Perl script to Windows and Linux executable versions.
Message-Id: <cf92999b-bbdb-4dbb-a1ba-794e4f39d787@d15g2000prc.googlegroups.com>

On Sep 18, 11:31=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> ExtUtils::Embed comes with the perl distribution, so something's gone
> wrong with yours. What happens if you run
>
> =A0 =A0 perl -MExtUtils::Embed -e1

I see this message:
  $ perl -MExtUtils::Embed -e1
  Can't locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/local/
lib/perl5/site_perl/5.10.0/i386-linux-thread-multi /usr/local/lib/
perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-
thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/
vendor_perl /usr/lib/perl5/5.10.0/i386-linux-thread-multi /usr/lib/
perl5/5.10.0 /usr/lib/perl5/site_perl .).
  BEGIN failed--compilation aborted.


> Do you actually have an ExtUtils\Embed.pm
> anywhere in your perl installation?

I don't seem to have ExtUtils/Embed.pm anywhere. Here's, e.g., what I
see:
  $ find /usr/local/lib/perl5/ /usr/lib/perl5/ -iname '*embed*'
  /usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/embedvar.h
  /usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/embed.h
  /usr/lib/perl5/5.10.0/pod/perlembed.pod


> What does perl -V say?

$ perl -V
Summary of my perl5 (revision 5 version 10 subversion 0)
configuration:
  Platform:
    osname=3Dlinux, osvers=3D2.6.18-128.1.14.el5, archname=3Di386-linux-
thread-multi
    uname=3D'linux x86-7.fedora.phx.redhat.com 2.6.18-128.1.14.el5 #1
smp mon jun 1 15:52:58 edt 2009 i686 i686 i386 gnulinux '
    config_args=3D'-des -Doptimize=3D-O2 -g -pipe -Wall -Wp,-
D_FORTIFY_SOURCE=3D2 -fexceptions -fstack-protector --param=3Dssp-buffer-
size=3D4 -m32 -march=3Di586 -mtune=3Dgeneric -fasynchronous-unwind-tables -
Accflags=3D-DPERL_USE_SAFE_PUTENV -Dversion=3D5.10.0 -
Dmyhostname=3Dlocalhost -Dperladmin=3Droot@localhost -Dcc=3Dgcc -Dcf_by=3DR=
ed
Hat, Inc. -Dprefix=3D/usr -Dvendorprefix=3D/usr -Dsiteprefix=3D/usr/local -
Dprivlib=3D/usr/lib/perl5/5.10.0 -Dsitelib=3D/usr/local/lib/perl5/
site_perl/5.10.0 -Dvendorlib=3D/usr/lib/perl5/vendor_perl/5.10.0 -
Darchlib=3D/usr/lib/perl5/5.10.0/i386-linux-thread-multi -Dsitearch=3D/usr/
local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi -Dvendorarch=3D/
usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi -
Dinc_version_list=3Dnone -Darchname=3Di386-linux-thread-multi -Duseshrplib
-Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun
-Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3D3pm -
Duseperlio -Dinstallusrbinperl=3Dn -Ubincompat5005 -Uversiononly -
Dpager=3D/usr/bin/less -isr -Dd_gethostent_r_proto -
Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -
Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -
Dscriptdir=3D/usr/bin -Dotherlibdirs=3D/usr/lib/perl5/site_perl'
    hint=3Drecommended, useposix=3Dtrue, d_sigaction=3Ddefine
    useithreads=3Ddefine, usemultiplicity=3Ddefine
    useperlio=3Ddefine, d_sfio=3Dundef, uselargefiles=3Ddefine,
usesocks=3Dundef
    use64bitint=3Dundef, use64bitall=3Dundef, uselongdouble=3Dundef
    usemymalloc=3Dn, bincompat5005=3Dundef
  Compiler:
    cc=3D'gcc', ccflags =3D'-D_REENTRANT -D_GNU_SOURCE -
DPERL_USE_SAFE_PUTENV -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/
local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=3D64 -I/usr/
include/gdbm',
    optimize=3D'-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=3D2 -fexceptions -
fstack-protector --param=3Dssp-buffer-size=3D4 -m32 -march=3Di586 -
mtune=3Dgeneric -fasynchronous-unwind-tables',
    cppflags=3D'-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -
DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/
include/gdbm'
    ccversion=3D'', gccversion=3D'4.4.0 20090506 (Red Hat 4.4.0-4)',
gccosandvers=3D''
    intsize=3D4, longsize=3D4, ptrsize=3D4, doublesize=3D8, byteorder=3D123=
4
    d_longlong=3Ddefine, longlongsize=3D8, d_longdbl=3Ddefine,
longdblsize=3D12
    ivtype=3D'long', ivsize=3D4, nvtype=3D'double', nvsize=3D8, Off_t=3D'of=
f_t',
lseeksize=3D8
    alignbytes=3D4, prototype=3Ddefine
  Linker and Libraries:
    ld=3D'gcc', ldflags =3D' -L/usr/local/lib'
    libpth=3D/usr/local/lib /lib /usr/lib
    libs=3D-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -
lc
    perllibs=3D-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=3D/lib/libc-2.10.1.so, so=3Dso, useshrplib=3Dtrue,
libperl=3Dlibperl.so
    gnulibc_version=3D'2.10.1'
  Dynamic Linking:
    dlsrc=3Ddl_dlopen.xs, dlext=3Dso, d_dlsymun=3Dundef, ccdlflags=3D'-Wl,-=
E -
Wl,-rpath,/usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE'
    cccdlflags=3D'-fPIC', lddlflags=3D'-shared -O2 -g -pipe -Wall -Wp,-
D_FORTIFY_SOURCE=3D2 -fexceptions -fstack-protector --param=3Dssp-buffer-
size=3D4 -m32 -march=3Di586 -mtune=3Dgeneric -fasynchronous-unwind-tables -=
L/
usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: DEBUGGING MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_TRACK_MEMPOOL PERL_USE_SAFE_PUTENV
USE_ITHREADS
                        USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
  Built under linux
  Compiled at Jul  7 2009 09:55:34
  @INC:
    /usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi
    /usr/local/lib/perl5/site_perl/5.10.0
    /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.10.0
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/5.10.0/i386-linux-thread-multi
    /usr/lib/perl5/5.10.0
    /usr/lib/perl5/site_perl
    .
$

(Thanks, Ben.)


------------------------------

Date: Fri, 18 Sep 2009 23:30:00 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Newbie: Perl script to Windows and Linux executable versions.
Message-Id: <88edo6-pir.ln1@osiris.mauzo.dyndns.org>


Quoth Harry <simonsharry@gmail.com>:
> On Sep 18, 11:31 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> > ExtUtils::Embed comes with the perl distribution, so something's gone
> > wrong with yours. What happens if you run
> >
> >     perl -MExtUtils::Embed -e1
> 
> I see this message:
>   $ perl -MExtUtils::Embed -e1
>   Can't locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/local/
> lib/perl5/site_perl/5.10.0/i386-linux-thread-multi /usr/local/lib/
> perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-
> thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/
> vendor_perl /usr/lib/perl5/5.10.0/i386-linux-thread-multi /usr/lib/
> perl5/5.10.0 /usr/lib/perl5/site_perl .).
>   BEGIN failed--compilation aborted.
>
> > What does perl -V say?
> 
> $ perl -V
> [...] -Dcf_by=Red Hat, Inc. [...]

There's your problem. Red Hat's perl packages are known to be broken:
the package called 'perl' doesn't actually install the whole of the perl
distribution. I believe you need to install the 'perl-core' package. See
also
http://www.mail-archive.com/fedora-perl-devel-list@redhat.com/msg12210.html .

Red Hat has a very poor history with their perl packages, though I
believe they are trying to fix that (Tom Callaway in particular seems to
be making an effort to work with p5p and sort out the issues). For now I
would still always recommend you build your own perl for any serious
work.

Ben



------------------------------

Date: Fri, 18 Sep 2009 21:03:56 -0700 (PDT)
From: Harry <simonsharry@gmail.com>
Subject: Re: Newbie: Perl script to Windows and Linux executable versions.
Message-Id: <5dc67eda-e641-4a6d-b77d-9d94e05b1971@i18g2000pro.googlegroups.com>

On Sep 19, 3:30 am, Ben Morrow <b...@morrow.me.uk> wrote:
> There's your problem. Red Hat's perl packages are known to be broken:
> the package called 'perl' doesn't actually install the whole of the perl
> distribution. I believe you need to install the 'perl-core' package. See
> also
> http://www.mail-archive.com/fedora-perl-devel-l...@redhat.com/msg12210.html .
>
> Red Hat has a very poor history with their perl packages, though I
> believe they are trying to fix that (Tom Callaway in particular seems to
> be making an effort to work with p5p and sort out the issues). For now I
> would still always recommend you build your own perl for any serious
> work.

Ben 'Angel' Morrow.
I had _no_ idea this could've been / was going on. Thanks, Ben, for
enlightening.

Just for the information of all you helpful posters (on this thread)
and other members of this group... I managed to 'somewhat install'
PAR::Packer but not without hiccups.
  1. I first got a exit status of 512 and a "won't make", "won't test"
error.
  2. I then tried to manually do the install by...
     2.1 cd-ing into ~/.cpan/build/PAR-Packer* dir.
     2.2 Issuing a 'perl Makefile.PL'.
     2.3 Followed by a 'make test' and 'make install'.

Things seemed to look fine at this point:
cpan[3]> install PAR::Packer
PAR::Packer is up to date (0.991).

However, when I try to actually use the Par Packer command pp (see
'man pp' for details), this is what I see:
$ which pp
/usr/local/bin/pp

$ pp -o hello.exe hello.pl
Can't locate PAR/Packer.pm in @INC (@INC contains: /usr/local/lib/
perl5/site_perl/5.10.0/i386-linux-thread-multi /usr/local/lib/perl5/
site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-
multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl /
usr/lib/perl5/5.10.0/i386-linux-thread-multi /usr/lib/perl5/5.10.0 /
usr/lib/perl5/site_perl .) at /usr/local/lib/perl5/site_perl/5.10.0/
pp.pm line 5.
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/
5.10.0/pp.pm line 5.
Compilation failed in require at /usr/local/bin/pp line 8.
BEGIN failed--compilation aborted at /usr/local/bin/pp line 8.

When I look for PAR-related stuff in my Perl installation, this is
what I see:
$ find /usr/local/lib/perl5/ /usr/lib/perl5/ -name '*PAR*'
/usr/local/lib/perl5/site_perl/5.10.0/App/Packer/PAR.pm
/usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/auto/PAR
/usr/local/lib/perl5/site_perl/5.10.0/PAR.pm
/usr/local/lib/perl5/site_perl/5.10.0/PAR
/usr/local/lib/perl5/site_perl/5.10.0/PAR/StrippedPARL


------------------------------

Date: Sat, 19 Sep 2009 09:48:38 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Newbie: Perl script to Windows and Linux executable versions.
Message-Id: <slrnhb936o.gog.hjp-usenet2@hrunkner.hjp.at>

On 2009-09-18 16:27, Harry <simonsharry@gmail.com> wrote:
> On Sep 18, 9:15 pm, RedGrittyBrick <RedGrittyBr...@spamweary.invalid>
> wrote:
>> Harry wrote:
>> >> I've tried to install PAR::Packer from CPAN. After having successfully
>> >> installed all its dependencies manually, I discovered that I couldn't
>> >> install PAR::Packer itself. I got the message:
>> >>     Can't locate ExtUtils/Embed.pm in @INC ...
>>
>> Doesn't that mean that you have *not* installed all the dependencies? Or
>> at least, not in the right places? Did you install ExtUtils::Embed?
>> Isn't that one of the standard modules? What Perl versions are you using
> Well the original dependencies reported by cpan program were:
>   Archive::Zip
>   Getopt::ArgvFile
>   Module::ScanDeps
>   PAR
>   PAR::Dist
> I installed them all one by one. Manually. Via cpan. This step was
> successful.

Why do you install them manually via cpan? The cpan program
automatically resolves all the dependencies and installs the necessary
modules for you.


>> I'm a bit confused about what you want.
[...]
> I want to handover this Perl script to another person (outside
> development). This another person could be field personnel, or even a
> customer. I don't want my logic to be leaked to anyone outside my
> development team. Hence the need to have a binary EXE for Windows and
> an ELF for Linux that a non-developer could use without needing to
> install Perl on their machines

This is what PAR::Packer does, but ...

> and, more importantly, without knowing what I'm doing inside.

 ... it doesn't do this. PAR::Packer just packages your script together with
the necessary modules and a perl interpreter into an executable. When
you run that executable it first unpacks everything again (into
/tmp/par-$LOGNAME/cache-$HASH on Linux) and then runs the script. So it
is easy to find out for the user of the program "what you are doing
inside".

> Of course, hackers can reverse engineer logic from EXE/ELF but I can
> live with that; I only want to make it difficult for casual hackers.

The options --clear and --filter may help you to make it a little harder
for the casual hacker. But I doubt you can make it really difficult.

(oh, and by the way: For Windows, I hear there are really good reverse
engineering tools[1] - so compiling to machine code still wouldn't make
it very difficult for the a-bit-more-than-casual hacker)


	hp



------------------------------

Date: Fri, 18 Sep 2009 19:27:44 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Newbie: Regular expresion
Message-Id: <020do6-0dq.ln1@osiris.mauzo.dyndns.org>


Quoth Jose Luis <jose.luis.fdez.diaz@gmail.com>:
> 
> Given the string  "one;two;three;four...", is there a easy way to
> print "one":
> 
> $ echo "one;two;three;four..."|perl -e 'while(<>){$_ =~ /^(.*)(\;)(.*)
> $/ &&   print $1}'
> one;two;three

    ~% echo "one;two;three;four..." | perl -naF\; -le'print $F[0]'
    one

or, if you have 5.10,

    ... | perl -naF\; -E'say $F[0]'

Ben



------------------------------

Date: Sat, 19 Sep 2009 10:08:14 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: perl script execution take a long time
Message-Id: <slrnhb94bf.gog.hjp-usenet2@hrunkner.hjp.at>

On 2009-09-18 04:28, Uri Guttman <uri@StemSystems.com> wrote:
>>>>>> "g" == gjain  <jaingaurav.08@gmail.com> writes:
>
>  g> I am having a perl script.The main script calls some 10 subroutines
>  g> which are in the same file.
>  g> Execution time of the script take around 1 and half minute which is
>  g> not desirable.
>  g> Please tell me the way to reduce the execution time.
>
> remove line 38.
>
> or show us the code so we can see where it is slow.
>
> or use a profiling module to see where it is using the cpu.

Since nobody has mentioned it yet: Devel::NYTProf is IMHO the best
profiler for Perl.

	hp


------------------------------

Date: Fri, 18 Sep 2009 14:06:08 -0700
From: sln@netherlands.com
Subject: Re: regex match for same number of opening and closing brackets
Message-Id: <r4t7b51n42liq7l1trh3nsi9okseb6srba@4ax.com>

On Fri, 18 Sep 2009 14:22:05 +0200, Sascha Bendix <sascha.bendix@localroot.de> wrote:

>Hi,
>
>I got a little parsing problem right here: I got some strings and want 
>to ensure, that there are as many opening as closing brackets via a 
>regex without specifying the exact number.
>
>This regex would be part of a bigger one, so it can't be done in two steps.
>
>Can anybody give me a hint how to do this?
>
>Here are some boundary conditions of the strings I have:
>
>   * the number of occurrences differs between 0 an 67
>   * the strings always start with [a-z]
>   * there is always [a-z,]+ between two opening brackets
>
>Thanks in advance for every hint.
>
>Regards,
>
>Sascha

- Try with(out) debug option.
- It can be set to (*FAIL) when first $2 is populated.
- Requires Perl 5.10
- Max 50 recursive levels (shouldn't be a problem).
- Is only based on char delimeters, can be tweeked for
  string delimeters.


Good Luck!
-sln
================

use strict;
use warnings;

my $debug = 0;
my $string = "  asdf[ ( () ) (((( ] )))  (  )   () a )";
my ($x,$y) =
(
  quotemeta '(',
  quotemeta ')'
);

my $rxbal = qr {
  (?:  ($x(?:(?>[^$x$y]+)|(?1))*$y) | ([$x$y]) | .  )+
}x;

if ($debug)
{
  use re 'eval';
  $rxbal = qr {
	(?:              
              (    # group 1
                $x
		    (?{ print "(",pos()," "; })
                    (?:
                       (?> [^$x$y]+ )  # not $x nor $y and no backtracking
                      |
                       (?{ print "-",pos(),"\n"; })
		       (?1) # Recurse to start of group 1
                    )*
		    (?{ print ")",pos()," "; })
                $y
              )
	      (?{ print "\n\$1 => $^N",pos()," \n"; })
	    |
	      ([$x$y])  # $x or $y
	      (?{ print "\n\$2 => (!!!!!!!!!!bad) $^N",pos()," \n"; })
		|
	      (.)       # any char
	      (?{ print "\n\$3 => $^N",pos()," \n"; })
	)+
    }x;
}
 
print "$string\n";

if ($string =~ /$rxbal/)
{
	if (defined $2)
	   { print "** This is NOT balanced\n" }
	else
	   { print "** This is balanced\n" }
}
else
     { print "** Nothing to balance\n" }



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2604
***************************************


home help back first fref pref prev next nref lref last post