[25770] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8009 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 22 21:05:22 2005

Date: Fri, 22 Apr 2005 18:05: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           Fri, 22 Apr 2005     Volume: 10 Number: 8009

Today's topics:
    Re: Adding Perl Core functions <spamtrap@dot-app.org>
    Re: Installing JPL on Mac OS X <tadmc@augustmail.com>
    Re: Looping almost the same repetitive lines <tadmc@augustmail.com>
    Re: Looping almost the same repetitive lines <tadmc@augustmail.com>
    Re: Matching mixed up words <pilkowsk@informatik.uni-marburg.de>
    Re: NET::DNS (Vorxion)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 22 Apr 2005 20:22:58 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Adding Perl Core functions
Message-Id: <5e6dncuq8_X_CPTfRVn-2A@adelphia.com>

Mark Clements wrote:
> Guenther Sohler wrote:
> 
>> Now I want to call c routines from within the perl code.
>> How can I do so?
> 
> Read the documentation for xs.
> 
> man perlxs

Also, "perldoc perlxstut" for an XS tutorial.

And, "perldoc perl" has a section that lists a number of relevant docs, 
titled "Internals and C Language Interface".

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 22 Apr 2005 18:36:06 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Installing JPL on Mac OS X
Message-Id: <slrnd6j2j6.5up.tadmc@magna.augustmail.com>

Paul J. Lucas <pauljlucas-removethis@removethistoo.mac.com> wrote:
> Tad McClellan <tadmc@augustmail.com> wrote:
>> Paul J. Lucas <pauljlucas-removethis@removethistoo.mac.com> wrote:
>> 
>> >       Has anybody built JPL successfully under Mac OS X?
>> 
>> What is "JPL" ?
> 
> 	http://www.oreilly.com/catalog/prkunix/excerpt/UGch03.html


Oh.

I was wondering how you "built" the Jet Propulsion Laboratory under OS X.

:-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 22 Apr 2005 18:27:46 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Looping almost the same repetitive lines
Message-Id: <slrnd6j23i.5up.tadmc@magna.augustmail.com>

Nikos <hackeras@gmail.com> wrote:
> Tad McClellan wrote:
>> Nikos <hackeras@gmail.com> wrote:
>> 
>> 
>>>ps. its ok about the my i actually never use them.
> 
> But man i 


It is not about *you*.

It is about your audience (us).

Rather than use strict and have a computer find common mistakes,
you ask *hundreds of live people* to find the common mistakes.

You are disrespectful of people's time when you ask them to
debug before asking a machine to debug.

It is demeaning to be asked to do the work of a machine.

If you continue to demean folks here, pretty soon you will be
in all of the killfiles, and getting help will be much much harder.

Do whatever you like in *your* programs, but if you are going to
ask volunteers to help with it, then first put

   use strict;
   use warnings;

at the top of your program and get it to run without complaint.


> write small cgi progs and i always define the varibles and use 
> them once so its not big deal if i dont use my.


Every college CS freshman knows that global variables are bad.

But you seem to know better than the collective wisdom of
nearly the entire history of computing?

I'm sceptical...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 22 Apr 2005 18:32:00 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Looping almost the same repetitive lines
Message-Id: <slrnd6j2bg.5up.tadmc@magna.augustmail.com>

Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr> wrote:


> You've been advised *multiple* times to use 
> warnings, and strict, and lexically scoped variables. There is good 
> reason for that advice. 


But Nikos knows better than us, and so can reject common wisdom
that all of us "lesser" people follow as a matter of best practices.

(which makes me wonder why he needs our help...)


> If you want help, you have to 
> take certain things on board. You do not appear to be doing this.
> 
> I don't think I can help you any further.


Me either, which is why I did what I did. It is hopeless.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 23 Apr 2005 00:07:24 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: Matching mixed up words
Message-Id: <3ctartF6p4jr0U1@individual.net>

* Michael T. Davis schrieb:
> In article <3cqi4sF6n2237U1@individual.net>, Fabian Pilkowski
> <pilkowsk@informatik.uni-marburg.de> writes:

>>I think, Abigail has shown such a trick in this thread. Scout about:
>>
>>    (?(?{grep {$_} values %h})(?!)|)
>>
>>The inner (?{code}) is what you want to eval, surrounded by a construct
>>called
>>
>>    (?(condition)yes-pattern|no-pattern)
>>
>>in `perldoc perlre`. Furthermore, »(?!)« never matchs, while the empty
>>pattern matchs always.
> 
> 	OK, so I need to modify my test pattern as follows:
> 
>      \sg((?i)[a-z]+?)s?\W(?(?{anagram($+,'host','houl','remlin')}).*$|(?!))
> 
> I read this as...
> 
>  Match a (plural) anagram of "ghost", "ghoul" or "gremlin" with a leading
>  white-space character and a trailing non-word character. If the anagram
>  matches, consume the rest of the line; otherwise, let the match fail.

I think, you misread a little bit ;-) I read:

    Match one white-space followed by "g". Thereafter a few alphabetic
    chars with a trailing optional "s". A non-word char must follow. I
    agree with: If the anagram matches, consume the rest of the line;
    otherwise, let the match fail.

Now, have a look at your test string of " ermlgin " you mentioned below.
It does start with »\s« but that is *not* followed by "g". Therefore the
whole regex cannot match this string. Even if you omit the »\s« at the
beginning, $+ would contain "in" (the part behind "g"). I think you want
do something like

    \s([a-zA-Z]+)s?\W(?(?{anagram($+,'ghost','ghoul','gremlin')}).*$|(?!))

Btw, »[a-zA-Z]+« is shorter than »(?i)[a-z]+«, and the non-greedy »?«
isn't needed due to the »\W« you enforced thereafter.

> 
> Here's my anagram code:
> 
>     use re 'eval';
>     sub anagram
>     {
>         my ( $result, $t, $target );
> 
>         $result = '';
>         $target = shift ( @_ );
>         $t = join "", sort { lc ( $a ) cmp lc ( $b ) } split //, $target;
>         foreach $word ( @_ )
>         {
>             my $w;
>             next if length ( $word ) != length ( $target );
>             $w = join "", sort { lc ( $a ) cmp lc ( $b ) } split //, $word;
>             $result = $w eq $t;
>             last if $result
>         }
>         if ( $result )
>         {
>             return $target
>         }
>         else
>         {
>             return $result
>         }
>     }
> 
> Through a diagnosic print statement, I can confirm that my test string of
> " ermlgin " would match, but the match test that calls anagram via re-eval
> isn't matching:
> 
>                       ( $match ) = $string =~ /($pattern)/i
> 
> ($string = " ermlgin " and $pattern is the pattern, above.)  What am I
> missing?

You haven't read Abigail's postings carefully enough. You cannot use any
other regex in the re-eval, so split() isn't allowed inside of anagram()
you are calling there. Have you tried to print() a debug message inside
of anagram()?. I had, but nothing is printed out -- but why? Ok, the sub
anagram() is only called if there are no regexes inside, I guess.

From that place you have to rewrite anagram(). I'd do it this way:


    sub anagram {
        my $result = '';
        my $target = shift ( @_ );
        my $t = join "", sort { lc ( $a ) cmp lc ( $b ) }
                map { substr $target, $_, 1 } 0 .. length($target)-1;
        foreach my $word ( @_ ) {
            next if length ( $word ) != length ( $target );
            my $w = join "", sort { lc ( $a ) cmp lc ( $b ) }
                 map { substr $word, $_, 1 } 0 .. length($word)-1;
            $result = $w eq $t;
            last if $result
        }
        return $result ? $target : $result;
    }


I haven't checked if this sub is doing what you want -- I just replaced
the split() calls and summarized the return statement. It seems there
are more things you could improve. I hope I have understood what you
want -- hence, I tested it this way:


    my $string = " start ermlgin ";
    my $pattern = qr/\s([a-zA-Z]+)s?\W(?(?{anagram($+,'ghost','ghoul','gremlin')}).*$|(?!))/;
    my( $match ) = $string =~ m/($pattern)/i;
    print "[$match]";


For me, this prints out

    [ ermlign ]
    
what is what you want, I thought. Btw, there is no »use re 'eval'« in my
test script. I hope this could help you.

regards,
fabian


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

Date: 22 Apr 2005 18:15:40 -0400
From: vorxion@knockingshopofthemind.com (Vorxion)
Subject: Re: NET::DNS
Message-Id: <4269778c$1_1@news.iglou.com>

In article <4269056b$0$1150$5402220f@news.sunrise.ch>, Alexandre Jaquet wrote:
>Alexandre Jaquet a écrit :
>> I'm trying to get HINFO values via  :
[snip]
>maybe this is because the record is not used

Possible.  Likely, even--same thing will happen if you try an NXDOMAIN A
record, but even more likely since widespread HINFO use fell out of favour
around 1991 or so.  As with so many things (finger comes to mind), what was
once a useful tool is now considered a security risk.

-- 
Vorxion - Founder of the knocking-shop of the mind.

"You have it, you sell it, you've still got it--what's the difference?"
--Diana Trent, "Waiting for God", on why a modelling agency is really a
knocking-shop.  Applied by me to the field of consulting.  :)

The Sci-Fi fan's solution to debt:  Reverse the polarity on your charge card.


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

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 8009
***************************************


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