[25828] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8065 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 10 14:05:46 2005

Date: Tue, 10 May 2005 11:05:08 -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           Tue, 10 May 2005     Volume: 10 Number: 8065

Today's topics:
    Re: Help, a problem with yesterdays date. (Anno Siegel)
    Re: How to do this? Form fill problem (Moozie)
        Howto install DBD-mysql on Mac OS X - Solution <news@chaos-net.de>
    Re: Inserting & Updating from txtx to a database! axel@white-eagle.co.uk
    Re: Inserting & Updating from txtx to a database! <hackeras@gmail.com>
    Re: Inserting & Updating from txtx to a database! xhoster@gmail.com
    Re: Inserting & Updating from txtx to a database! axel@white-eagle.co.uk
    Re: Inserting & Updating from txtx to a database! <glex_nospam@qwest.invalid>
    Re: Media Lending Library - web based application <tadmc@augustmail.com>
    Re: Media Lending Library - web based application <tadmc@augustmail.com>
    Re: using grep and diff <apeiron+usenet@coitusmentis.info>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 May 2005 10:13:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help, a problem with yesterdays date.
Message-Id: <d5q1gm$lmh$5@mamenchi.zrz.TU-Berlin.DE>

Joe Smith  <joe@inwap.com> wrote in comp.lang.perl.misc:
> jbl wrote:
> 
> > sub formatDayofMonth {
> >     my $val = $_[0];
> >     if( $val > 31 ) {
> >         return 0;
> >     }
> >     return (qw(01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 
> >                 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31))[$val];
> > }
> 
> Since $_=formatDayofMonth(1) results in $_='02', I'd say that you've
> given your function the wrong name.  Compare with these:
> 
> sub nextDayofMonth {
>    my $val = shift;
>    return (qw(** 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16
>           17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 01))[$val];
> }

    sub nextDayofMonth { sprintf '%02d', 1 + shift() % 31 }

Similar for previousDayofMonth.

Anno


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

Date: 10 May 2005 05:09:14 -0700
From: nospam@dse.nl (Moozie)
Subject: Re: How to do this? Form fill problem
Message-Id: <e8b6156c.0505100409.61fcb79@posting.google.com>

THANKS TOU YOU I SOLVED IT.

CLOSED


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

Date: Tue, 10 May 2005 16:19:27 +0200
From: Martin Kissner <news@chaos-net.de>
Subject: Howto install DBD-mysql on Mac OS X - Solution
Message-Id: <slrnd81gnf.86.news@maki.homeunix.net>

Hello together,

this time I am not going txpo post a Question but a solution to a - as
far as I know common - problem.

Installation of DBD-mysql has been a problem on Mac OS X 10.3 and still
is on Mac OS X 10.4.

As far as I have experienced at least one problem is that mysql_config
does not provide correct settings for cflags and libs directories, which
actually is an error of mysql and not of Perl.
It can be solved by editing "/usr/local/mysql/bin/mysql_config" and
changing the following lines:

	pkglibdir='/usr/local/mysql/lib/mysql'
to
	pkglibdir='/usr/local/mysql/lib/'
and
	pkgincludedir='/usr/local/mysql/include/mysql'
to
	pkgincludedir='/usr/local/mysql/include/'

It is also possible to leave mysql_config alone and to call "perl
Makefile.PL" as follows (all in one line and with a space before the
second and thid line), but I prefere the first method:

	perl Makefile.PL --cflags="-I/usr/local/mysql/include/
-fno-omit-frame-pointer" --libs="-L/usr/local/mysql/lib/ -lmysqlclient
-lz -lm"

I have tested both methods on Mac OS X 10.4 and hope that this will be
useful to others.

Best 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: Tue, 10 May 2005 13:15:21 GMT
From: axel@white-eagle.co.uk
Subject: Re: Inserting & Updating from txtx to a database!
Message-Id: <Jt2ge.7498$Jc5.2109@fe1.news.blueyonder.co.uk>

Nikos <hackeras@gmail.com> wrote:
> This is the best i can do with my games.pl script to load the game, 
> description and times downloaded from a .txt file to database.
 
> Can you suggest something better?
 
> 
> 
> my $dbh = DBI->connect('DBI:mysql:nikos_db', 'root', 'tiabhp2r') or 
> {RaiseError=>1};
> 
> #===============================================================================
> 
> my @row;
> my $insert = $dbh->prepare( "INSERT INTO games (gamename, gamedesc, 
> gamecounter) VALUES (?, ?, ?)" );
> my $update = $dbh->prepare( "UPDATE games SET gamedesc=? where 
> gamename=?" );
> 
> open (FILE, "<../data/games/descriptions.txt") or die $!;
>     while (<FILE>) {
>         chomp;
> 
>         my ($gamename, $gamedesc) = split /\t/;
>         $insert->execute( $gamename, $gamedesc, 0 );
>         if ($DBI::err)
>         {
>             print "Error on INSERT $gamename: $DBI::errstr\n";
>             $update->execute( $gamedesc, $gamename );

Huh... you have an error and then immediately attempt to carry out an
UPDATE? 

What effect do you think that is going to have?

Axel




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

Date: Tue, 10 May 2005 16:18:18 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Inserting & Updating from txtx to a database!
Message-Id: <d5qcap$947$2@nic.grnet.gr>

axel@white-eagle.co.uk wrote:
> Nikos <hackeras@gmail.com> wrote:
> 
>>This is the best i can do with my games.pl script to load the game, 
>>description and times downloaded from a .txt file to database.
> 
>  
> 
>>Can you suggest something better?
> 
>  
> 
>>
>>my $dbh = DBI->connect('DBI:mysql:nikos_db', 'root', 'tiabhp2r') or 
>>{RaiseError=>1};
>>
>>#===============================================================================
>>
>>my @row;
>>my $insert = $dbh->prepare( "INSERT INTO games (gamename, gamedesc, 
>>gamecounter) VALUES (?, ?, ?)" );
>>my $update = $dbh->prepare( "UPDATE games SET gamedesc=? where 
>>gamename=?" );
>>
>>open (FILE, "<../data/games/descriptions.txt") or die $!;
>>    while (<FILE>) {
>>        chomp;
>>
>>        my ($gamename, $gamedesc) = split /\t/;
>>        $insert->execute( $gamename, $gamedesc, 0 );
>>        if ($DBI::err)
>>        {
>>            print "Error on INSERT $gamename: $DBI::errstr\n";
>>            $update->execute( $gamedesc, $gamename );
> 
> 
> Huh... you have an error and then immediately attempt to carry out an
> UPDATE? 
> 
> What effect do you think that is going to have?
> 
> Axel
> 
> 

I just need some way to update the mysql table if a gamename exists in 
the mayswl table games or insert a new one if it does not.



-- 
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."


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

Date: 10 May 2005 14:14:37 GMT
From: xhoster@gmail.com
Subject: Re: Inserting & Updating from txtx to a database!
Message-Id: <20050510101437.086$Qp@newsreader.com>

axel@white-eagle.co.uk wrote:
> Nikos <hackeras@gmail.com> wrote:
> >         my ($gamename, $gamedesc) = split /\t/;
> >         $insert->execute( $gamename, $gamedesc, 0 );
> >         if ($DBI::err)
> >         {
> >             print "Error on INSERT $gamename: $DBI::errstr\n";
> >             $update->execute( $gamedesc, $gamename );
>
> Huh... you have an error and then immediately attempt to carry out an
> UPDATE?
>
> What effect do you think that is going to have?

I think it would have the effect of doing update instead of inserting when
attempting to insert gives a unique key violation.  Of course, I'd also
match the error string to a regex to make sure it was a unique key
violation rather than just assuming that it is.

Xho

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


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

Date: Tue, 10 May 2005 15:31:15 GMT
From: axel@white-eagle.co.uk
Subject: Re: Inserting & Updating from txtx to a database!
Message-Id: <7t4ge.8161$Jc5.2087@fe1.news.blueyonder.co.uk>

xhoster@gmail.com wrote:
> axel@white-eagle.co.uk wrote:
>> Nikos <hackeras@gmail.com> wrote:
>> >         my ($gamename, $gamedesc) = split /\t/;
>> >         $insert->execute( $gamename, $gamedesc, 0 );
>> >         if ($DBI::err)
>> >         {
>> >             print "Error on INSERT $gamename: $DBI::errstr\n";
>> >             $update->execute( $gamedesc, $gamename );
>>
>> Huh... you have an error and then immediately attempt to carry out an
>> UPDATE?
>>
>> What effect do you think that is going to have?
 
> I think it would have the effect of doing update instead of inserting when
> attempting to insert gives a unique key violation.  Of course, I'd also
> match the error string to a regex to make sure it was a unique key
> violation rather than just assuming that it is.

Yes, on both counts.

Although, why do I suspect that there is no unique key in the table
definition?

Still it is neither a Perl nor my problem.

Axel
 


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

Date: Tue, 10 May 2005 10:56:13 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Inserting & Updating from txtx to a database!
Message-Id: <xQ4ge.14$Xo3.628@news.uswest.net>

Nikos wrote:

> I just need some way to update the mysql table if a gamename exists in 
> the mayswl table games or insert a new one if it does not.

I know this involves reading and nothing to do with perl, however look 
at the MySQL documentation for "replace".


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

Date: Tue, 10 May 2005 07:41:04 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Media Lending Library - web based application
Message-Id: <slrnd81av0.a5a.tadmc@magna.augustmail.com>

Michael De Tomaso <mdetomaso@bak.rr.com> wrote:

> Q: I'm looking for a PHP-MySQL web solution


Errr, but this is the *Perl* newsgroup.

People who make off-topic postings risk getting killfiled.


> --


People who persist in posting with a broken sig-dash after being
asked to repair it risk getting killfiled.


> thanks & take care M.D.
> 
><aka>
>     _                                _
>    | |_   ___    _ __ ___     __ _  | |_   ___     ___
>    | __| / _ \  | '_ ` _ \   / _` | | __| / _ \   / _ \
>    | |_ | (_) | | | | | | | | (_| | | |_ | (_) | |  __/
>     \__| \___/  |_| |_| |_|  \__,_|  \__| \___/   \___|
> 
>          ( .) ( .)         (o ) (o )
>   You say tomato and I say tomatoe, Let's call the whole thing off


People who persist in posting a ten-line .sig after being
asked to repair it risk getting killfiled.

So long!


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


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

Date: Tue, 10 May 2005 08:39:24 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Media Lending Library - web based application
Message-Id: <slrnd81ecc.adm.tadmc@magna.augustmail.com>

Michael De Tomaso <mdetomaso@bak.rr.com> wrote:
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message 
> news:Xns9651BABE24FA5asu1cornelledu@127.0.0.1...
>> "Michael De Tomaso" <mdetomaso@bak.rr.com> wrote in
>> news:cDQfe.32883$Au1.27491@tornado.socal.rr.com:
>>
>>> -----
>>> --
>>
>> You are still not using the correct sig delimiter that would allow my
>> newsreader to automatically snip your gaudy signature. The proper sig
>> delimiter consists of tow dashes followed by a space.
>>
>>>   You say tomato and I say tomatoe, Let's call the whole thing off


This is NOT an issue of personal preference.

It is an issue of what is seen as Good Manners on Usenet.


>> -- 
>> A. Sinan Unur <1usa@llenroc.ude.invalid>
>> (reverse each component and remove .invalid for email address)
>>
>> comp.lang.perl.misc guidelines on the WWW:
>> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
> 
> ... snip your gaudy signature


Pardon me, but your ignorance is showing.

One new person is not likely to be successful in mandating
How It Should Be to hundreds of regulars.

Post as accepted netiquette dictates or become ostracized, your choice.



Have you seen the Posting Guidelines mentioned in that .sig?

It was included there for your benefit, but you cannot realize
that benefit if you do not follow the link.

It has a link for info on standard netiquette:

   http://andrew2.andrew.cmu.edu/rfc/rfc1855.html

Wherein it says:

    - If you include a signature keep it short.  Rule of thumb
      is no longer than 4 lines.  Remember that many people pay for
      connectivity by the minute, and the longer your message is,
      the more they pay.

So ASU's .sig had an extra blank line in it, that's all.


> Believe it or not, beauty is in the eye of the beholder, 


We are not discussing an issue of beauty, we are discussing
what is socially acceptable on Usenet.

(neither broken sig-dashes nor long .sigs are acceptable.)


> so please try to 
> find another part of the elephant quickly before the heard comes ...


so please try to do it the way everybody else does before all of
your questions become unheard by the heard (sic).


> Then again, perhaps your newsread sig delimiter need tweaking maestro,


There *is no* sig in your posts.

The sig-dash *defines* a sig, and since you don't have a sig-dash
you don't have a (proper) sig.

(putting a sig-like thingy in the body is not acceptable either)

You don't modify the program to deal with broken data, you simply
repair the data.


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


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

Date: 10 May 2005 16:09:31 GMT
From: Christopher Nehren <apeiron+usenet@coitusmentis.info>
Subject: Re: using grep and diff
Message-Id: <slrnd81n5r.15nh.apeiron+usenet@prophecy.dyndns.org>

On 2005-05-09, Chris scribbled these
curious markings:
> use Shell("grep", "diff");
> my $item=diff("file1 file2","");
> my $other=grep($item,""^[0-9]"");

Wow ... shelling out to do text processing in Perl! Seriously. Get some
modules and learn about Perl's regex engine (which is infinitely better
than anything your grep can ever provide, by the way[1]) and the
Algorithm::Diff module.

[1]: Unless it was written in Perl, of course ...
http://search.cpan.org/src/CWEST/ppt-0.14/bin/grep

Best Regards,
Christopher Nehren
-- 
I abhor a system designed for the "user", if that word is a coded
pejorative meaning "stupid and unsophisticated". -- Ken Thompson
If you ask the wrong questions, you get answers like "42" and "God".
Unix is user friendly. However, it isn't idiot friendly.


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

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


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