[Wellington-pm] Roundup of Monday night's meeting

Grant McLean grant at mclean.net.nz
Wed Dec 15 01:36:22 CST 2004


On Wed, 2004-12-15 at 09:02, Peter Love wrote:
> > And what I forgot to say, was that the sample source code and slides are
> > up in the 'archive' section of the web site:
> > 
> >   http://wellington.pm.org/archive/
> 
> Note that the presentation that Grant will have uploaded (don't copy 
> anything to his laptop - you never know where it might end up!) is a 
> slightly older version than what I used.

Sorry Peter, I didn't realise you were wanting to keep your code under
wraps.  A lot of people do rely on the material appearing on the web
site so they can review it and absorb it at their own pace later.  I
wouldn't get too concerned about tidying up the code, what's on the site
works and that's the main thing.

FYI - as far as the hard-coded pathname goes, there's a common Perl
idiom for dealing with paths relative to the location of the script. 
One approach is to extract the path out of $0, or __FILE__, but a
cleaner approach is to use the core module FindBin:

  use FindBin qw($Bin);
  my $slidedir = $Bin;

I often use it for adding a lib directory to @INC:

  use FindBin qw($Bin);
  use lib "$Bin/lib";

or more portably:

  use FindBin qw($Bin);
  use File::Spec;
  use lib File::Spec->catfile($Bin, 'lib');

Cheers
Grant



More information about the Wellington-pm mailing list