emperor: (Default)
Add MemoryShare This Entry
posted by [personal profile] emperor at 01:55pm on 08/06/2011 under , ,
I have concluded that I really ought to learn some Perl. In my experience, while reading the fine manual is a good start, having some sort of project in a new language is the way to really cement my learning.

I have also been thinking for a while that it might be nice to have some record of beers I have drunk. Partly so I can avoid the real stinkers, and partly so that when faced with a beer festival list, I can try and pick new beers. And also because I'm a bit of a sad geek.

Things to note about a beer would be: name, brewery, abv, rating (I am persuaded by Ben that /5 is the way to go here, rather than the /10 I've used in the past), comment, and maybe date and occasion of tasting and country of origin? I guess you might want the opportunity to add repeat tastings in the event of changing one's mind substantially.

Obvious features would be: interactive or bulk import, various search and sort routines for output (cli and maybe web-based too?), and the ability to feed in a beer list (from e.g. a festival) and get back new beers, and perhaps beers I've liked a lot previously.

Less obvious features would be: tweeting new beers as they are added to the system, links to Open Beer DB, beermad, Cyclops, etc., export in odd formats...?

I don't think there's much of great difficulty in implementation - some sort of SQLish storage should get most of the searching and sorting pretty much for free, and the rest is just some text processing (with a bit of thought about reliable updates, future spec changes and the like). What have I missed?

I'm sure this is a wheel that has been invented before, but maybe someone else will want to use it :)

And finally, now would be a good time to pass on any pearls of wisdom that you wish someone had imparted to you when you started to write Perl ;-)
There are 7 comments on this entry. (Reply.)
gerald_duck: (by Redderz)
posted by [personal profile] gerald_duck at 02:03pm on 08/06/2011
FWIW I learned Perl a few years back and with hindsight wish I'd invested the effort in Python instead.

I learned from the Camel Book. The Perl I subsequently produced was well received by experts who viewed it, so I must have been doing something right as a result.

Other bits of advice: it sounds like your motivating problem is actually database schema specification more than coding; there's famously more than one way to do it, but choose carefully because most involve polymorphing into a millipede then running off several clips from an automatic weapon without bothering to take aim.
emperor: (Default)
posted by [personal profile] emperor at 02:05pm on 08/06/2011
I already use python a lot, and have a copy of the Camel book on loan from the university library here :)
 
posted by [identity profile] deliberateblank.livejournal.com at 07:11pm on 08/06/2011
The camel book is better as a reference (along with Advanced Perl Programming, but by that time the manpages and google are faster). If you know C then Learning Perl is a pretty quick and easy introduction to the important differences.
 
posted by [identity profile] pseudomonas.livejournal.com at 02:04pm on 08/06/2011
The Perl framework Maypole is documented in terms of beer :)
 
posted by [identity profile] mobbsy.livejournal.com at 10:01pm on 08/06/2011
OOP Perl is awful, just avoid it.

When they say "there's more than one way to do it", they mean there's no right way to do it.

Get your head around refs sooner rather than later.

{ is not the same as ( is not the same as [ - if using one does something random, try the other; similarly with $ % and @. Being Perl, you won't always get an error for using the wrong one, just unexpected behaviour.

Just dump all your data into a bunch of hashes, it's easier.

$myData is not the same as $mydata; however both will happily work.

Nearly everything useful is in a CPAN library. CPAN won't be available in the next place you want to run your code. If it is, then chasing down all the package dependencies will be a major headache.

Date/time handling is terrible in the base language. (See above re CPAN).

Despite all that, it's sometimes the easiest option to use Perl.

ext_22879: (Default)
posted by [identity profile] nja.livejournal.com at 07:27pm on 09/06/2011
Haven't programmed in Perl for a couple of years since switching to Python, but...

use strict; - means you can't implicitly declare variables which traps a lot of typos and scope problems. I never bothered with the -w flag which always seemed to me to generate too many warnings to which the response was "yes, I know I'm doing that".

I like Nigel Chapman's "Perl: The Programmer's Companion", which assumes you know how to program already and just need to get up to speed with a new language (but also deals with some of the advanced features that "get going quickly" books tend to skip over, if I remember correctly). Seems to be out of print, but there are reasonably-priced new and second hand copies on Amazon marketplace.

sparrowsion: photo of male house sparrow (string-handling kitten)
posted by [personal profile] sparrowsion at 11:04am on 10/06/2011
Just want to strongly second [livejournal.com profile] mobbsy's comment about OOP. It's an ugly, hacked-on afterthought of an extension which fits uneasily with Perl's strong procedural foundations and (almost) everyone else's ideas of how to do objects. It's only there because of the "OOP is shiny and The Way Forward" movement, and too many people wound up drinking the Kool-Aid and writing hideously impenetrable and unusable Perl modules which would have been vastly simpler and cleaner if they hadn't tried to make it object orientated.

People often make the mistake, when moving from Perl to Python, of trying to use regular expressions for all string handling. It's a mistake because regular expressions are an integral part of the Perl language, whereas in Python they're an extension, where they should only be used when they're the right tool. Going the other way, precisely the same is true about object orientation.

October

SunMonTueWedThuFriSat
      1
 
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
 
10
 
11
 
12
 
13
 
14
 
15
 
16
 
17
 
18
 
19
 
20
 
21
 
22
 
23
 
24
 
25
26
 
27
 
28
 
29
 
30
 
31