[26633] in Perl-Users-Digest
Perl-Users Digest, Issue: 8741 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 7 09:05:37 2005
Date: Wed, 7 Dec 2005 06:05:07 -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, 7 Dec 2005 Volume: 10 Number: 8741
Today's topics:
Re: A simple inheritance question. (Anno Siegel)
Re: How can I use GD module in Windows XP ? <smilebang@dreamwiz.com.nospam>
Re: How do I reply a NNTP message? <tintin@invalid.invalid>
Re: migrate data tables robic0
Re: Perl Blather Generator axel@white-eagle.invalid.uk
Slice to end of array (Ronald Fischer)
Re: Slice to end of array <oliver.gorwits@computing-services.oxford.ac.uk>
Re: Slice to end of array <tassilo.von.parseval@rwth-aachen.de>
Re: Slice to end of array (Anno Siegel)
Re: Why array always printed as pointer? <sdn.girths00869@zoemail.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Dec 2005 13:58:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: A simple inheritance question.
Message-Id: <dn6pql$fl1$1@mamenchi.zrz.TU-Berlin.DE>
Don Gatlin <invalid@nowhere.com> wrote in comp.lang.perl.misc:
> On Tue, 06 Dec 2005 17:10:48 -0700, Scott Bryce wrote:
>
> > Don Gatlin wrote:
> >> Got to get a book on actual POOP if one exists.
> >
> > Object Oriented Perl by Damian Conway
>
> Found it at Booksamillion online and it is coming. Not many books on Perl
> oop available. Probably not enough room in the warehouses from the fifty
> thousand C++ oop books in stock.
OOP remains a good book, but there are newer developments. Damian's
newest opus _Perl Best Practices_ recommends inside-out objects as the
standard object type. These are not (yet) mentioned in OOP. This may
be relevant because your problem is at least partly related to data
inheritance. Specifically, when and how are attributes (fields) of an
ancestor class initialized?
Common wisdom is that Perl has no data inheritance, but that isn't quite
true. The problem is that Perl doesn't *support* data inheritance in
a meaningful way. If the parent class and the subclass are both hashes,
and if you implement inheritance in the standard way (as in your example),
there is *too much* data inheritance. The attributes of the subclass are
in the same name space as those of the parent, an absurdity in the face of
encapsulation. Inside-out objects give every class its own lexical name
space, that is their fundamental merit.
You can learn about PBP's introduction to inside-out classes without
(immediately) buying the book. The documentation of the CPAN module
Class::Std is more or less identical to the relevant chapters from PBP.
Anno
--
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, 7 Dec 2005 22:11:09 +0900
From: "???" <smilebang@dreamwiz.com.nospam>
Subject: Re: How can I use GD module in Windows XP ?
Message-Id: <dn6mr6$7iu$1@news2.kornet.net>
Thanks Dr. Ruud and Bob Walton
On the command prompt , I typed as follows
ppm rep add threoryx http://theoryx5.uwinnipeg.ca/ppms/
ppm install GD
Thank you Sir!
------------------------------
Date: Wed, 7 Dec 2005 21:03:26 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: How do I reply a NNTP message?
Message-Id: <4Hwlf.6300$vH5.332351@news.xtra.co.nz>
"Jamie" <nospam@geniegate.com> wrote in message
news:Lucy1133921078108850xaa1f48@air.tunestar.net...
> In: <VNSdnRKtScA2uAjenZ2dnUVZ_t-dnZ2d@rogers.com>, "OttawaTrade"
> <speediercoREMOVE_THIS@yahoo.com> wrote:
>>I am kind of confused by MSGNUM and MSGID.
>
> MSGID is the articles message ID.
>
>>I don't want the replies become a new thread. I want them to follow the
>>prevous posted messages.
>
> NNTP doesn't "know" about threading, client programs need to do this
> themselves. One useful way (most servers support it) is to use the XOVER
> command to fetch references.
>
> Basically, you need to do threading client-side.
>
> BTW, I'd strongly recommend against posting messages from a web site.
Good point. Just look at the mess Google Groups has made of Usenet.
------------------------------
Date: Tue, 06 Dec 2005 22:33:38 -0800
From: robic0
Subject: Re: migrate data tables
Message-Id: <8stcp1d8c0tkq6ahqe0b5ehgp9capbg556@4ax.com>
On Mon, 05 Dec 2005 02:29:55 -0500, John Smith <noone@nowhere.net>
wrote:
>robic0 wrote:
>> On Sat, 03 Dec 2005 14:26:16 -0500, John Smith <noone@nowhere.net>
>> wrote:
>>
>>> I have data in a Foxpro DBF table. Is there a quick, simple way in Perl
>>> to copy this table into a SQLite table? I know how to do it manually
>>> using DBI, but I'm looking for a package that does it all automatically.
>>> I do not mind if the data types are not mapped exactly right. Could
>>> SNOPS do it?
>>>
> >> The reason I need to do this is because I need to generate some
>reports
>>>from the Foxpro database. However, I'm unfamiliar with Foxpro SQL, the
>>> Foxpro ODBC driver has very limited functionality, and the data is
>>> read-only. So it would be easier if I imported the data into a more
>>> advanced database and worked with it from there. I'm using Perl on
>>> Windows XP.
>>
>> This is really puzzling, Foxpro is very limited functionality?
>> I never used foxpro, but most dbm engines support standard SQL
>> syntax. Are you new to sql query's? Have you ever heard of
>> "stored procedures"? Most need several practice query's to have
>> it sink in. Mostly simple. However in Access, the level of
>> auto-generated indirection (relationships) can produce query
>> strings several K in size that can only be analyzed graphically.
>> Access does however support simple sql standards.
>>
>
>Foxpro is not bad, but the Foxpro ODBC driver is very limited. See:
>http://tinyurl.com/bhdby
>
>I tried DBIx::Migrate, but it didn't create the tables in the target. I
>looked at SPOPS, but it was too complicated. I didn't want to use
>inefficient Table2Hash/Hast2Table functions. Taking advantage of
>SQLite's data type independence, I wrote this utility function:
>
># source DBI connection - odbc
># target DBI connection - sqlite
># odbc query
># new table name
>sub CreateTemporarySQLiteTable($$$$)
>{
> my ($dbh, $sth, @row, $i);
> my $source = shift;
> my $target = shift;
> my $query = shift;
> my $newtablename = shift;
> my ($fieldnames);
>
> $sth = $source->prepare($query)
> or die "Error-".$source->errstr()."-preparing: $query";
> $sth->execute() or die "Error-".$source->errstr()."-executing: $query";
> $fieldnames = $sth->{NAME_uc};
> $query = "CREATE TABLE ".$newtablename." ('".join("','",@$fieldnames)."')";
> $target->do($query)
> or die "Error creating table: ".$source->errstr();
> while(@row = $sth->fetchrow_array())
> {
> $query = "INSERT INTO ".$newtablename." VALUES (";
> for($i = 0; $i < scalar(@row); $i++)
> {
> $query .= $target->quote($row[$i]);
> if($i == scalar(@row)-1) {
> $query .= " ) ";
> } else {
> $query .= " , ";
> }
> }
> $target->do($query);
> }
> $target->commit();
>}
>
>It reads my Foxpro data into a SQLite table. Actually, it takes the
>results of any SELECT query from any DBI data source, and dumps it into
>a new SQLite table. I can take snapshots of all the data I need from
>Foxpro, and then do additional processing from there. The main thing I
>wanted from SQLite was the ability to do nested subqueries. The Foxpro
>ODBC driver only supports a couple in the WHERE clause. I couldn't
>import or touch the Foxpro database, because it is part of an in-use,
>legacy application. Thanks for your reply.
>
Honestly, I don't know why you go to so much trouble trying to
just generate a report. The create and insert constructs are
standard. You seem to have sql down so it shouldn't matter what
db engine you use. When you programmatically do a create table
(with fields), then populate it with insert into's (records),
and can't do a query on the existing db/table? That doesen't
make sense.
If the where clause isin't so robust, then convert
the db/table into another form using acess. Then construct a query
string to be passed to a more robust engine that can do the sql
you need to describe the output you want.
To that end, today I casually noticed standard Perl has an ADO
interface inplememted directly through their Ole module (using OleDB)
that auto-initializes. Using that, if you know ADO paradigm, you can
do anything you want, such as what your code shows above and all your
query's directly. The code I posted just wrapped the ADO paradigm
that can be done in this module, however it just marshals information
to the connected db engine. So beyond table creation, it still boils
down to creating a sql string that you connected db engine can
understand. This is true of ALL engines, thus ADO.
I think you are confusing the issue when you rely on hacked out
modules to provide you a turnkey solution. You don't know these
modules. You would be better off understanding the ADO paradigm
which is your gateway to ALL dbm's. That paradigm is the one
used in all and anything database in Perl. This is the joke
here --> You don't think that when M$ says this is the way it will
be, the major (and minor) corporate db don't comply do you?
ADO is the common interface to ALL ODBC dbm's running on windows.
And now you know you don't need DBI for it. If you want
the ability to convert Foxpro db to one with more robust sql
and/or you work with alot and want to do complex reports that
Foxpro cant do but that Foxpro can be converted to another
engine and that would be a part of the procedure everytime.
If Foxpro ODBC can be relied upon to provide the minimum
get fields/records via ADO, sure you could convert it in Perl
if you can connect to it. You would have a parallel connection
to another dbm (like you did above), then write out the new db/table.
Then do your sql/reports using the new engine.
Its all so tedius. I've done this thousands of times. But you know
its job security where you work since nobody wants to touch this
stuff. A word of advice, when you get a method down, don't tell
your boss that you can do this anytime easily now. Make him think
every request requires custom code and a long time to do it.
------------------------------
Date: Wed, 07 Dec 2005 12:47:51 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Perl Blather Generator
Message-Id: <XRAlf.4229$iz3.1230@text.news.blueyonder.co.uk>
In comp.lang.perl.misc vjp2.at@at.biostrategist.dot.dot.com wrote:
> I'm sure I've seen programs that generate blather but now I
> can't find one. I'm stuck in a wierd situation that comes up often
> enoguh: Some third-worlders insist you write pretentious casuistry
> when a few simple words are enough. It is sad in these day of "Fog
> Index" that we have people who are commitedly ideological and even
> theologically dogmatic about making prose incomprehensibly obfuscated
> and complicated. I want it in perl so it can be extremely portable.
Have a look at:
http://www.cs.utexas.edu/users/jbc/home/chef.html
And the lex sources for the jive and other translators.
Axel
------------------------------
Date: Wed, 07 Dec 2005 09:12:12 GMT
From: u235321044@spawnkill.ip-mobilphone.net (Ronald Fischer)
Subject: Slice to end of array
Message-Id: <l.1133946732.1096008300@proxy22-ic-ext.fth.sbs.de>
Given an array @x, what is the most elegant way to get a slice from index $n to the end of the array?
My first attempt was @x[$n .. -1] failed - probably because the
.. operator found that the rhs value was already lower than the
lhs value and hence produced an empty range.
I ended up with @x[$n .. $#x], which is not that bad, but maybe someone
can come up with a better solution?
Ronald
--
Sent by mn-pg-p-e-b-consultant-3.com from siemens in field com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com
------------------------------
Date: Wed, 07 Dec 2005 09:40:32 +0000
From: Oliver Gorwits <oliver.gorwits@computing-services.oxford.ac.uk>
Subject: Re: Slice to end of array
Message-Id: <dn6amg$q7h$1@news.ox.ac.uk>
Ronald Fischer wrote:
> Given an array @x, what is the most elegant way to get a slice from index
> $n to the end of the array?
See the splice builtin's man page: `perldoc -f splice`
regards,
oliver.
------------------------------
Date: Wed, 7 Dec 2005 11:12:39 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Slice to end of array
Message-Id: <3vnqspF16qv6hU1@news.dfncis.de>
Also sprach Ronald Fischer:
> Given an array @x, what is the most elegant way to get a slice from
> index $n to the end of the array?
>
> My first attempt was @x[$n .. -1] failed - probably because the
> .. operator found that the rhs value was already lower than the
> lhs value and hence produced an empty range.
That's correct.
> I ended up with @x[$n .. $#x], which is not that bad, but maybe someone
> can come up with a better solution?
This is a perfectly legitimate way of doing it and I'd do it thus
myself. If you dislike the use of $#x, you could also do:
reverse +(reverse @x)[0 .. $n];
Clearly, here the cure is worse than the disease.
You might also be interested in splice(), mentioned elsewhere in this
thread. But note that this will remove the elements from the input array
so it's destructive.
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
------------------------------
Date: 7 Dec 2005 11:59:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Slice to end of array
Message-Id: <dn6iqv$b4c$1@mamenchi.zrz.TU-Berlin.DE>
Tassilo v. Parseval <tassilo.von.parseval@rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach Ronald Fischer:
>
> > Given an array @x, what is the most elegant way to get a slice from
> > index $n to the end of the array?
[...]
> > I ended up with @x[$n .. $#x], which is not that bad, but maybe someone
> > can come up with a better solution?
>
> This is a perfectly legitimate way of doing it and I'd do it thus
> myself. If you dislike the use of $#x, you could also do:
>
> reverse +(reverse @x)[0 .. $n];
>
> Clearly, here the cure is worse than the disease.
Another alternative is
@x[ $n-@x .. -1];
which is more concise, but confusing. The straight-but-narrow way is
best here.
Anno
--
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, 07 Dec 2005 05:42:13 -0600
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: Why array always printed as pointer?
Message-Id: <Xns97254487585D7sdn.comcast@216.196.97.136>
"OttawaTrade" <speediercoREMOVE_THIS@yahoo.com> wrote in
news:1eSdnYCg9u_bdQjenZ2dnUVZ_t-dnZ2d@rogers.com:
> I guess it is a deref issue.
> I did two things. 1 works, 2 does not
>
> 1 $lines= $nntp-> article ('<FIqdndE94PcxiwjeRVn-sw@rogers.com>');
> print @$lines;
>
> 2 print @($nntp-> article ('<FIqdndE94PcxiwjeRVn-sw@rogers.com>'));
>
I do not believe you.
>
> Is there a way to get rid of the middleman $lines?
>
I have no clue what this question is asking.
--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
------------------------------
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 8741
***************************************