[25772] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8011 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 25 18:10:52 2005

Date: Mon, 25 Apr 2005 15:10:40 -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           Mon, 25 Apr 2005     Volume: 10 Number: 8011

Today's topics:
        loading a lot of values into an mysql database and loop <hackeras@gmail.com>
    Re: loading a lot of values into an mysql database and  <jgibson@mail.arc.nasa.gov>
    Re: loading a lot of values into an mysql database and  <john@castleamber.com>
    Re: loading a lot of values into an mysql database and  <hackeras@gmail.com>
    Re: loading a lot of values into an mysql database and  xhoster@gmail.com
    Re: loading a lot of values into an mysql database and  <hackeras@gmail.com>
    Re: loading a lot of values into an mysql database and  <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: loading a lot of values into an mysql database and  <tadmc@augustmail.com>
        Looping (continued) <hackeras@gmail.com>
    Re: Looping (continued) <hackeras@gmail.com>
    Re: Looping (continued) <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: Looping (continued) <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: Looping (continued) <tadmc@augustmail.com>
    Re: Looping (continued) <joe@inwap.com>
    Re: Looping almost the same repetitive lines <hackeras@gmail.com>
    Re: Matching mixed up words (Michael T. Davis)
        mod_perl 2 / apache 2 under windows <alexj@freesurf.ch>
    Re: mod_perl 2 / apache 2 under windows <noreply@gunnar.cc>
        NEWS: Have a miscarriage, get a tax deduction (Dave in Dallas)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 25 Apr 2005 22:14:37 +0300
From: Nikos <hackeras@gmail.com>
Subject: loading a lot of values into an mysql database and looping
Message-Id: <d4jfiu$83d$1@nic.grnet.gr>

ok before we go into the step i asked i must somehow load the games
database table with a row coantaining 3 fields. The games name, the
games description and the number of times the games downloaded by the user.

I had the table loaded with repetitive insert into statements but now
the games folder has more than 100+ games so i need a more automatic way
of filling it in.

I have made the following snippet of code but as usual it aint working
as it should so i could use a liitle Monk help/suggestions. After
completeing this part i will go to the one i first asked because now
that i deleted the insert into statements i must firstly load the
database table again Any way here is the code so far:

It would be even better that the description of the game would not be
the same text as the name of the game that why i have wriiten all the
description in one file in the same folder as games separating by one
line but i donw know hot to load them as a 2nd parameter to the 2nd ? in
prepare. Any way here is the code so far:

$db->do( "create table   games( name varchar, desc text, counter int"
+);


#=====================================================================
+==========

my $st = $db->prepare( "INSERT INTO games VALUES (?, ?, ?)" );
my @games = glob( "/data/games/*" ) or die $!;

print @games;

while (@games) {
         $st->execute( $_, $_, 0 );
}

#=====================================================================
+==========

# hre is the part that load the description game into an array from a
+file containign the descs

open(FILE, "</data/games/descriptions.txt") or die $!;
              my @desc = <FILE>;
close(FILE);

@desc = grep { !/^\s*\z/s } @desc;


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

Date: Mon, 25 Apr 2005 12:45:25 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: loading a lot of values into an mysql database and looping
Message-Id: <250420051245254467%jgibson@mail.arc.nasa.gov>

In article <d4jfiu$83d$1@nic.grnet.gr>, Nikos <hackeras@gmail.com>
wrote:

> ok before we go into the step i asked i must somehow load the games
> database table with a row coantaining 3 fields. The games name, the
> games description and the number of times the games downloaded by the user.
> 
> I had the table loaded with repetitive insert into statements but now
> the games folder has more than 100+ games so i need a more automatic way
> of filling it in.
> 
> I have made the following snippet of code but as usual it aint working
> as it should so i could use a liitle Monk help/suggestions. After
> completeing this part i will go to the one i first asked because now
> that i deleted the insert into statements i must firstly load the
> database table again Any way here is the code so far:
> 
> It would be even better that the description of the game would not be
> the same text as the name of the game that why i have wriiten all the
> description in one file in the same folder as games separating by one
> line but i donw know hot to load them as a 2nd parameter to the 2nd ? in
> prepare.

Put your game names and descriptions in a separate file, one game on
each line. Put the name first followed by a tab character followed by
the description, making sure that the description does not contain any
tabs. Read these descriptions into a hash with the following code
(untested):

my %descriptions;
open( my $desc, '<', 'descriptions.txt' ) or 
  die("Can't open descriptions file: $!");
while(<$desc>) {
   chomp;
   my( $name, $description ) = split(/\t/);
   $descriptions{$name} = $description;
}


> Any way here is the code so far:
> 
> $db->do( "create table   games( name varchar, desc text, counter int"
> +);
> 
> 
> #=====================================================================
> +==========
> 
> my $st = $db->prepare( "INSERT INTO games VALUES (?, ?, ?)" );
> my @games = glob( "/data/games/*" ) or die $!;
> 
> print @games;
> 
> while (@games) {
>          $st->execute( $_, $_, 0 );

Make the above line

         $st->execute( $_, $descriptions{$_}, 0 );

and you are done.

> }
> 
> #=====================================================================
> +==========
> 
> # hre is the part that load the description game into an array from a
> +file containign the descs
> 
> open(FILE, "</data/games/descriptions.txt") or die $!;
>               my @desc = <FILE>;
> close(FILE);
> 
> @desc = grep { !/^\s*\z/s } @desc;


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: 25 Apr 2005 19:45:43 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: loading a lot of values into an mysql database and looping
Message-Id: <Xns96439622A8E4castleamber@130.133.1.4>

Nikos wrote:

> I have made the following snippet of code but as usual it aint working
> as it should

You really think people are going to complete your script, set up a 
database, and fix it? 

Which error do you get? Or what is the behavior you see?

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Mon, 25 Apr 2005 23:14:04 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: loading a lot of values into an mysql database and looping
Message-Id: <d4jj2c$b6m$1@nic.grnet.gr>

Jim Gibson wrote:

> Put your game names and descriptions in a separate file, one game on
> each line. Put the name first followed by a tab character followed by
> the description, making sure that the description does not contain any
> tabs. Read these descriptions into a hash with the following code
> (untested):
> 
> my %descriptions;
> open( my $desc, '<', 'descriptions.txt' ) or 
>   die("Can't open descriptions file: $!");
> while(<$desc>) {
>    chomp;
>    my( $name, $description ) = split(/\t/);
>    $descriptions{$name} = $description;
> }

Thanks but i was wondering/thinking that there is no need actually to 
put except from the descriptions also the name of the games inside the 
description file since we can get all the games names from the game 
folder they are inside by doing this:

my @games = </data/games/*.rar> or die $!;

What do you think?


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

Date: 25 Apr 2005 20:58:15 GMT
From: xhoster@gmail.com
Subject: Re: loading a lot of values into an mysql database and looping
Message-Id: <20050425165814.993$G3@newsreader.com>

Nikos <hackeras@gmail.com> wrote:
>
> while (@games) {
>          $st->execute( $_, $_, 0 );
> }

This looks like an infinite loop to me.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Tue, 26 Apr 2005 00:05:31 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: loading a lot of values into an mysql database and looping
Message-Id: <d4jm2o$ds8$1@nic.grnet.gr>

xhoster@gmail.com wrote:
> Nikos <hackeras@gmail.com> wrote:
> 
>>while (@games) {
>>         $st->execute( $_, $_, 0 );
>>}

Actually now is changed to:

$db->do( "create table   games( onoma text, description text, counter 
int )" ) or die $!;


#===============================================================================

my %descriptions;
open( my $desc, "</data/games/perigrafes.txt" ) or die $!;

while(<$desc>) {
         chomp;
         my( $name, $description ) = split(/\t/);
         $descriptions{$name} = $description;
}

my $st = $db->prepare( "INSERT INTO games VALUES (?, ?, ?)" );

my @games = </data/games/*.rar> or die $!;

while (@games) {
         $st->execute( $_, $descriptions{$_}, 0 );
}

#===============================================================================


And here si the code that tries to displays those database table values 
in a esy appelaing way:

my $row;
while ( $row = $st->fetchrow_hashref ) {

     print table( {class=>'info'},
           Tr(
              td( submit( -name=>'game', -value=>$_->{name} )),
              td( $_->{description} ),
              td( $_->{counter} )
             )
     )
}

But it aint show anyhting :(


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

Date: Mon, 25 Apr 2005 23:26:48 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: loading a lot of values into an mysql database and looping
Message-Id: <426d609e$0$812$8fcfb975@news.wanadoo.fr>

Nikos wrote:

> Actually now is changed to:
> 
> $db->do( "create table   games( onoma text, description text, counter 
> int )" ) or die $!;
> 
You still aren't partitioning your problem.

> 
> #=============================================================================== 
> 
> 
> my %descriptions;
> open( my $desc, "</data/games/perigrafes.txt" ) or die $!;
> 
> while(<$desc>) {
>         chomp;
>         my( $name, $description ) = split(/\t/);
>         $descriptions{$name} = $description;
> }
> 
> my $st = $db->prepare( "INSERT INTO games VALUES (?, ?, ?)" );
> 
> my @games = </data/games/*.rar> or die $!;
> 
Does @games contain what you think it contains at this stage? Have you 
checked?

> while (@games) {
>         $st->execute( $_, $descriptions{$_}, 0 );
> }

This will only ever complete if @games is empty....
How many elements does @games contain? Have you tried Data::Dumper?
Do you check the return value of $st->execute()?


Following this, what is in the database table? Have you used the mysql 
console to execute

select * from games;

Until you verify that the data is as you expect, then there is little 
point in worrying about the next step....

> #=============================================================================== 
> 
> 
> 
> And here si the code that tries to displays those database table values 
> in a esy appelaing way:
> 
> my $row;
> while ( $row = $st->fetchrow_hashref ) {
> 
>     print table( {class=>'info'},
>           Tr(
>              td( submit( -name=>'game', -value=>$_->{name} )),
>              td( $_->{description} ),
>              td( $_->{counter} )
>             )
>     )
> }
This is going to give you a separate table for each row.

Mark


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

Date: Mon, 25 Apr 2005 16:24:46 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: loading a lot of values into an mysql database and looping
Message-Id: <slrnd6qo0u.ruu.tadmc@magna.augustmail.com>

Nikos <hackeras@gmail.com> wrote:
> xhoster@gmail.com wrote:


You snipped everything that Xho wrote.

he said that this:

>> Nikos <hackeras@gmail.com> wrote:
>> 
>>>while (@games) {
>>>         $st->execute( $_, $_, 0 );
>>>}


looked like an infinite loop.


> while (@games) {
>          $st->execute( $_, $descriptions{$_}, 0 );
> }


And it *still* looks like an infinite loop.

This is precisely why some folks have given up on helping you,
a problem was pointed out to you, but you didn't fix it.

We get the feeling that you are not listening to followups,
so there isn't much point it spending time composing
a followup.

Fix your infinite loop.


> my $row;
> while ( $row = $st->fetchrow_hashref ) {
> 
>      print table( {class=>'info'},
>            Tr(
>               td( submit( -name=>'game', -value=>$_->{name} )),
>               td( $_->{description} ),
>               td( $_->{counter} )
>              )
>      )
> }
> 
> But it aint show anyhting :(


Look at the name of the hashref variable.

Look at the name of the variable that you are using as if it
was a hashref.

Do they look like the same variable?


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


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

Date: Sat, 23 Apr 2005 10:29:23 +0300
From: Nikos <hackeras@gmail.com>
Subject: Looping (continued)
Message-Id: <d4ctgk$31j$1@nic.grnet.gr>

Hello i still cant make this work:

$st = $db->prepare( "SELECT * FROM counter" );
$st->execute();

my @tableRows;
while ( my $row = $st->fetchrow_hashref() ) {
    push @tableRows, $row;
}

print table( {class=>'info'},
       map {
            Tr(
               td( submit( -name=>'game', -value=>$_->{name} )),
               td( $_->{text} ),
               td( $_->{name} )
               )
            } @tableRows
);

I only got 1 row with 3 fileds one having a button saying game and 
beside it 2 empty cells instead of the big game list i was producing 
with the print statements before i turn it to loop.


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

Date: Sat, 23 Apr 2005 13:18:39 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Looping (continued)
Message-Id: <d4d7e0$ca3$1@nic.grnet.gr>

Nikos wrote:
Please can someone make this work?

#!/usr/bin/perl -w
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use DBI;
use DBD::mysql;

my @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 
'Sep', 'Oct', 'Nov', 'Dec');
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;
my $xronos = "$mday $months[$mon], $hour:$min";

my $game = param('game');

my $ip = $ENV{'REMOTE_ADDR'};
my @numbers = split (/\./,$ip);
my $address = pack ("C4", @numbers);
my $host = gethostbyaddr ($address, 2) || $ip;

print header( -charset=>'iso-8859-7' );
print start_html( -style=>'../style.css', -title=>'Ðáé÷íéäÜêéá êáé ü÷é 
ìüíï!', -background=>'../data/images/night.gif' );


my $db = ($ENV{'SERVER_NAME'} ne 'nikolas.50free.net')
        ? DBI->connect('DBI:mysql:nikos_db', 'root', '')
        : DBI->connect('DBI:mysql:nikos_db:50free.net', 'nikos_db', 
'tiabhp2r')
        or print font({-size=>5, -color=>'Lime'}, $DBI::errstr) and exit 0;

print p( font( {-size=>4, -color=>'Lime'},  "Áðü åäþ ìðïñåßò íá 
êáôåâÜóåéò ðáé÷íßäéá üðùò åðßóçò êáé äéêÜ ìïõ ðñïãñÜììáôá:<br>" ),
                           font( {-size=>4, -color=>'Lime'},  "ÃñÜøå ìïõ 
ôéò åíôõðþóåéò óïõ óôï "),
                           font( {-size=>4, -color=>'White'}, 
"nik0s\@mycosmos.gr<br><br>" ));

print start_form(-action=>'games.pl');

my $st = $db->prepare( "SELECT * FROM counter" );
$st->execute();

my @tableRows;
while ( my $row = $st->fetchrow_hashref() ) {
    push @tableRows, $row;
}

print table( {class=>'info'},
       map {
            Tr(
               td( submit( -name=>'game', -value=>$_->{name} )),
               td( $_->{text} ),
               td( $_->{name} )
               )
            } @tableRows
);

print '<br>';

if ( !param() ) { print p(  a( {href=>'index.pl'},  img 
{src=>'../data/images/back.gif'} )); }


if ( param() )
{
    $db->do( "UPDATE counter SET $game = $game + 1" );
    $st = $db->prepare( "SELECT $game FROM counter" );
    $st->execute();
    $row = $st->fetchrow_hashref;

    print p(  font( {-size=>4, -color=>'Yellow'},  "Åßóáé ï " ),
                                  font( {-size=>4, -color=>'White'}, 
"$row->{$game}" ),
                                  font( {-size=>4, -color=>'Yellow'}, 
"ïò ðïõ êáôåâÜæåé ôï " ),
                                  font( {-size=>4, -color=>'White'}, 
"$game!<br>" ),
                                  font( {-size=>4, -color=>'Yellow'}, 
"Åëðßæù íá óïõ áñÝóåé êáé íá óïõ öáíåß ÷ñÞóéìï!" ));

    $db->do( "UPDATE logs SET keimeno='$game' WHERE host='$host'" ) or 
die $db->errstr;

    print p(  a( {href=>'index.pl'},  img 
{src=>'../data/images/back.gif'} ));
    print "<script 
language='Javascript'>location.href='../data/games/$game.rar'</script>";
}

Iam getting thsi when i try to run it:

Global symbol "$sec" requires explicit package name at D:\www\cgi-bin\
+games.pl line 9.
Global symbol "$min" requires explicit package name at D:\www\cgi-bin\
+games.pl line 9.
Global symbol "$hour" requires explicit package name at D:\www\cgi-bin
+\games.pl line 9.
Global symbol "$mday" requires explicit package name at D:\www\cgi-bin
+\games.pl line 9.
Global symbol "$mon" requires explicit package name at D:\www\cgi-bin\
+games.pl line 9.
Global symbol "$year" requires explicit package name at D:\www\cgi-bin
+\games.pl line 9.
Global symbol "$wday" requires explicit package name at D:\www\cgi-bin
+\games.pl line 9.
Global symbol "$yday" requires explicit package name at D:\www\cgi-bin
+\games.pl line 9.
Global symbol "$isdst" requires explicit package name at D:\www\cgi-bi
+n\games.pl line 9.
Global symbol "$mday" requires explicit package name at D:\www\cgi-bin
+\games.pl line 10.
Global symbol "$mon" requires explicit package name at D:\www\cgi-bin\
+games.pl line 10.
Global symbol "$hour" requires explicit package name at D:\www\cgi-bin
+\games.pl line 10.
Global symbol "$min" requires explicit package name at D:\www\cgi-bin\
+games.pl line 10.
Global symbol "$row" requires explicit package name at D:\www\cgi-bin\
+games.pl line 62.
Global symbol "$row" requires explicit package name at D:\www\cgi-bin\
+games.pl line 65.
Execution of D:\www\cgi-bin\games.pl aborted due to compilation errors


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

Date: Sat, 23 Apr 2005 12:37:12 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Looping (continued)
Message-Id: <426a2553$0$11706$8fcfb975@news.wanadoo.fr>

Nikos wrote:
> Hello i still cant make this work:
> 
> $st = $db->prepare( "SELECT * FROM counter" );
> $st->execute();
> 
> my @tableRows;
> while ( my $row = $st->fetchrow_hashref() ) {
>    push @tableRows, $row;
> }
> 
> print table( {class=>'info'},
>       map {
>            Tr(
>               td( submit( -name=>'game', -value=>$_->{name} )),
>               td( $_->{text} ),
>               td( $_->{name} )
>               )
>            } @tableRows
> );
> 
> I only got 1 row with 3 fileds one having a button saying game and 
> beside it 2 empty cells instead of the big game list i was producing 
> with the print statements before i turn it to loop.
I've said this before: it looks like I will have to say it again. *What* 
is in @tableRows following the while loop that populates it? As I have 
also said before, you can use Data::Dumper to examine the contents of 
data structures.

use Data::Dumper;

 ....

warn Dumper \@tableRows;

will dump the contents of @tableRows to the console if you run the 
script from the command line.

Sigh.

Mark


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

Date: Sat, 23 Apr 2005 12:41:06 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Looping (continued)
Message-Id: <426a263c$0$847$8fcfb975@news.wanadoo.fr>

Nikos wrote:
> Nikos wrote:
> Please can someone make this work?
<snip>

No. We don't have access to your environment. You have to learn to debug 
your own programs.

> ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;
<snip>

> Global symbol "$sec" requires explicit package name at D:\www\cgi-bin\
> +games.pl line 9.
<snip error messages on this theme>
As the documentation for strict

perldoc strict

states, your variables need to be declared before use, typically with my.

Is any of this getting through?

Mark


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

Date: Sat, 23 Apr 2005 09:03:52 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Looping (continued)
Message-Id: <slrnd6kle8.8g4.tadmc@magna.augustmail.com>

Nikos <hackeras@gmail.com> wrote:

> Please can someone make this work?


Please post your job offers in a newsgroup for job offers, or
advertise on the perl-jobs mailing list.


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


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

Date: Sun, 24 Apr 2005 21:16:47 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Looping (continued)
Message-Id: <76idnWrTgNSo8vHfRVn-vg@comcast.com>

Nikos wrote:

> my @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 
> 'Sep', 'Oct', 'Nov', 'Dec');

It appears that you are using an out-of-date book for a reference.

   my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);

> ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;

The fix for that line is to simply add two characters to it.

	-Joe


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

Date: Sat, 23 Apr 2005 10:12:36 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Looping almost the same repetitive lines
Message-Id: <d4csh5$25t$1@nic.grnet.gr>

Tad McClellan wrote:

> 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.

OK. I will put those 2 lines in front of every script of mine.
Actually it was the *use script* i didnt so far working with cause i had 
the use warning not as use but in the very first statement of
#!/usr/bin/perl -w  so i was actually using it :-)

but *i will* use sctrict as well.

I have no intension to be disrespectfull or estimate myself higher than 
all of you by any means. After all its *I* that ask questions i cant 
make the simpelst program work.

Please dont consider it this way.
Its just that if i dont understand exactly why i am using something i 
dont use because it confuses me.

But i will do as i been told.


> 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...

No, no at all but i was wondering why use my since in my scripts i only 
work with global variables and dont even have one single function?

And except that i am using variables at least 2 times. One at 
definition/initialization time and one in calcualation or print time.

But again, i will comply.


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

Date: 23 Apr 2005 16:21:49 GMT
From: DAVISM@ecr6.ohio-state.edu (Michael T. Davis)
Subject: Re: Matching mixed up words
Message-Id: <d4dsmt$fms$1@charm.magnus.acs.ohio-state.edu>


In article <3ctartF6p4jr0U1@individual.net>, Fabian Pilkowski
<pilkowsk@informatik.uni-marburg.de> writes:

>* 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')}).*$|(?!))

	I made the mistake of over-generalizing the test string.  Thanks for
pointing out my obvious idiocy. (;-)

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

	Point taken.
>
>>
>> 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.

	Yes, I believe you've hit the nail on the head.
>
>regards,
>fabian

Much obliged,
Mike
--
                                         |    Systems Specialist: CBE,MSE
             Michael T. Davis            | Departmental Networking/Computing
 http://www.ecr6.ohio-state.edu/~davism/ |     The Ohio State University
                                         |     197 Watts, (614) 292-6928


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

Date: Mon, 25 Apr 2005 21:45:27 +0200
From: Alexandre Jaquet <alexj@freesurf.ch>
Subject: mod_perl 2 / apache 2 under windows
Message-Id: <426d48d8$0$1161$5402220f@news.sunrise.ch>

Hi,

I'm trying to setup @ home mod_perl 2 / apache under windows (I know 
that's not the best ..)  And got some trouble.

After reading the docs about setting up my env,  :

http://perl.apache.org/docs/2.0/os/win32/config.html

ppm install ... mod_perl2..

I've tryed to use a startup.pl script :

use ModPerl::Util ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::RequestUtil ();
use Apache2::ServerRec ();
use Apache2::ServerUtil ();
use Apache2::Connection ();
use Apache2::Log ();
use Apache2::Const -compile => ':common';
use APR::Const -compile => ':common';
use APR::Table ();
use Apache2::compat ();
use ModPerl::Registry ();
use CGI ();
  1;

An compile error came with APR module I didn't find where I can get it  :'(

thxs in advance


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

Date: Mon, 25 Apr 2005 22:00:37 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: mod_perl 2 / apache 2 under windows
Message-Id: <3d50mhF6qj9r2U1@individual.net>

Alexandre Jaquet wrote:
> I'm trying to setup @ home mod_perl 2 / apache under windows (I know 
> that's not the best ..)  And got some trouble.

For a really convenient way to get Apache incl. mod_perl on Windows:

     http://www.indigostar.com/indigoperl.htm

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sun, 24 Apr 2005 22:05:12 GMT
From: daveindallasNOSPAM@comcast.nut (Dave in Dallas)
Subject: NEWS: Have a miscarriage, get a tax deduction
Message-Id: <426c17eb.26371390@decaxp.HARVARD.EDU>

From
http://www.washingtonpost.com/wp-dyn/articles/A10411-2005Apr22.html

> The Bush administration issued guidelines yesterday advising
> physicians and hospitals that under a 2002 law they are obligated to
> care for fetuses "born alive" naturally or in the process of an
> abortion, and medical providers could face penalties for withholding
> treatment.
> 
> The law, signed by President Bush nearly three years ago, conferred
> legal rights on fetuses "at any stage of development." It specifies
> that a fetus that is breathing, has a beating heart, a pulsating
> umbilical cord or muscle movement should be considered alive and
> entitled to protection under federal emergency medical laws and child
> abuse statutes.
> 
> Several physicians interviewed yesterday said that definition appeared
> overly broad, as muscle twitching can occur after death.
> 
> Initially, the Department of Health and Human Services did not see the
> need to issue guidance on the Born-Alive Infants Protection Act. But
> shortly after his confirmation in January, Health and Human Services
> Secretary Mike Leavitt said he "received several inquiries on whether"
> the department was planning to develop regulations.
>
> ...
> 
> Leavitt's aides refused to say who made the inquiries or whether the
> government had received any complaints of abuse or neglect involving a
> just-born or aborted fetus.

It wouldn't surprise me if the RTL crowd was behind the inquiries and
that either no complaints were involved or if they were that they were
unfounded claims made by the RTL nuts.

The article ends with the following bit of information:

> The most significant impact of the 2002 law, Grimes said, was a
> record-keeping change. Previously, a miscarriage before viability was
> classified as a spontaneous abortion. Under the new provision, it is
> recorded as a live birth followed by a neonatal death, and parents can
> claim the child as a tax deduction for that year, he said.

Only the RTL nutjobs could imagine classifying a miscarriage as a live
birth.  I wonder if this would qualify every woman who miscarries even
the tiniest embryo to claim a child deduction.  After all, that little
blob, that may very likely go unnoticed, is a living human who just
happens to die the moment it emerges from the womb.

I wonder what the reaction would be if women began showing up at the
hospital with little blod clots, demanding that it be examined to
determine whether it is indeed a miscarriage, and if so to demand that
the proper paperwork (does this involve issuance of both a birth and
death certificate?) be completed so she can claim a deduction for Lil'
Blastocyst on her taxes.


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

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


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