[25803] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8042 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 2 18:05:42 2005

Date: Mon, 2 May 2005 15:05: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           Mon, 2 May 2005     Volume: 10 Number: 8042

Today's topics:
    Re: feeding a value to a js file from a perl one burlo.stumproot@gmail.com
        loading values from txt to database <hackeras@gmail.com>
    Re: loading values from txt to database <jgibson@mail.arc.nasa.gov>
    Re: loading values from txt to database <hackeras@gmail.com>
    Re: loading values from txt to database <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: Multiple Inheritance: mixed base class refs (hash,  <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: Somethign about hashes <matternc@comcast.net>
    Re: Somethign about hashes <hackeras@gmail.com>
    Re: Somethign about hashes <tintin@invalid.invalid>
    Re: Somethign about hashes <hackeras@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 02 May 2005 20:52:27 GMT
From: burlo.stumproot@gmail.com
Subject: Re: feeding a value to a js file from a perl one
Message-Id: <upsw9mjug.fsf@gmail.com>

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

> Nikos wrote:
> > Thanks Mark but i think i will give up on programming too.
> You shouldn't be too disheartened: you have been trying to run before
> you could walk, although you don't seem to have realised this. Start
> with the basics and build up.
> 
> > I like Perl and i know some basic stuff but actually i cant put much
> > effort on reading.
> This is unfortunate: reading is the key to education, in pretty much
> any discipline.
> 
> > I liek things to be be pretty much self-explanatory.
> Programming isn't easy: you shouldn't expect everything to magically
> fall into place without understanding the whys and wherefores. If it
> were easy, then it wouldn't attract people who like to be challenged,
> and who like making difficult things work, and just as importantly, it
> wouldn't pay. New languages only become self-explanatory (up to a
> point) when you are already familiar with a variety of languages. This
> takes time.
> 
> > Anyway thank you for tryign to help me and sorry for the annoyance i
> > caused.
> The annoyance (despair?) was caused by you expecting too much from the
> readers of this newsgroup, and moreover by you refusing to listen to
> them. Being a beginner is not a problem (it can take years to reach
> proficiency): being a beginner who doesn't want to listen *is*.
> 
> anyway, best of luck,
> 
> Mark

Very well said Mark.


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

Date: Mon, 02 May 2005 21:13:27 +0300
From: Nikos <hackeras@gmail.com>
Subject: loading values from txt to database
Message-Id: <d55qk2$s50$1@nic.grnet.gr>

I have this code to load the name of the games, descriptions and how 
many times a game was downloaded.
problem is that if i change the description file, by for example  adding 
more games or editing existing ones this snippet will have to rerun form 
games.pl thts is inside.

Can i do something that even if i cahnge the descriptions.txt file i 
wont have to initialize all this evry tiem games.pl is loading and the 
gamecounetr not to be lost?

Thank you and here si the snippet:

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

my @row;
$sth = $dbh->prepare( 'INSERT INTO games (gamename, gamedesc, 
gamecounter) VALUES (?, ?, ?)' );

open (FILE, "<../data/games/descriptions.txt") or die $!;
     while (<FILE>) {
         chomp;

         @row = split /\t/;
         push @row, 0;

         $sth->execute( @row );
     }
close (FILE);

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


-- 
"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: Mon, 02 May 2005 12:10:24 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: loading values from txt to database
Message-Id: <020520051210244823%jgibson@mail.arc.nasa.gov>

In article <d55qk2$s50$1@nic.grnet.gr>, Nikos <hackeras@gmail.com>
wrote:

> I have this code to load the name of the games, descriptions and how 
> many times a game was downloaded.
> problem is that if i change the description file, by for example  adding 
> more games or editing existing ones this snippet will have to rerun form 
> games.pl thts is inside.
> 
> Can i do something that even if i cahnge the descriptions.txt file i 
> wont have to initialize all this evry tiem games.pl is loading and the 
> gamecounetr not to be lost?
> 
> Thank you and here si the snippet:
> 
>
> #=============================================================================
> ==
> 
> my @row;
> $sth = $dbh->prepare( 'INSERT INTO games (gamename, gamedesc, 
> gamecounter) VALUES (?, ?, ?)' );
> 
> open (FILE, "<../data/games/descriptions.txt") or die $!;
>      while (<FILE>) {
>          chomp;
> 
>          @row = split /\t/;
>          push @row, 0;
> 
>          $sth->execute( @row );
>      }
> close (FILE);
> 
> #===============================================================================

This is basically an SQL question, although you will want to implement
it in Perl. Instead of just loading the contents of your
descriptions.txt file into your database blindly, you need to first
query your database and see if the game in the descriptions file
already exists in the database. If it does, do not insert it. If it
does not, insert it with a zero count. 

Another, perhaps simpler approach, would be to query the database and
fetch and save all of the counts. Then load the descriptions file into
the database including the counts as part of your insert. This approach
would have the benefit of updating the descriptions column if it had
changed.

The exact SQL (DBI) statements to accomplish either of the above is
left as an exercise.

Good luck.


----== 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: Mon, 02 May 2005 22:18:03 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: loading values from txt to database
Message-Id: <d55ud8$1th$1@nic.grnet.gr>

Jim Gibson wrote:

{instructions]

> The exact SQL (DBI) statements to accomplish either of the above is
> left as an exercise.
> 
> Good luck.

Thanks, iam workign on it.
I likes the 2nd approach better.

-- 
"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: Mon, 02 May 2005 21:37:04 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: loading values from txt to database
Message-Id: <4276815d$0$844$8fcfb975@news.wanadoo.fr>

Nikos wrote:
> I have this code to load the name of the games, descriptions and how 
> many times a game was downloaded.
> problem is that if i change the description file, by for example  adding 
> more games or editing existing ones this snippet will have to rerun form 
> games.pl thts is inside.
> 
> Can i do something that even if i cahnge the descriptions.txt file i 
> wont have to initialize all this evry tiem games.pl is loading and the 
> gamecounetr not to be lost?
Er - how about keeping the game descriptions directly in the database 
and not bothering with descriptions.txt. You could mount it via ODBC and 
enter the data using eg Access. This is *not* the place to ask how to do 
this, but I guess you will ignore that I have said that.

> 
> Thank you and here si the snippet:
> 
> #=============================================================================== 
> 



> my @row;
> $sth = $dbh->prepare( 'INSERT INTO games (gamename, gamedesc, 
> gamecounter) VALUES (?, ?, ?)' );

This is more of a MySQL question, but as per usual you have no interest 
in posting questions to the correct newsgroup. As I've stated before 
(you chose, yet again, not to listen), you don't need to bind all three 
column values since one of them is invariant. I would tell you to read 
the MySQL documentation for "replace", but you won't because you are too 
rude to do any reading for yourself. Shame!

> 
> open (FILE, "<../data/games/descriptions.txt") or die $!;
>     while (<FILE>) {
>         chomp;
> 
>         @row = split /\t/;
>         push @row, 0;
> 
>         $sth->execute( @row );
>     }
> close (FILE);
> 
> #=============================================================================== 
> 
> 
> 


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

Date: Mon, 02 May 2005 21:04:18 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Multiple Inheritance: mixed base class refs (hash, array)
Message-Id: <427679af$0$1253$8fcfb975@news.wanadoo.fr>

Alfred Z. Newmane wrote:
> Mark Clements wrote:

>>This doesn't really work for multiple inheritance though.
>>
>>With composition, your class isn't a subclass, but contains references
>>to the other classes.
>>
>>
>>sub new {
>>my $class = shift;
>>my $argsForEvent = shift;
>>my $argsForSelect = shift;
>>
>>my $self = {
>>_event => MyEvent->new( @$argsForEvent ),
>>_select => IO::Select->new( @$argsForSelect ) ,
>>};
>>
>>return bless $self,$class;
>>}
> 
> 
> Yes I could of done it this way. but I was really wondering if it would 
> be possible to accomplish this with inheritance, some how combine the 
> two base classes into one big class. Would it be possible to "convert" 
> (for lack of a better term) the "pseudo-hashes" returned by IO::Select 
> into a more standard HASH (ref), *without* compromising the IO::Select 
> class itself (meaning, can the values be fed into the $obj hashref and 
> then still be able to use an inherited subs of IO::Select?)
> 
Multiple inheritance raises all sorts of questions in OO programming. In 
fact, some languages forbid it. (They aren't pseudo-hashes by the way, I 
  was wrong. See Tassilo's post). There is no advantage to be gained by 
trying to convert the blessed arrayref returned by IO::Select's 
constructor into something else, in fact one of the points of OO 
programming (encapsulation) is that the underlying implentation of an 
object is hidden and unimportant as regards the functionality of a 
class. Classes can (and should, in a lot of cases), be treated as 
black-boxes.

As I've said, you can't create a class that inherits from both parent 
classes transparently because the constructors will clash. If you really 
do need inheritance from both classes (composition is much more 
straightforwrd to implement), then you will need to override the 
constructor methods (breaking the interface from a functional 
perspective ) so that you can pass both sets of arguments in.
I don't know how you'd reconcile the need to call $class->SUPER::new() 
for each parent class.


Mark



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

Date: Mon, 02 May 2005 14:40:41 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Somethign about hashes
Message-Id: <QoydnVYBGKu06evfRVn-uw@comcast.com>

Nikos wrote:

> Tad McClellan wrote:
> 
>> That's too bad, but it does not change a CSS question
>> into a Perl question.
>> 
>> PLEASE STOP ABUSING OUR NEWSGROUP!
> 
> Its not completely irrelevant with Perl since it embeds the use of cgi.pm
> 
Tell me, if you drove your car to the supermarket and they were out
of milk, would you regard this as a matter to take up with your
mechanic?  After all, it happened while you were on a trip with
your car!

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Mon, 02 May 2005 22:02:14 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Somethign about hashes
Message-Id: <d55tfj$uh$1@nic.grnet.gr>

Chris Mattern wrote:

> Tell me, if you drove your car to the supermarket and they were out
> of milk, would you regard this as a matter to take up with your
> mechanic?  After all, it happened while you were on a trip with
> your car!
> 

lol! :-)

ok, but it wouldnt be much of a trouble if you helped me a little on the 
styling since little details are confusing me, would it?

if yes, the ignore my question.

-- 
"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: Tue, 3 May 2005 07:07:28 +1200
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: Somethign about hashes
Message-Id: <KTude.3085$Od6.448136@news.xtra.co.nz>


"Nikos" <hackeras@gmail.com> wrote in message 
news:d55kta$n1e$1@nic.grnet.gr...
> A. Sinan Unur wrote:
>> You are making false statements again:
>>
>> <URL: 
>> http://groups-beta.google.com/group/alt.html/browse_thread/thread/e23f2ce89b2db30d/0bd488c7cab7d760#0bd488c7cab7d760>
>>
>> It seems like you got useful answers. The fact that you don't
>> like them, and you want others to do your work does not change
>> that fact.
>>
>> Now, try to remember what we call people who insist on making false 
>> statements?
>
> Ah, so they did answer there.....
> Thats nice to hear, iw aited 2 days but i didnt got any response and today 
> morning i unsubscribed from alt.html considering that after what grg said 
> they will never anser.
>
> Now with the url you pointed to me i just saw their new responses.
>
> Sorry about that but once again iam i am a vivtim of circumstances....

More a victim of your own impatience and lazyness. 




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

Date: Mon, 02 May 2005 22:12:23 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Somethign about hashes
Message-Id: <d55u2j$1kf$1@nic.grnet.gr>

Tintin wrote:

>>Now with the url you pointed to me i just saw their new responses.
>>
>>Sorry about that but once again iam i am a vivtim of circumstances....
> 
> 
> More a victim of your own impatience and lazyness. 

Yes, unforunately.

-- 
"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: 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 8042
***************************************


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