[31346] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2591 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 9 14:09:51 2009

Date: Wed, 9 Sep 2009 11:09:11 -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           Wed, 9 Sep 2009     Volume: 11 Number: 2591

Today's topics:
    Re: add a 3 lines of text in a file before "package" in <xhoster@gmail.com>
        Beginner question about "inheritance" <mikaelpetterson@hotmail.com>
        Data::FormValidator fails many tests <abc@def.com>
    Re: Data::FormValidator fails many tests <abc@def.com>
        FAQ 1.12 What's the difference between "perl" and "Perl <brian@theperlreview.com>
        FAQ 3.19 How can I make my CGI script more efficient? <brian@theperlreview.com>
        FAQ 3.3 Is there a Perl shell? <brian@theperlreview.com>
    Re: IPC::Open2::open2() -- How to pass strings stdin, s <hjp-usenet2@hjp.at>
    Re: IPC::Open2::open2() -- How to pass strings stdin, s <hjp-usenet2@hjp.at>
    Re: Need expert help matching a line sln@netherlands.com
        perl regex : surround tabbed numeric field by double qu <toralf.foerster@gmx.de>
    Re: perl regex : surround tabbed numeric field by doubl <source@netcom.com>
    Re: Perl regex expression to return values <ipellew@yahoo.com>
    Re: Perl regex expression to return values sln@netherlands.com
        public key encryption <jwilson@andover.edu>
        split a big program into main + (optional) advanced <bruzzim@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 08 Sep 2009 19:11:32 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: add a 3 lines of text in a file before "package" in file
Message-Id: <4aa711ed$1$26541$ed362ca5@nr5-q3a.newsreader.com>

Ben Morrow wrote:
> Quoth Tad J McClellan <tadmc@seesig.invalid>:
>> mike <mikaelpetterson@hotmail.com> wrote:
>>> sub modify {
>>> 	my @line_array;
>>> 	my $line;
>>> 	my ($file) = @_;
>>> 	print "Modifying file, $file\n";
>>> 	tie @line_array, 'Tie::File', $file or die "Can not tie file:$!";
>>
>> foreach my $i ( 0 .. $#line_array) {
> 
> This will read the entire file to count the lines before it starts,
> removing any benefit of using Tie::File.

That is far from the only benefit of Tie::File.  I don't think it is 
even one of the benefits of Tie::File to start with.  Not that I think 
that Tie::File has all that many benefits to start with.  One of the 
benefits it does have is letting you write into the middle of a file in 
a way that syntactically and logically easy, though quite inefficient. 
This benefit is maintained, and ISTM is the whole point.

Xho


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

Date: Wed, 9 Sep 2009 03:17:46 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: Beginner question about "inheritance"
Message-Id: <4816011e-46f3-440c-bfc1-4fd37c00dfe4@z24g2000yqb.googlegroups.com>

Hi,

In a ModifiedCleartool.pm file we have the following:

use base 'IPC::ClearTool';

If I use the module ( ModifiedCleartool.pm) by setting path to it in
my perl script.

use lib qw(/path/to/the/module);

Can I use the ClearTool functions provided.

br,

//mike


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

Date: Wed, 09 Sep 2009 13:32:41 +0100
From: zaphod <abc@def.com>
Subject: Data::FormValidator fails many tests
Message-Id: <voOdnSCw-8_3PTrXnZ2dnUVZ8gSdnZ2d@brightview.co.uk>

System: Mac OS X Leopard/PPC 10.5.8, Perl 5.8.8

Installing Data::FormValidator fails many tests, starting with:


Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_base.t .............................. ok   
t/02_code_ref.t .......................... 1/8 
#   Failed test at t/02_code_ref.t line 46.

#   Failed test at t/02_code_ref.t line 48.

#   Failed test at t/02_code_ref.t line 50.
#          got: undef
#     expected: 'email'
Can't use an undefined value as an ARRAY reference at t/02_code_ref.t line 53.
# Looks like you planned 8 tests but ran 3.
# Looks like you failed 3 tests of 3 run.
# Looks like your test exited with 2 just after 3.
t/02_code_ref.t .......................... Dubious, test returned 2 (wstat 512, 0x200)
Failed 8/8 subtests 
t/03_dependency.t ........................ ok     
t/04_arrayify_undef.t .................... ok   
t/05_valid_ip_address.t .................. ok   
t/06_regexp_map.t ........................ 1/5 
#   Failed test at t/06_regexp_map.t line 34.

#   Failed test at t/06_regexp_map.t line 35.

#   Failed test at t/06_regexp_map.t line 37.

#   Failed test at t/06_regexp_map.t line 38.

#   Failed test at t/06_regexp_map.t line 39.
# Looks like you failed 5 tests of 5.
t/06_regexp_map.t ........................ Dubious, test returned 5 (wstat 1280, 0x500)


********************  Summary test report ******************

Test Summary Report
-------------------
t/02_code_ref.t                        (Wstat: 512 Tests: 3 Failed: 3)
  Failed tests:  1-3
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 8 tests but ran 3.
t/06_regexp_map.t                      (Wstat: 1280 Tests: 5 Failed: 5)
  Failed tests:  1-5
  Non-zero exit status: 5
t/11_procedural_match.t                (Wstat: 512 Tests: 26 Failed: 2)
  Failed tests:  19-20
  Non-zero exit status: 2
t/18_constraint_refs.t                 (Wstat: 512 Tests: 2 Failed: 1)
  Failed test:  2
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 4 tests but ran 2.
t/26_qr.t                              (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/constraint_regexp_map_profile_reuse.t (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/constraints_regexp_map_interaction.t (Wstat: 512 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 2
t/filter_constraints.t                 (Wstat: 256 Tests: 2 Failed: 1)
  Failed test:  2
  Non-zero exit status: 1
  Parse errors: Bad plan.  You planned 4 tests but ran 2.
t/missing_optional.t                   (Wstat: 1536 Tests: 9 Failed: 6)
  Failed tests:  1-6
  Non-zero exit status: 6
t/msgs.t                               (Wstat: 512 Tests: 7 Failed: 7)
  Failed tests:  1-7
  Non-zero exit status: 2
t/procedural_valid.t                   (Wstat: 512 Tests: 27 Failed: 2)
  Failed tests:  9-10
  Non-zero exit status: 2
t/simple.t                             (Wstat: 768 Tests: 3 Failed: 3)
  Failed tests:  1-3
  Non-zero exit status: 3
t/untaint.t                            (Wstat: 0 Tests: 15 Failed: 9)
  Failed tests:  5-6, 8-9, 11-15
  Parse errors: Bad plan.  You planned 55 tests but ran 15.
t/upload.t                             (Wstat: 512 Tests: 3 Failed: 1)
  Failed test:  3
  Non-zero exit status: 2
t/upload_closure.t                     (Wstat: 512 Tests: 3 Failed: 1)
  Failed test:  3
  Non-zero exit status: 2
Files=61, Tests=464,  9 wallclock secs ( 0.60 usr  0.62 sys +  6.01 cusr  1.69 csys =  8.92 CPU)
Result: FAIL
Failed 15/61 test programs. 42/464 subtests failed.
make: *** [test_dynamic] Error 255
  /usr/bin/make test -- NOT OK
Running make install
  make test had returned bad status, won't install without force



zaphod






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

Date: Wed, 09 Sep 2009 14:00:29 +0100
From: zaphod <abc@def.com>
Subject: Re: Data::FormValidator fails many tests
Message-Id: <DuadnSRmiOZwOzrXnZ2dnUVZ8rdi4p2d@brightview.co.uk>

Resolved. Many dependencies not auto-insalled. Grrr!

zaphod


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

Date: Wed, 09 Sep 2009 04:00:17 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 1.12 What's the difference between "perl" and "Perl"?
Message-Id: <lLFpm.219640$ZN.37470@newsfe23.iad>

This is an excerpt from the latest version perlfaq1.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 .

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

1.12: What's the difference between "perl" and "Perl"?

    One bit. Oh, you weren't talking ASCII? :-) Larry now uses "Perl" to
    signify the language proper and "perl" the implementation of it, i.e.
    the current interpreter. Hence Tom's quip that "Nothing but perl can
    parse Perl."

    Before the first edition of *Programming perl*, people commonly referred
    to the language as "perl", and its name appeared that way in the title
    because it referred to the interpreter. In the book, Randal Schwartz
    capitalised the language's name to make it stand out better when
    typeset. This convention was adopted by the community, and the second
    edition became *Programming Perl*, using the capitalized version of the
    name to refer to the language.

    You may or may not choose to follow this usage. For example, parallelism
    means "awk and perl" and "Python and Perl" look good, while "awk and
    Perl" and "Python and perl" do not. But never write "PERL", because perl
    is not an acronym, apocryphal folklore and post-facto expansions
    notwithstanding.



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

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: Wed, 09 Sep 2009 10:00:02 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 3.19 How can I make my CGI script more efficient?
Message-Id: <C0Lpm.158208$cf6.9547@newsfe16.iad>

This is an excerpt from the latest version perlfaq3.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 .

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

3.19: How can I make my CGI script more efficient?

    Beyond the normal measures described to make general Perl programs
    faster or smaller, a CGI program has additional issues. It may be run
    several times per second. Given that each time it runs it will need to
    be re-compiled and will often allocate a megabyte or more of system
    memory, this can be a killer. Compiling into C isn't going to help you
    because the process start-up overhead is where the bottleneck is.

    There are two popular ways to avoid this overhead. One solution involves
    running the Apache HTTP server (available from http://www.apache.org/ )
    with either of the mod_perl or mod_fastcgi plugin modules.

    With mod_perl and the Apache::Registry module (distributed with
    mod_perl), httpd will run with an embedded Perl interpreter which
    pre-compiles your script and then executes it within the same address
    space without forking. The Apache extension also gives Perl access to
    the internal server API, so modules written in Perl can do just about
    anything a module written in C can. For more on mod_perl, see
    http://perl.apache.org/

    With the FCGI module (from CPAN) and the mod_fastcgi module (available
    from http://www.fastcgi.com/ ) each of your Perl programs becomes a
    permanent CGI daemon process.

    Both of these solutions can have far-reaching effects on your system and
    on the way you write your CGI programs, so investigate them with care.

    See
    http://www.cpan.org/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/
    .



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

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: Wed, 09 Sep 2009 16:00:03 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 3.3 Is there a Perl shell?
Message-Id: <7iQpm.158217$cf6.97352@newsfe16.iad>

This is an excerpt from the latest version perlfaq3.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 .

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

3.3: Is there a Perl shell?

    The psh (Perl sh) is currently at version 1.8. The Perl Shell is a shell
    that combines the interactive nature of a Unix shell with the power of
    Perl. The goal is a full featured shell that behaves as expected for
    normal shell activity and uses Perl syntax and functionality for
    control-flow statements and other things. You can get psh at
    http://sourceforge.net/projects/psh/ .

    Zoidberg is a similar project and provides a shell written in perl,
    configured in perl and operated in perl. It is intended as a login shell
    and development environment. It can be found at
    http://pardus-larus.student.utwente.nl/~pardus/projects/zoidberg/ or
    your local CPAN mirror.

    The Shell.pm module (distributed with Perl) makes Perl try commands
    which aren't part of the Perl language as shell commands. perlsh from
    the source distribution is simplistic and uninteresting, but may still
    be what you want.



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

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: Wed, 9 Sep 2009 10:58:23 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: IPC::Open2::open2() -- How to pass strings stdin, stdout?
Message-Id: <slrnhaerhg.um8.hjp-usenet2@hrunkner.hjp.at>

Please quote relevant parts from the posting you are replying to.

On 2009-09-08 12:04, Jerry Krinock <jerrykrinock@gmail.com> wrote:
> First, I tried Uri's code, but it has the same problem as mine.  That
> is, it waits forever, on the line
>        my $out = <$chld_out> ;

You already mentioned to solution to this problem in your first posting:
You need to close $chld_in after you are done sending data to it.
Otherwise, how  does your filter know you are done?

	hp


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

Date: Wed, 9 Sep 2009 12:02:10 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: IPC::Open2::open2() -- How to pass strings stdin, stdout?
Message-Id: <slrnhaev94.um8.hjp-usenet2@hrunkner.hjp.at>

On 2009-09-08 20:47, Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth Jerry Krinock <jerry@ieee.org>:
>> Use this in lieu of open2() and the methods of Expect.pm, both
>> of which will hang indefinitely unless the program supports
>> unbuffered I/O, typically a -u option.
>
> This comment is inaccurate. It is perfectly possible to drive a program
> that uses buffered IO using open2, you just need to be ready to feed
> input as needed and get output as it arrives.

Yes. Using select (or IO::Select) is a bit tricky, though. There are a
few frameworks for handling async Events and I/O, but I've never used
them.


>> sub getStdoutWithStdinFromCmd {
>> 	my $cmd = shift ;
>> 	my $stdin = shift ;
>> 
>> 	return `echo \"$stdin\" | \"$cmd\"` ;
>
> This is a bad idea. For one thing, if $stdin contains a '$' you will not
> get the input you expect; for another, if $stding is longer than the
> (system-specific) maximum command-line length, this will fail.
>
> Forking a child to feed the input pipe might, however, be a sensible
> solution.

Yes. That is frequently the simplest solution, especially if you could
write it as a pipe sequence in the shell.

> Something like
>
>     use POSIX qw/_exit/;
>
>     my $kid = fork;
>     defined $kid or die "can't fork: $!";
>
>     unless ($kid) {
>         print *Writer $stdin;

I assume Writer comes from open2 in your snippet? 

In this case I wouldn't use open2. You don't need a bidirectional
communication, so just use plain open:


#!/usr/bin/perl
use warnings;
use strict;


my $pid1 = open(my $filter_out, '-|');
if ($pid1 == 0) {
    # kid process
    # STDOUT is connected to $filter_out in the parent.
    # now we start the filter
    my $pid2 = open(my $filter_in, '|-', 'tr', 'a-z', 'A-Z');
    # $filter_in is now connected to stdin of the filter,
    # stdout of the filter is still connected to $filter_out
    # of the parent.
    # So we when we print something to $filter_in, it is passed through 
    # the filter to the parent.
    for ('a' .. 'z', 'a' .. 'z', 'a' .. 'z') {
        print STDERR "kid: sending $_\n";
        print $filter_in $_ x 80, "\n";
        sleep 1;
    }
    # exit will close the pipe to the filter which will cause the
    # filter to terminate which will close the pipe to the parent.
    # so everything is cleaned up after that.
    exit 0;
} else {
    while (<$filter_out>) {
        print STDERR "parent: received $_";
    }
}

# child is reaped when $filter_out goes out of scope
__END__

(error handling is left as an exercise for the reader)

On my system this prints:

kid: sending a
kid: sending b
 ...
kid: sending y
kid: sending z
kid: sending a
kid: sending b
 ...
kid: sending x
kid: sending y
parent: received AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
parent: received YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
parent: received ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
parent: received AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
parent: received BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
 ...
parent: received XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
kid: sending z
kid: sending a
 ...
kid: sending y
kid: sending z
parent: received YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
parent: received ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
parent: received AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
parent: received BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
 ...
parent: received YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
parent: received ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

Note the asynchronous output caused by buffering.

	hp



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

Date: Tue, 08 Sep 2009 18:31:39 -0700
From: sln@netherlands.com
Subject: Re: Need expert help matching a line
Message-Id: <ennda5tqu6r0tidbt8mpdg1a4bm770hob9@4ax.com>

On Tue, 8 Sep 2009 15:38:21 -0700 (PDT), Ramon F Herrera <ramon@conexus.net> wrote:

>On Sep 8, 6:20 pm, Ramon F Herrera <ra...@conexus.net> wrote:
>> On Sep 8, 1:35 pm, s...@netherlands.com wrote:
>>
>> > On Tue, 8 Sep 2009 05:23:32 -0700 (PDT), Ramon F Herrera <ra...@conexus.net> wrote:
>>
>I have made some progress here:
>
>const string variable = "(\\w+[\\w\\d\\. ]*)";
>const char equal_sign = '=';
>const string value    = "(.+)";
>
>I think the above will cover most real cases, but not sure what will
>happen if the RHS contains an '=' sign?
>
>-RFH

  "(\\w+[\\w\\d\\. ]*)";
     ^ don't you want alpha first character?
  "(\\w+[\\w\\d\\. ]*)";
              ^ this is redundant

Otherwise, it looks ok. Since Boost is using Perl 5.8, you may
be able to do some validation and trimming all in the regex components.

// VAR Capture: alpha start char, other chars alphanumeric, space and '.',
// Trim (do not capture) trailing white spaces before 'equal_sign'
const string variable = "([a-zA-Z](?:(?!\s*=)[\\w. ])*)";
        // Breakdown:
        //   (  # start capture group
        //      [a-zA-Z]     # first char, alpha
        //      (?:          # pseudo group
        //          (?!\s*=)     # IF NOT whitespace(*) followed by equal sign
        //          [\w. ]       # AND this char is in this class
        //                       # THEN consume character
        //                       # ELSE fail (or trim) on this character
        //      )*           # end group, do none or many times
        //   )  # finish capture, done once


// Separator: whitespace, equal, whitespace (non-capture, considered trim)
const char equal_sign = "\\s*=\\s*";

// VAL Capture: any character up until a newline.
// Trim (do not capture) trailing white spaces before either
// equal sign (invalid separator), newline or end of string.
const string value    = "((?:(?!\s*(?:=|\n|$)).)+)";
        // Breakdown:
        //     ( # start capture group
        //        (?:     # pseudo group
        //            (?!       # IF NOT
        //                \s*         # whitespace(*) followed by
        //                (?:=|\n|$)  # equal or newline or end of string
        //            )
        //            .         # AND this char is not newline
        //                      # THEN consume character
        //                      # ELSE fail (or trim) on this character
        //        )+      # end group, do once or many times
        //     ) # finish capture, done once

Combined it looks something like this -
       /([a-zA-Z](?:(?!\s*=)[\w. ])*)\s*=\s*((?:(?!\s*(?:=|\n|$)).)+)/

I am guilty of too much info. It looks worse than it really is.
Thanks for that Boost info.

-sln





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

Date: Wed, 9 Sep 2009 14:39:59 +0000 (UTC)
From: toralf <toralf.foerster@gmx.de>
Subject: perl regex : surround tabbed numeric field by double quotes
Message-Id: <h88env$pa4$1@news.eternal-september.org>

I've a file containing tab separated values - most, but not all are
quoted - and now I'm wondering how to substitute a non-quoted value like
<tab>20090807<tab> by sth. like <tab>"20090807"<tab>

-- 
MfG/Sincerely

Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3




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

Date: Wed, 09 Sep 2009 09:43:36 -0700
From: David Harmon <source@netcom.com>
Subject: Re: perl regex : surround tabbed numeric field by double quotes
Message-Id: <KMmdnRtbu-31RjrXnZ2dnUVZ_vadnZ2d@earthlink.com>

On Wed, 9 Sep 2009 14:39:59 +0000 (UTC) in comp.lang.perl.misc, toralf
<toralf.foerster@gmx.de> wrote,
>I've a file containing tab separated values - most, but not all are
>quoted - and now I'm wondering how to substitute a non-quoted value like
><tab>20090807<tab> by sth. like <tab>"20090807"<tab>

What part are you having trouble with?  What did you try and what
happened?

I suggest, use regex substitution s/// with \t for tab, capture the
string of digits, then use $1 to put them back in the replacement
string.  Don't forget to account for the first and last fields not
having both tabs.



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

Date: Wed, 9 Sep 2009 01:27:13 -0700 (PDT)
From: ian <ipellew@yahoo.com>
Subject: Re: Perl regex expression to return values
Message-Id: <3b4cfa00-98d0-44e1-b7c9-e63369039210@q7g2000yqi.googlegroups.com>

Netherlands works, but John's does not !!
To be fair to John, this may come down to
version, as the Perl blardy blar tells us this is
very Release concious.
I am using Perl 5  version 10.

I can't help but think that Perl missed a golden
opportunity here in sort of having a Perl
function sub set inside the m{...}x;

EG:-
my $success = m{
                  .*
       my $date = ( \d{4] - \d{2} - ....... )
                  .*
       my $srv =  ( \w* ) \W
                  .*
  ... etc
               }x;


Regards
Ian


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

Date: Wed, 09 Sep 2009 10:55:36 -0700
From: sln@netherlands.com
Subject: Re: Perl regex expression to return values
Message-Id: <v8qfa51g22458fpfscrl2mqvcjnfshurlb@4ax.com>

On Wed, 9 Sep 2009 01:27:13 -0700 (PDT), ian <ipellew@yahoo.com> wrote:

>Netherlands works, but John's does not !!
>To be fair to John, this may come down to
>version, as the Perl blardy blar tells us this is
>very Release concious.
>I am using Perl 5  version 10.
>
>I can't help but think that Perl missed a golden
>opportunity here in sort of having a Perl
>function sub set inside the m{...}x;
>
>EG:-
>my $success = m{
>                  .*
>       my $date = ( \d{4] - \d{2} - ....... )
>                  .*
>       my $srv =  ( \w* ) \W
>                  .*
>  ... etc
>               }x;
>
>
>Regards
>Ian

John's code works on my machine. Maybe something got lost in the cut'n paste.

As far as asigning specific capture to variables, that is possible
in perl 5.8 or 5.10

Inside a code block (?{..}) (version 5.8 and up):
   ( Returning \s+ from | Entering ) \s* (?{ $Action  = $^N })

There's always named capture variables (new in 5.10):
-------------
  use strict;
  use warnings;

  while ( <DATA> ) {
     chomp;
     m{
         .*
         (?<O1_Date>      \d\d\d\d - \d\d - \d\d \s+ \d\d : \d\d : \d\d )
                          . \d* \s
         (?<O1_Type>      \w* ) \W
         (?<O2_From>      .* - \s* )
         (?<O3_Action>    Returning \s+ from | Entering ) \s*
         (?<O4_Function>  [\w._]+ )
         (?<O5_Parms>     \( [^()]* \) )
         (?:
             (?<O6_Result> , \s+ \w+ : \s+ )
             (?<O7_Output> .* )
         )?
     }x;

     my %capt = %+;
     for my $key (sort keys %capt) {
          my $val = $capt{$key};
          $key =~ s/.*_//;
          print "$key:   \t$val\n";
     }
     print "\n";
     next;
  }
  print "-----------\n";
__END__

-sln




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

Date: Wed, 9 Sep 2009 07:24:56 -0700 (PDT)
From: jpw <jwilson@andover.edu>
Subject: public key encryption
Message-Id: <7dc71e65-1c98-4123-914c-eba85922af6a@t13g2000yqn.googlegroups.com>

I am looking to encrypt a string with PERL using private/public key
encryption.  I have tried several solutions from a google query
without much luck.  The string will need to be decrypted in a ASP.NET
environment.  One of the examples I found gives me errors:

script (file called "rsa"):
print pack"C*",split/\D+/,`echo "16iII*o\U@{$/=$z;
[(pop,pop,unpack"H*",<>
)]}\EsMsKsN0[lN*1lK[d2%Sa2/d0<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<J]dsJxp"|
dc`

calling stmt:  echo "Mother of Perl" | rsa -k=10001 -n=1967cb529 >
msg.rsa

error:
7 packC*,split/D+/,134 is unimplemented 125 is unimplemented 100 is
unimplemented 173 is unimplemented 44 is unimplemented stack empty
stack empty stack empty stack empty 175 is unimplemented 134 is
unimplemented save:args 116 is unimplemented exp not an integer divide
by 0 divide by 0 0
sg.rsa: END


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

Date: Wed, 9 Sep 2009 08:49:18 -0700 (PDT)
From: Freddie <bruzzim@gmail.com>
Subject: split a big program into main + (optional) advanced
Message-Id: <279b91f1-fe1a-4b26-a57a-400fc23284bb@l9g2000yqi.googlegroups.com>

I have a hotel managerial software that I wrote in perl-tk that I
would split into 2

- the main part with all base functionalities
- the advanced (and optional) part with advanced functionalities
I'd like the main would import the advanced if present, in that case
the main would
offer all functionalities to the user otherwise just the base ones.

I tried to use the 'do' (and require, actually) without success. I'd
like to have the following working:

# main.pl
  $mw->configure(-menu => my $menubar = $mw->Menu);
  my $menuMain = $menubar->cascade(-label => '~Checkin', -tearoff
=> 0);
do 'advanced.pl';

# advanced.pl
my $menuAdv = $menubar->cascade(-label => '~Advanced Cash', -tearoff
=> 0);


Thanks and best regards,

Freddie


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

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:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#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 2591
***************************************


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