Educational

Author Topic: object-oriented Perl  (Read 840 times)

0 Members and 4 Guests are viewing this topic.

Offline odeon

  • Witchlet of the Aspie Elite
  • Webmaster
  • Postwhore Beyond Repair
  • *****
  • Posts: 108879
  • Karma: 4481
  • Gender: Male
  • Replacement Despot
Re: object-oriented Perl
« Reply #15 on: April 30, 2009, 12:10:52 PM »
I hope you can enjoy that book, after all the trouble it has caused you. :)
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

- Albert Einstein

Offline Parts

  • The Mad
  • Caretaker Admin
  • Almighty Postwhore
  • *****
  • Posts: 37456
  • Karma: 3059
  • Gender: Female
  • Who are you?
Re: object-oriented Perl
« Reply #16 on: May 04, 2009, 08:44:02 PM »
"Eat it up.  Wear it out.  Make it do or do without." 

'People who say it cannot be done should not interrupt those who are doing it.'
George Bernard Shaw

Offline garmonbozia

  • Elder
  • Incessant Poster
  • *****
  • Posts: 581
  • Karma: 136
  • Gender: Male
  • The plane! The plane!
Re: object-oriented Perl
« Reply #17 on: May 21, 2009, 04:57:11 PM »
I've been reading the recently-acquired book and also a few that I've had for years, and last night I did some practice coding.  I wanted to make sure I have the Perl modules available to put a GUI on this project.  I thought I'd be using Tk, which I have a whole book about.  I couldn't figure out how to install it, but saw that I already have a similar module called Tkx.  Only thing is, Tkx has a syntax that is rather different from Tk.  I'll need to find some good reference material on it.  I did manage to stumble around and make a "Hello, world" program (a tradition for when you're working with a new language or making sure a language works on your computer) and then add onto it.  This one has a text field and two buttons.  When you click one of the buttons, whatever you've got in the text field gets spit out onto the MS-DOS console.  The other button closes the program.  No real purpose, except for practice.

I also plan to practice using "hash" data structures and then see if I've got the Perl DBI module.  DBI is what lets your program keep its information in a real database (e.g. PostgreSQL or MySQL) and not just a bunch of text files.


Offline odeon

  • Witchlet of the Aspie Elite
  • Webmaster
  • Postwhore Beyond Repair
  • *****
  • Posts: 108879
  • Karma: 4481
  • Gender: Male
  • Replacement Despot
Re: object-oriented Perl
« Reply #18 on: May 22, 2009, 06:00:03 AM »
Let me know how it goes. :)
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

- Albert Einstein

Offline garmonbozia

  • Elder
  • Incessant Poster
  • *****
  • Posts: 581
  • Karma: 136
  • Gender: Male
  • The plane! The plane!
Re: object-oriented Perl
« Reply #19 on: May 23, 2009, 06:19:49 AM »
Certainly.

I did check the Perl Package Manager console yesterday and saw that it's already got DBI.  So, hopefully, I'll be able to try the exercises in my DBI book (Programming the Perl DBI by Alligator Descartes and Tim Bruce; O'Reilly and Associates; ISBN 1-56592-699-4) with no trouble.

The real fun will begin when I start writing stuff that uses Tkx, DBI, and ImageMagick all in one program with carefully-constructed data structures.


Offline odeon

  • Witchlet of the Aspie Elite
  • Webmaster
  • Postwhore Beyond Repair
  • *****
  • Posts: 108879
  • Karma: 4481
  • Gender: Male
  • Replacement Despot
Re: object-oriented Perl
« Reply #20 on: May 23, 2009, 04:58:09 PM »
You'll be using ImageMagick? Very cool.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

- Albert Einstein

Offline garmonbozia

  • Elder
  • Incessant Poster
  • *****
  • Posts: 581
  • Karma: 136
  • Gender: Male
  • The plane! The plane!
Re: object-oriented Perl
« Reply #21 on: May 23, 2009, 11:07:15 PM »
I've been using ImageMagick for a decade, in the Linux shell, the DOS prompt, and as the PerlMagick module... both at home and at work.  Very useful when you need to do the same thing to hundreds of images all at once.

Offline odeon

  • Witchlet of the Aspie Elite
  • Webmaster
  • Postwhore Beyond Repair
  • *****
  • Posts: 108879
  • Karma: 4481
  • Gender: Male
  • Replacement Despot
Re: object-oriented Perl
« Reply #22 on: May 24, 2009, 10:11:59 AM »
Yes, it's a very useful library. We use it for our document management system, to generate previews.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

- Albert Einstein

Offline garmonbozia

  • Elder
  • Incessant Poster
  • *****
  • Posts: 581
  • Karma: 136
  • Gender: Male
  • The plane! The plane!
Re: object-oriented Perl
« Reply #23 on: May 28, 2009, 05:02:10 PM »
Interesting.  I work in document management.

The project I'm working on at home, I guess I could accurately describe as my own spin on digital asset management.  It will be a piecing-together of various small imaging-related programs I've written for my own use over the past ten years.

As for O-O Perl, since getting the book and also consulting some other books in my collection, I've written a couple of little test programs.  So far, I've succeeded at using O-O Perl with the modules for graphics (ImageMagick) and user interfaces (Tkx).  The past few days, I've been studying the use of DBI, the module for databases.  I've got several years experience with ImageMagick, so I need no further practice with that.  Once I've got the hang of Tkx and DBI, I'll be ready to do the serious work on my project.


Offline garmonbozia

  • Elder
  • Incessant Poster
  • *****
  • Posts: 581
  • Karma: 136
  • Gender: Male
  • The plane! The plane!
Re: object-oriented Perl
« Reply #24 on: June 03, 2009, 04:27:35 PM »
Been practicing with the DBI.  I was originally trying to decide between MySQL and PostgreSQL.  I decided on another one called SQLite because the others require you to have a server process running in the background at all times, even when you're not using the database.  With SQLite, the database is just another type of data file, but still "speaks" SQL.  Besides, it's already included with ActiveState Perl if you've got the DBI.

Last night I practiced by adding some database usage to a program I had originally written to practice with text fields in Tkx.  Every time you process the information in the text boxes, it saves it to a SQLite database.  The goal is to get the program to remember what was in the text boxes the last time it ran.  Currently, it's adding a newline character ( '\n' ) to the end of every string in the text boxes after recalling it from the database.  I need to figure out where along the way it's picking up the newline character and stop it from doing that.


Offline garmonbozia

  • Elder
  • Incessant Poster
  • *****
  • Posts: 581
  • Karma: 136
  • Gender: Male
  • The plane! The plane!
Re: object-oriented Perl
« Reply #25 on: June 06, 2009, 09:41:34 PM »
Figured out the newline issue.  I needed to be using the "chop" command when adding data to the database.  Today, I gave the test program the ability to remember its past settings in an SQLite database and allow the user to scroll through the database records and retrieve them.  The program doesn't do anything important.  It's just to practice my programming skills for later use in writing a planned program with a practical purpose.

Offline odeon

  • Witchlet of the Aspie Elite
  • Webmaster
  • Postwhore Beyond Repair
  • *****
  • Posts: 108879
  • Karma: 4481
  • Gender: Male
  • Replacement Despot
Re: object-oriented Perl
« Reply #26 on: June 07, 2009, 06:03:19 AM »
Chop is very useful for other stuff as well. Try writing a simple XML parser without it.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

- Albert Einstein

Offline garmonbozia

  • Elder
  • Incessant Poster
  • *****
  • Posts: 581
  • Karma: 136
  • Gender: Male
  • The plane! The plane!
Re: object-oriented Perl
« Reply #27 on: June 16, 2009, 01:33:49 PM »
Now that I've figured out the use of a database and some basics on GUI, I've started practicing with the Tkx canvas.  Been trying to figure out how to read an image from a JPEG and put it into the canvas.

Offline odeon

  • Witchlet of the Aspie Elite
  • Webmaster
  • Postwhore Beyond Repair
  • *****
  • Posts: 108879
  • Karma: 4481
  • Gender: Male
  • Replacement Despot
Re: object-oriented Perl
« Reply #28 on: June 16, 2009, 02:37:02 PM »
Never did much of that, me.

But today, for the first time in years, really, I did some Perl hacking. Me and a mate at work did some stuff to a couple of hundred XML files. They needed fixing after a bug in the CMS caused some trouble.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

- Albert Einstein

Offline garmonbozia

  • Elder
  • Incessant Poster
  • *****
  • Posts: 581
  • Karma: 136
  • Gender: Male
  • The plane! The plane!
Re: object-oriented Perl
« Reply #29 on: June 20, 2009, 10:47:44 AM »
I've never done much with XML.  I assume it can be used in a similar manner to a database?  From what I've seen, it looks like you need to decide your data layouts very carefully at the very start.  I decided to stick with SQLite and its .dbl files, because I'm more comfortable using a data format that speaks SQL.