[26522] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8672 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 16 11:05:39 2005

Date: Wed, 16 Nov 2005 08:05:05 -0800 (PST)
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, 16 Nov 2005     Volume: 10 Number: 8672

Today's topics:
    Re: Grouping like items together (Anno Siegel)
        ISO regex analysis and debugging tools <socyl@987jk.com.invalid>
    Re: ISO regex analysis and debugging tools <ekkehard.horner@arcor.de>
    Re: strange problem with system() and backtick operator <news@chaos-net.de>
    Re: strange problem with system() and backtick operator <someone@example.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 16 Nov 2005 14:35:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Grouping like items together
Message-Id: <dlfg35$dqt$1@mamenchi.zrz.TU-Berlin.DE>

AcCeSsDeNiEd  <dillon@SpamMinuSaccessdenied.darktech.org> wrote in comp.lang.perl.misc:
> On Tue, 15 Nov 2005 08:48:14 -0600, Tad McClellan <tadmc@augustmail.com> wrote:
> 
> Well, I've just given up doing this programmatically.
> I've taken a closer look at the naming conventions.
> One method I thought off was to split the name from the numbers.
> But I've come across files that do not have numbers just after the
> client's name.
> The client name always comes on the left of the filename, but the rest
> of the filename is just too
> 'gibberish'.
> 
> Not gonna happen. At least not until computers are capable of AI.
> 
> Thx for the help anyways.
> 
> My coy will just have to hire temp staff to clean up this mess.
> 
> Btw, we have 400k files.
> So good luck on the manual process.

A list of valid names (even a modest one) could help sorting out the
clear cases.  If everything in the formats "first middle last",
"first last" and "first middle" with verified "first" and "last"
(and middle something like /[[:upper:]]\./ was accepted automatically,
that could reduce the amount of manual processing considerably.  I am
appending a sketch of how this could work.

Name lists are available from the US Census Bureau, typical file names
are dist.all.last, dist.female.first, and dist.male.first.

Anno

#!/usr/bin/perl
use strict; use warnings; $| = 1; # @^~`
use Vi::QuickFix;

my ( %first, %last);
my $namedir = "$ENV{ HOME}/dict/us-census-names";
my $in;
open $in, $_ or die "Can't read $_: $!" for "$namedir/dist.female.first";
@first{ map /(\S+)/, <$in> } = ();
open $in, $_ or die "Can't read $_: $!" for "$namedir/dist.male.first";
@first{ map /(\S+)/, <$in> } = ();
open $in, $_ or die "Can't read $_: $!" for "$namedir/dist.all.last";
@last{ map /(\S+)/, <$in> } = ();

my ( @accepted, @rejected);
while ( <DATA> ) {
    chomp;
    my ( $first, $middle, $last) = split;
    unless ( exists $first{ uc $first} ) {
        push @rejected, "$first $middle $last";
        next;
    }
    if ( $middle =~ /[[:upper:]]\./ ) {
        if ( exists $last{ uc $last} ) {
            push @accepted, "$first $middle $last";
        }
        else {
            push @accepted, "$first, $middle";
        }
    }
    else {
        $last = $middle;
        if ( exists $last{ uc $last} ) {
            push @accepted, "$first $last";
        }
        else {
            push @rejected, "$first $last";
        }
    }
}
print "accepted:\n";
print "$_\n" for @accepted;
print "\nrejected:\n";
print "$_\n" for @rejected;

__DATA__
Mike 12345.pdf
Mike G. 2332445-withdrawal.pdf
Mike G. 12345.pdf
Mike G. Johnson 12345.pdf
Mike F. Smith 12345.pdf
Mike F. Jones 12345.pdf
Mike F. Jones 12345 (01).pdf
Mike F. Jones 12345 (02).pdf
Mike F. 2332445-withdrawal.pdf
Mike F. 434324.sign.pdf
Mike F. 434324.everywhere_a_sign.pdf
Mike 12345.pdf
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Wed, 16 Nov 2005 12:24:57 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: ISO regex analysis and debugging tools
Message-Id: <dlf8ep$65v$1@reader2.panix.com>




I'm trying to debug some code not written by me.  The problem lies
in a regular expression that is generated dynamically by the program,
and depends on user input.  The bug shows up only with certain
inputs, and, unfortunately, for such inputs the problematic regex
turns out to be huge and hairy.  To make matters worse, it makes
heavy use of (?{...}) constructs.

I've stared at this monster regex for a while now, but I'm getting
nowhere.  I'm looking for some tools to help me analyze and debug
this thing.

For starters, a regex pretty-printer would be a huge help.

Also, anything like a regex debugger would be a godsend.  Is there
such a thing?

Any other tool I should be aware of?

Thanks!

kj
-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


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

Date: Wed, 16 Nov 2005 15:18:05 +0100
From: "ekkehard.horner" <ekkehard.horner@arcor.de>
Subject: Re: ISO regex analysis and debugging tools
Message-Id: <437b3f9e$0$7438$9b4e6d93@newsread4.arcor-online.net>

kj wrote:

> I'm trying to debug some code not written by me.  The problem lies
> in a regular expression that is generated dynamically by the program,
> and depends on user input.  The bug shows up only with certain
> inputs, and, unfortunately, for such inputs the problematic regex
> turns out to be huge and hairy.  To make matters worse, it makes
> heavy use of (?{...}) constructs.
> 
> I've stared at this monster regex for a while now, but I'm getting
> nowhere.  I'm looking for some tools to help me analyze and debug
> this thing.
> 
> For starters, a regex pretty-printer would be a huge help.
> 
> Also, anything like a regex debugger would be a godsend.  Is there
> such a thing?
> 
> Any other tool I should be aware of?
> 
> Thanks!
> 
> kj
Have a look at
    http://weitz.de/regex-coach/


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

Date: Wed, 16 Nov 2005 16:06:08 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: strange problem with system() and backtick operator
Message-Id: <slrndnmin0.fl.news@maki.homeunix.net>

A. Sinan Unur wrote :
>
> perldoc -f oct
>
>    oct EXPR
>    oct     Interprets EXPR as an octal string and returns the
>            corresponding value.
>
> Notice the "octal string".
>
> A number is just a number, that is it.
>
[script sniped]

Thank you for your help.
This clarifies a lot.

If I understand right, I should use "chmod oct($mode), 'file'" (like I
did ;-)) if $mode is the result of an addition (and not an octal value).

	perldoc -f oct 
	...
	The oct() function is commonly used when a string such as 644
	needs to be converted into a file mode, for example.

I also had some more time to look at my first problem.
Actually the file is not created by "$ftp->get()" when it is not readable on
the server (this was unexpected anyway).

I myself create the file later in the script with "`touch -t ....`"
because I want to set the modtime of the downloaded file to the modtime
of the file on the server.
After realizing this the solution was simple (using "and").

btw: is there a built-in function to manipulate modification time of
files in Perl?

Regards
Martin

-- 
perl -e '$S=[[73,116,114,115,31,96],[108,109,114,102,99,112],
[29,77,98,111,105,29],[100,93,95,103,97,110]];
for(0..3){for$s(0..5){print(chr($S->[$_]->[$s]+$_+1))}}'


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

Date: Wed, 16 Nov 2005 15:13:57 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: strange problem with system() and backtick operator
Message-Id: <V0Ief.112361$y_1.48523@edtnps89>

Martin Kissner wrote:
> 
> btw: is there a built-in function to manipulate modification time of
> files in Perl?

perldoc -f utime


John
-- 
use Perl;
program
fulfillment


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

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 V10 Issue 8672
***************************************


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