From dan at linder.org Thu Sep 1 08:35:30 2005
From: dan at linder.org (Daniel Linder)
Date: Thu, 1 Sep 2005 10:35:30 -0500 (CDT)
Subject: [Omaha.pm] Proper way to test a variable with strict and -w?
Message-ID: <16020.12.160.138.88.1125588930.squirrel@mail.linder.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Guys,
I have this basic perl script:
#!perl -w
use strict;
use Env qw(EnvVar1 EnvVar2);
my $EnvVar1="DefaultValue1" if ("" eq
"$EnvVar1");
my $EnvVar2="DefaultValue2" if ("" eq
"$EnvVar2");
my $Var3 = "$EnvVar1 -- $EnvVar2";
When I run it, the perl interperter complains about "Use of
uninitialized value in concatenation" on the "Var3" line
(the last line.
Did I mess things up by putting the "my" on the
"EnvVar1" and "EnvVar2" lines -- these variables
should be defined on the "use Env" line, right?
If you were to re-write this whole section, how would you do it??
This is my thought:
#!perl -w
use strict;
use Env qw(EnvVar1 EnvVar2);
my $EnvVar1 = "DefaultValue1" if (! exists ($EnvVar1));
my $EnvVar2 = "DefaultValue2" if (! exists ($EnvVar2));
my $Var3 = "$EnvVar1 -- $EnvVar2";
Dan
- - - - -
"Wait for that wisest of all counselors, time." -- Pericles
"I do not fear computer, I fear the lack of them." -- Isaac
Asimov
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDFx/CsrDMR0/em2gRAjnJAKDjWccSSR95T9C/ZPGSNwMCCQiUzwCfc9Lg
TOQ6HWycMlibL+x3LZTBHHs=
=okW6
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050901/10c5e97f/attachment.html
From kthompson at omnihotels.com Thu Sep 1 08:47:47 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Thu, 1 Sep 2005 10:47:47 -0500
Subject: [Omaha.pm] Proper way to test a variable with strict and -w?
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B0301B77B@exchange2k3.omnihotels.net>
It could be $EnvVar1 and 2 are in fact not initialized and that is the
complaint.
Is this what you're trying to say?
my $EnvVar1 = ($EnvVar1 || "DefaultValue1");
my $EnvVar2 = ($EnvVar2 || "DefaultValue2");
my $Var3 = "$EnvVar1 -- $EnvVar2";
English:
If for some reason $EnvVar1 doesn't have a value, use the value
"DefaultValue1"
________________________________
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Daniel Linder
Sent: Thursday, September 01, 2005 10:36 AM
To: omaha-pm at pm.org
Subject: [Omaha.pm] Proper way to test a variable with strict and -w?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Guys,
I have this basic perl script:
#!perl -w
use strict;
use Env qw(EnvVar1 EnvVar2);
my $EnvVar1="DefaultValue1" if ("" eq "$EnvVar1");
my $EnvVar2="DefaultValue2" if ("" eq "$EnvVar2");
my $Var3 = "$EnvVar1 -- $EnvVar2";
When I run it, the perl interperter complains about "Use of
uninitialized value in concatenation" on the "Var3" line (the last line.
Did I mess things up by putting the "my" on the "EnvVar1" and "EnvVar2"
lines -- these variables should be defined on the "use Env" line, right?
If you were to re-write this whole section, how would you do it? This
is my thought:
#!perl -w
use strict;
use Env qw(EnvVar1 EnvVar2);
my $EnvVar1 = "DefaultValue1" if (! exists ($EnvVar1));
my $EnvVar2 = "DefaultValue2" if (! exists ($EnvVar2));
my $Var3 = "$EnvVar1 -- $EnvVar2";
Dan
- - - - -
"Wait for that wisest of all counselors, time." -- Pericles
"I do not fear computer, I fear the lack of them." -- Isaac Asimov
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDFx/CsrDMR0/em2gRAjnJAKDjWccSSR95T9C/ZPGSNwMCCQiUzwCfc9Lg
TOQ6HWycMlibL+x3LZTBHHs= =okW6 -----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050901/fe4116cc/attachment.html
From dan at linder.org Thu Sep 1 10:42:36 2005
From: dan at linder.org (Daniel Linder)
Date: Thu, 1 Sep 2005 12:42:36 -0500 (CDT)
Subject: [Omaha.pm] Proper way to test a variable with strict and -w?
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B0301B77B@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B0301B77B@exchange2k3.omnihotels.net>
Message-ID: <41817.12.160.138.88.1125596556.squirrel@mail.linder.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, September 1, 2005 10:47, Kenneth Thompson wrote:
It could be
$EnvVar1 and 2 are in fact not initialized and that is the
complaint.
Is this what
you’re trying to say?
my $EnvVar1 =
($EnvVar1 || "DefaultValue1");
my $EnvVar2 =
($EnvVar2 || "DefaultValue2");
my $Var3 =
"$EnvVar1 -- $EnvVar2";
English:
If for some
reason $EnvVar1 doesn’t have a value, use the value
“DefaultValue1”
Ah, this could be a good use of the "//" instead of
"||", right?
Dan
- - - - -
"Wait for that wisest of all counselors, time." -- Pericles
"I do not fear computer, I fear the lack of them." -- Isaac
Asimov
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDFz2MsrDMR0/em2gRAvKEAKDgm22Bg0JTT3wmhFzooGIgCH762ACfXSsq
q/aV9w0/7N0pZ826lfAs20U=
=XDZ9
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050901/eccfadc2/attachment.html
From kthompson at omnihotels.com Thu Sep 1 15:22:35 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Thu, 1 Sep 2005 17:22:35 -0500
Subject: [Omaha.pm] Quick Bail
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B0301BC31@exchange2k3.omnihotels.net>
A short one-liner to keep a script from executing more than one at a
time (say a long running script kicked off from cron every minute that
runs more than a minute occasionally...
my @ps = `ps -ef | grep $0 | grep -v grep`; exit if ( @ps > 1);
and a more advanced version...
my @procs = grep /perl .*invan\.pl/, `ps axw`;
if (@procs > 1) {
unless ($ENV{USER} eq "jhannah") { # Hopefully that dork knows what
he's doing, so let him do whatever.
die "Looks like I'm already running. I refuse to run on top of
myself.\n @procs";
}
}
Kenn Thompson
Omni Hotels Reservation Center
Sr. Programmer/Analyst
w:402.952.6521
c:402.598.8818
Omni Hotels is proud to be ranked "Highest in Guest Satisfaction Among
Upscale Hotel Chains" in the J.D. Power and Associates 2005 North
America Hotel Guest Satisfaction StudySM.
(Study based on 37,471 responses from guests who stayed in a hotel
between December 2004 and May 2005. Fourteen upscale hotel chains were
ranked in the study. www.jdpower.com )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050901/2aac4f35/attachment.html
From kthompson at omnihotels.com Thu Sep 1 15:37:11 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Thu, 1 Sep 2005 17:37:11 -0500
Subject: [Omaha.pm] Proper way to test a variable with strict and -w?
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B0301BC49@exchange2k3.omnihotels.net>
>>Ah, this could be a good use of the "//" instead of "||", right?
Could be- what does "// " do?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050901/6d25bfe9/attachment.html
From jay at jays.net Fri Sep 2 05:01:27 2005
From: jay at jays.net (Jay Hannah)
Date: Fri, 2 Sep 2005 07:01:27 -0500
Subject: [Omaha.pm] Proper way to test a variable with strict and -w?
In-Reply-To: <16020.12.160.138.88.1125588930.squirrel@mail.linder.org>
References: <16020.12.160.138.88.1125588930.squirrel@mail.linder.org>
Message-ID: <7ab5e75bd0986cd0894dbd4c3ab5f8bb@jays.net>
On Sep 1, 2005, at 10:35 AM, Daniel Linder wrote:
> use Env qw(EnvVar1 EnvVar2);
>
> my $EnvVar1="DefaultValue1" if ("" eq "$EnvVar1");
> my $EnvVar2="DefaultValue2" if ("" eq "$EnvVar2");
> my $Var3 = "$EnvVar1 -- $EnvVar2";
>
> When I run it, the perl interperter complains about "Use of
> uninitialized value in concatenation" on the "Var3" line (the last
> line.
>
> Did I mess things up by putting the "my" on the "EnvVar1" and
> "EnvVar2" lines -- these variables should be defined on the "use Env"
> line, right?
As I read "perldoc Env" I would say that your use Env line is declaring
those two values for you, so your first two my's are redundant. That
said, I don't understand why Perl would throw that warning.
> If you were to re-write this whole section, how would you do it?
Assuming 0 is never a legitimate value for those two environment
variables, I'd do this:
#!/usr/bin/perl -w
use Env qw(EnvVar1 EnvVar2);
$EnvVar1 ||= "DefaultValue1";
$EnvVar2 ||= "DefaultValue2";
my $Var3 = "$EnvVar1 -- $EnvVar2";
Actually, I wouldn't 'use Env' at all. That's just a "shortcut" for
Perl's built-in %ENV. I'd do this:
#!/usr/bin/perl -w
$ENV{Var1} ||= "DefaultValue1";
$ENV{Var2} ||= "DefaultValue2";
my $Var3 = "$ENV{Var1} -- $ENV{Var2}";
HTH,
j
From jay at jays.net Fri Sep 2 05:13:57 2005
From: jay at jays.net (Jay Hannah)
Date: Fri, 2 Sep 2005 07:13:57 -0500
Subject: [Omaha.pm] Quick Bail
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B0301BC31@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B0301BC31@exchange2k3.omnihotels.net>
Message-ID:
On Sep 1, 2005, at 5:22 PM, Kenneth Thompson wrote:
> A short one-liner to keep a script from executing more than one at a
> time (say a long running script kicked off from cron every minute that
> runs more than a minute occasionally...
> ?
> my @ps = `ps -ef | grep $0 | grep -v grep`; exit if ( @ps > 1);
I like it! Quick and dirty! -grin-
> and a more advanced version...
> ?
> my @procs = grep /perl .*invan\.pl/, `ps axw`;?
> if (@procs > 1) {?
> ?? unless ($ENV{USER} eq "jhannah") {? # Hopefully that dork knows
> what he's doing, so let him do whatever.?
> ????? die "Looks like I'm already running. I refuse to run on top of
> myself.\n @procs";
> ?? }
> }?
-laugh- Not sure I'd call my hack there more advanced. But, it is
handy in that it throws a printed list of the procs that were already
running, and lets me, specifically, shoot myself in the foot when I
want to. -grin-
For serious applications I've used Proc::ProcessTable before:
http://search.cpan.org/~durist/Proc-ProcessTable-0.40/ProcessTable.pm
I assume it's more portable than `ps -ef`, and is great when you care
about PIDs, PPIDs, memory utilization, etc.
Looks like there's tons of process control stuff on CPAN:
http://search.cpan.org/search?query=proc&mode=all
Grin,
j
From dan at linder.org Fri Sep 2 09:33:37 2005
From: dan at linder.org (Daniel Linder)
Date: Fri, 2 Sep 2005 11:33:37 -0500 (CDT)
Subject: [Omaha.pm] Proper way to test a variable with strict and -w?
In-Reply-To: <7ab5e75bd0986cd0894dbd4c3ab5f8bb@jays.net>
References: <16020.12.160.138.88.1125588930.squirrel@mail.linder.org>
<7ab5e75bd0986cd0894dbd4c3ab5f8bb@jays.net>
Message-ID: <1730.12.160.138.88.1125678817.squirrel@mail.linder.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, September 2, 2005 07:01, Jay Hannah wrote:
> Actually, I wouldn't 'use Env' at all. That's just a
"shortcut" for
> Perl's built-in %ENV. I'd do this:
>
> #!/usr/bin/perl -w
>
> $ENV{Var1} ||= "DefaultValue1";
> $ENV{Var2} ||= "DefaultValue2";
> my $Var3 = "$ENV{Var1} -- $ENV{Var2}";
Since the "||" operator is more well known with my team, I ended
up using this:
my $Var1 = $Env{Var1} || "DefaultValue1";
Dan
- - - - -
"Wait for that wisest of all counselors, time." -- Pericles
"I do not fear computer, I fear the lack of them." -- Isaac
Asimov
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDGH7hsrDMR0/em2gRAr6UAKCmiSml7lQc2jIf3lFTNkF+U9H3nQCgrvsU
j+IxGQzJp4qgp//cYiPXRaA=
=Hegb
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050902/7ecb11cb/attachment.html
From dan at linder.org Fri Sep 2 09:37:12 2005
From: dan at linder.org (Daniel Linder)
Date: Fri, 2 Sep 2005 11:37:12 -0500 (CDT)
Subject: [Omaha.pm] Proper way to test a variable with strict and -w?
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B0301BC49@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B0301BC49@exchange2k3.omnihotels.net>
Message-ID: <2280.12.160.138.88.1125679032.squirrel@mail.linder.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, September 1, 2005 17:37, Kenneth Thompson wrote:
>>Ah, this could be a good use of the
"//" instead of "||", right?
>Could be-
what does “// “ do?
I believe someone mentioned that it is a "smarter" form of
"||" that is due to be included in a future release of
Perl.? In this example, if the value to the left of "//" is
a value, zero or empty string, then the value the "//" operator
returns will be the value/zero/empty string respectively.? If the
variable is not defined (or possibly "NaN" or other error
values), then it will return the value on the right side of the
"//" operator.
I haven't seen a writeup of this new functions planned implementation
rules so this might be way off.
Dan
- - - - -
"Wait for that wisest of all counselors, time." -- Pericles
"I do not fear computer, I fear the lack of them." -- Isaac
Asimov
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDGH+3srDMR0/em2gRAqT2AKDH0N1uuOfnMX6r7xoT9FDiEygFpgCfVMh9
+njPrCHewOxANFXUMfGMTzE=
=s59N
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050902/7d00813b/attachment-0001.html
From jay at jays.net Sat Sep 3 05:19:02 2005
From: jay at jays.net (Jay Hannah)
Date: Sat, 3 Sep 2005 07:19:02 -0500
Subject: [Omaha.pm] Proper way to test a variable with strict and -w?
In-Reply-To: <2280.12.160.138.88.1125679032.squirrel@mail.linder.org>
References: <29AB736ABCE5C745ABF9C93B02F2C27B0301BC49@exchange2k3.omnihotels.net>
<2280.12.160.138.88.1125679032.squirrel@mail.linder.org>
Message-ID:
On Sep 2, 2005, at 11:37 AM, Daniel Linder wrote:
> >Could be- what does ?// ? do?
>
> I believe someone mentioned that it is a "smarter" form of "||" that
> is due to be included in a future release of Perl.? In this example,
> if the value to the left of "//" is a value, zero or empty string,
> then the value the "//" operator returns will be the value/zero/empty
> string respectively.? If the variable is not defined (or possibly
> "NaN" or other error values), then it will return the value on the
> right side of the "//" operator.
>
> I haven't seen a writeup of this new functions planned implementation
> rules so this might be way off.
http://www.perl.com/pub/a/2004/03/18/synopsis3.html
"Binary // is just like ||, except that it tests its left side for
definedness instead of truth. There is a low-precedence form, too:
err."
j
From jhannah at omnihotels.com Wed Sep 7 07:40:51 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 7 Sep 2005 09:40:51 -0500
Subject: [Omaha.pm] Bundle::Omni
Message-ID: <200509071440.j87Ee0ic008528@omares-email.omnihotels.com>
Sweet... I defined my first CPAN bundle thanks to these instructions:
http://www.cpan.org/misc/cpan-faq.html#How_make_bundle
Now instead of installing a million things we can just do this:
# perl -MCPAN -e 'install Bundle::Omni'
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Database was generated on Tue, 06 Sep 2005 08:58:48 GMT
Bit::Vector is up to date.
CGI is up to date.
Class::Date is up to date.
Convert::EBCDIC is up to date.
Date::Calc is up to date.
DBI is up to date.
DBD::Informix is up to date.
DBD::Sybase is up to date.
Email::Valid is up to date.
ExtUtils::AutoInstall is up to date.
IPC::ShareLite is up to date.
Log::Log4perl is up to date.
MIME::Lite is up to date.
Template is up to date.
Test::More is up to date.
Test::Pod is up to date.
Text::Format is up to date.
XML::Parser is up to date.
XML::Twig is up to date.
And all those classes dependencies are also installed... Wheee!
Anyone use CPANPLUS? Is that considered the cool way yet?
j
From jhannah at omnihotels.com Fri Sep 9 12:27:40 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Fri, 9 Sep 2005 14:27:40 -0500
Subject: [Omaha.pm] doh
Message-ID: <200509091925.j89JPvic026107@omares-email.omnihotels.com>
What's wrong w/ this code?
$sga = "78B";
$sga ||= $state_cookie->{sga};
Grin,
j
From dan at linder.org Fri Sep 9 12:41:50 2005
From: dan at linder.org (Daniel Linder)
Date: Fri, 9 Sep 2005 14:41:50 -0500 (CDT)
Subject: [Omaha.pm] doh
In-Reply-To: <200509091925.j89JPvic026107@omares-email.omnihotels.com>
References: <200509091925.j89JPvic026107@omares-email.omnihotels.com>
Message-ID: <61891.12.160.138.88.1126294910.squirrel@mail.linder.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, September 9, 2005 14:27, Jay Hannah wrote:
> What's wrong w/ this code?
> $sga = "78B";
> $sga ||= $state_cookie->{sga};
Did you mean:
$sga ||= $state_cookie->{$sga};
???
(Of course not knowing what $state_cookie is doesn't help...)
Dan
- - - - -
"Wait for that wisest of all counselors, time." -- Pericles
"I do not fear computer, I fear the lack of them." -- Isaac
Asimov
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDIeV+srDMR0/em2gRAqDaAKChFME5FN9DXqNokxk6ICQC9mRAqgCeOXS3
ifjtTpJoY8EDjv88g3OguHM=
=SjhM
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050909/ee8bf226/attachment.html
From jay at jays.net Fri Sep 9 21:11:04 2005
From: jay at jays.net (Jay Hannah)
Date: Fri, 9 Sep 2005 23:11:04 -0500
Subject: [Omaha.pm] doh
In-Reply-To: <61891.12.160.138.88.1126294910.squirrel@mail.linder.org>
References: <200509091925.j89JPvic026107@omares-email.omnihotels.com>
<61891.12.160.138.88.1126294910.squirrel@mail.linder.org>
Message-ID: <5488c6108d8720834abf859fa37b8957@jays.net>
On Sep 9, 2005, at 2:41 PM, Daniel Linder wrote:
> On Fri, September 9, 2005 14:27, Jay Hannah wrote:
> > What's wrong w/ this code?
> > $sga = "78B";
> > $sga ||= $state_cookie->{sga};
>
> Did you mean:
> $sga ||= $state_cookie->{$sga};
> ???
>
> (Of course not knowing what $state_cookie is doesn't help...)
I was fishing for the fact that in my code ||= will never do anything
because $sga will always be defined because I just got done setting it
to a string.
Doh! -grin-
j
From jhannah at omnihotels.com Wed Sep 14 07:46:28 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 14 Sep 2005 09:46:28 -0500
Subject: [Omaha.pm] map: make a hash from an array
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC28@exchange2k3.omnihotels.net>
Given an array:
my @keepthese = qw(
account_code adult_qty arrival_date child_qty depart_date gds_sys
group_code lang_code prop prune_level rate_code rate_type room_type
seamless_bk_code sga
);
Here's the slow way to make a hash out of it:
my %keepthese;
foreach (@keepthese) {
$keepthese{$_} = 1;
}
Here's a faster way:
my %keepthese = map { $_, 1 } @keepthese;
HTH,
j
From jhannah at omnihotels.com Wed Sep 14 07:49:34 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 14 Sep 2005 09:49:34 -0500
Subject: [Omaha.pm] Reminder: Mtg tomorrow (Thr)
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC29@exchange2k3.omnihotels.net>
Don't forget our mtg tomorrow night!
http://omaha.pm.org
Hey Jay S.: Are those 80 racks still in the middle of your store? -grin-
Maybe this should be a social meeting -- let's meet up at the regular
place then ditch and get dinner instead?
j
mobile: 578-3976
From andy at petdance.com Wed Sep 14 11:55:46 2005
From: andy at petdance.com (Andy Lester)
Date: Wed, 14 Sep 2005 13:55:46 -0500
Subject: [Omaha.pm] map: make a hash from an array
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC28@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC28@exchange2k3.omnihotels.net>
Message-ID: <20050914185546.GA4995@petdance.com>
On Wed, Sep 14, 2005 at 09:46:28AM -0500, Jay Hannah (jhannah at omnihotels.com) wrote:
> Here's a faster way:
>
> my %keepthese = map { $_, 1 } @keepthese;
If you only care about the existence of a given element, and don't care
if it gets a value, you can assign to a hash slice:
my %hash;
@hash{@keepthese} = ();
If you need them to have a value, you can do this:
my %hash;
@hash{@keepthese} = (1) x @keepthese;
Finally, if you're just checking for existence, and don't really need
to worry about speed, you can do
my $exists = grep { $_ eq $searching_for }, @keepthese;
xoxo,
Andy
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From jay at jays.net Thu Sep 15 04:40:39 2005
From: jay at jays.net (Jay Hannah)
Date: Thu, 15 Sep 2005 06:40:39 -0500
Subject: [Omaha.pm] map: make a hash from an array
In-Reply-To: <20050914185546.GA4995@petdance.com>
References: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC28@exchange2k3.omnihotels.net>
<20050914185546.GA4995@petdance.com>
Message-ID:
On Sep 14, 2005, at 1:55 PM, Andy Lester wrote:
> On Wed, Sep 14, 2005 at 09:46:28AM -0500, Jay Hannah
> (jhannah at omnihotels.com) wrote:
>> Here's a faster way:
>>
>> my %keepthese = map { $_, 1 } @keepthese;
>
> If you only care about the existence of a given element, and don't care
> if it gets a value, you can assign to a hash slice:
>
> my %hash;
> @hash{@keepthese} = ();
>
> If you need them to have a value, you can do this:
>
> my %hash;
> @hash{@keepthese} = (1) x @keepthese;
I've never used hash slices... I'll have to do some reading.
> Finally, if you're just checking for existence, and don't really need
> to worry about speed, you can do
>
> my $exists = grep { $_ eq $searching_for }, @keepthese;
Usually when I'm building a hash from an array I'm doing it for the
sake of speed. My theory is that when I have unique keys building and
then performing multiple lookups against a large hash is faster than
performing multiple greps against a large array.
I use grep when I'm only doing 1 or 2 lookups against an array. My
theory there being that its more efficient to do that than to build a
hash that's only going to be used once.
(You need to remove the "," from your grep statement, btw. It's a
syntax error.)
Thanks!
j
From jay at jays.net Thu Sep 15 04:58:14 2005
From: jay at jays.net (Jay Hannah)
Date: Thu, 15 Sep 2005 06:58:14 -0500
Subject: [Omaha.pm] [pm_groups] What do you do with free books?
In-Reply-To: <4321ED1D.1000900@mit.edu>
References: <4321ED1D.1000900@mit.edu>
Message-ID:
On Sep 9, 2005, at 3:14 PM, Linda L. Julien wrote:
> However, I'm curious about what other groups do with these books when
> they receive them.
>
> Do you keep them in a group library? If so, how do you arrange access
> for the members, and/or ensure that the books come back when people
> borrow them?
We have 12 books. (Thanks O'Reilly! Yay!) They're all heavily labeled
the property of Omaha Perl Mongers. We keep them at the store where our
meetings are held. They're tracked in an online database (w/ a PHP
interface! gasp! -grin-) where people, theoretically, check them out
and then eventually return them:
http://library.reboottheuser.com/login.php
I have a couple books checked out personally, they're at my work. If
anyone wanted them I'd be happy to bring them to meetings and hand them
over.
> How effective to you think your strategy is? Does it encourage group
> membership? Group participation? Etc.
No one seems to care. No one except me has ever checked out a book, or
expressed any interest in borrowing them. A couple of years ago,
before the tracking database, random people took 3 or 4 books home. I
didn't track it. I think 2 or 3 of them came back eventually. It's a
good idea to always keep some sort of list/record, regardless of how
informal, otherwise everyone involved will likely completely forget and
the book will go unused forever on some shelf somewhere.
No one has ever taken the time to write a review. Personally, that's
not my thing and apparently it isn't popular among other Omaha Perl
geeks either. -grin- So far O'Reilly doesn't seem to care. I post
their banner ad, they send a book. I've never taken them up on any
review offers since I'm not interested in writing one.
No book requests have come from other members of our group, so I've
ordered the books I want/use/read.
Cheers,
j
Omaha.pm
a sleepy little group
From Scott.L.Miller at hp.com Thu Sep 15 09:02:32 2005
From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks))
Date: Thu, 15 Sep 2005 11:02:32 -0500
Subject: [Omaha.pm] map: make a hash from an array
Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E988@omaexc11.americas.cpqcorp.net>
Just make sure you benchmark your resulting code. Building the hash
from an array is fairly expensive in itself...
Is it possible that building the hash in the first place, rather than an
array is the more correct thing to do?
-Scott
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Jay Hannah
Sent: Thursday, September 15, 2005 6:41 AM
To: Perl Mongers of Omaha, Nebraska USA
Subject: Re: [Omaha.pm] map: make a hash from an array
On Sep 14, 2005, at 1:55 PM, Andy Lester wrote:
> On Wed, Sep 14, 2005 at 09:46:28AM -0500, Jay Hannah
> (jhannah at omnihotels.com) wrote:
>> Here's a faster way:
>>
>> my %keepthese = map { $_, 1 } @keepthese;
>
> If you only care about the existence of a given element, and don't
care
> if it gets a value, you can assign to a hash slice:
>
> my %hash;
> @hash{@keepthese} = ();
>
> If you need them to have a value, you can do this:
>
> my %hash;
> @hash{@keepthese} = (1) x @keepthese;
I've never used hash slices... I'll have to do some reading.
> Finally, if you're just checking for existence, and don't really need
> to worry about speed, you can do
>
> my $exists = grep { $_ eq $searching_for }, @keepthese;
Usually when I'm building a hash from an array I'm doing it for the
sake of speed. My theory is that when I have unique keys building and
then performing multiple lookups against a large hash is faster than
performing multiple greps against a large array.
I use grep when I'm only doing 1 or 2 lookups against an array. My
theory there being that its more efficient to do that than to build a
hash that's only going to be used once.
(You need to remove the "," from your grep statement, btw. It's a
syntax error.)
Thanks!
j
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From Scott.L.Miller at hp.com Thu Sep 15 09:09:20 2005
From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks))
Date: Thu, 15 Sep 2005 11:09:20 -0500
Subject: [Omaha.pm] [pm_groups] What do you do with free books?
Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E989@omaexc11.americas.cpqcorp.net>
A truthful and humorous reply, thanks for sharing :-)
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Jay Hannah
Sent: Thursday, September 15, 2005 6:58 AM
To: PM Groups
Cc: Omaha Perl Mongers
Subject: Re: [Omaha.pm] [pm_groups] What do you do with free books?
On Sep 9, 2005, at 3:14 PM, Linda L. Julien wrote:
> However, I'm curious about what other groups do with these books when
> they receive them.
>
> Do you keep them in a group library? If so, how do you arrange access
> for the members, and/or ensure that the books come back when people
> borrow them?
We have 12 books. (Thanks O'Reilly! Yay!) They're all heavily labeled
the property of Omaha Perl Mongers. We keep them at the store where our
meetings are held. They're tracked in an online database (w/ a PHP
interface! gasp! -grin-) where people, theoretically, check them out
and then eventually return them:
http://library.reboottheuser.com/login.php
I have a couple books checked out personally, they're at my work. If
anyone wanted them I'd be happy to bring them to meetings and hand them
over.
> How effective to you think your strategy is? Does it encourage group
> membership? Group participation? Etc.
No one seems to care. No one except me has ever checked out a book, or
expressed any interest in borrowing them. A couple of years ago,
before the tracking database, random people took 3 or 4 books home. I
didn't track it. I think 2 or 3 of them came back eventually. It's a
good idea to always keep some sort of list/record, regardless of how
informal, otherwise everyone involved will likely completely forget and
the book will go unused forever on some shelf somewhere.
No one has ever taken the time to write a review. Personally, that's
not my thing and apparently it isn't popular among other Omaha Perl
geeks either. -grin- So far O'Reilly doesn't seem to care. I post
their banner ad, they send a book. I've never taken them up on any
review offers since I'm not interested in writing one.
No book requests have come from other members of our group, so I've
ordered the books I want/use/read.
Cheers,
j
Omaha.pm
a sleepy little group
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From andy at petdance.com Thu Sep 15 09:11:48 2005
From: andy at petdance.com (Andy Lester)
Date: Thu, 15 Sep 2005 11:11:48 -0500
Subject: [Omaha.pm] map: make a hash from an array
In-Reply-To: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E988@omaexc11.americas.cpqcorp.net>
References: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E988@omaexc11.americas.cpqcorp.net>
Message-ID: <20050915161148.GA18042@petdance.com>
On Thu, Sep 15, 2005 at 11:02:32AM -0500, Miller, Scott L (Omaha Networks) (Scott.L.Miller at hp.com) wrote:
> Just make sure you benchmark your resulting code. Building the hash
> from an array is fairly expensive in itself...
And make sure that you actually care about speed. We as programmers
often spend valuable programmer time optimizing cheap computer time,
when there's not really a need to do so.
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From jay at jays.net Thu Sep 15 09:30:26 2005
From: jay at jays.net (Jay Hannah)
Date: Thu, 15 Sep 2005 11:30:26 -0500
Subject: [Omaha.pm] OT: Free wireless @ Zio's 80th & Dodge
Message-ID: <290580cb197db6d7650ae3307351b716@jays.net>
Sweet! I'm typing this an another free wi-fi connection!
I'll have to figure out how to add it here:
http://nebraska.metrofreefi.com/city/Omaha.htm
And how to get Google Maps to do that fancy stuff for me too! -grin-
j
From jhannah at omnihotels.com Thu Sep 15 11:28:04 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Thu, 15 Sep 2005 13:28:04 -0500
Subject: [Omaha.pm] TT fun!
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC3A@exchange2k3.omnihotels.net>
(1) Oops! In Template Toolkit this fails:
[% lang_para1 = "Thank you $guest_name for booking ...snip... you at
$prop_name." %]
Because TT sees $prop_name. as an attempt to envoke a method on the
prop_name object. What method? The undef method perhaps? Dunno, but I
had to change it to this:
[% lang_para1 = "Thank you $guest_name for booking ...snip... you at
${prop_name}." %]
I hadn't seen that pattern before.
(2) TT + Date::Class + our custom OO business layer (Res) + our
multi-language hackery = FUN!!
HTML-mode snippet from a TT template:
$lang_text1
${Res.get_arrival_date('obj').format('%m-%b-%Y (%a)')}
$lang_text2 ${Res.get_depart_date(
'obj').format('%m-%b-%Y (%a)')}
Output:
Arrival: 09-Sep-2005 (Thu)
Depart: 09-Sep-2005 (Fri)
Mwoo ha ha ha ha hah ah ahaha,
j
From jhannah at omnihotels.com Thu Sep 15 13:58:09 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Thu, 15 Sep 2005 15:58:09 -0500
Subject: [Omaha.pm] Hey OO Perl 5: Do my base classes thing plus my thing
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC3B@exchange2k3.omnihotels.net>
Project:
Build 2 classes, A and B. B inherits to A. B->go() should do whatever
A->go() does plus some other stuff.
Solution:
$ cat j.pl
use vars qw( @ISA );
package A;
sub go {
print "Perl "
}
package B;
@ISA = ("A");
sub new { return bless {} }
sub go {
my ($self) = @_;
$self->SUPER::go;
print "Rulz!\n";
}
package main;
my $obj = B->new();
$obj->go;
In action:
$ perl j.pl
Perl Rulz!
HTH,
j
From jay at jays.net Thu Sep 15 14:17:28 2005
From: jay at jays.net (Jay Hannah)
Date: Thu, 15 Sep 2005 16:17:28 -0500
Subject: [Omaha.pm] map: make a hash from an array
In-Reply-To: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E988@omaexc11.americas.cpqcorp.net>
References: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E988@omaexc11.americas.cpqcorp.net>
Message-ID:
On Sep 15, 2005, at 11:02 AM, Miller, Scott L (Omaha Networks) wrote:
> Is it possible that building the hash in the first place, rather than
> an
> array is the more correct thing to do?
I think you and Andy are dead on. Have all the tools in your toolbox,
and do what the right thing probably is each time. In the probably rare
case that speed is critical, benchmark each strategy.
I'm sure benchmarking would show wildly different results per strategy
comparing, for instance, 3 scans of 1M keys vs. 1M scans of 3 keys.
j
From jay at jays.net Thu Sep 15 16:22:01 2005
From: jay at jays.net (Jay Hannah)
Date: Thu, 15 Sep 2005 18:22:01 -0500
Subject: [Omaha.pm] Perl Monger group maps?
Message-ID:
Oooo!! Project!? Now that google.maps.com is global and not just US...
Google Maps API + Perl Mongers XML file = revival of Perl Monger group
maps?!
Google Maps API:
http://www.google.com/apis/maps/
These maps have been broken for a couple years:
http://www.pm.org/groups/north_america.html
Ooo!! Feasible? I haven't read the API docs yet.
j
From jay at jays.net Thu Sep 15 16:25:02 2005
From: jay at jays.net (Jay Hannah)
Date: Thu, 15 Sep 2005 18:25:02 -0500
Subject: [Omaha.pm] TT fun!
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC3A@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC3A@exchange2k3.omnihotels.net>
Message-ID:
On Sep 15, 2005, at 1:28 PM, Jay Hannah wrote:
> (1) Oops! In Template Toolkit this fails:
>
> [% lang_para1 = "Thank you $guest_name for booking ...snip... you at
> $prop_name." %]
Sorry about the line wrap. My work email moved onto Exchange, and I
can't get this ver not to wrap. (Or send emails at all right now, for
that matter. -sigh-)
j
from my rogue, underground laptop email client that works
From omaha.pm.knitter at recursor.net Thu Sep 15 20:43:05 2005
From: omaha.pm.knitter at recursor.net (omaha.pm.knitter@recursor.net)
Date: Thu, 15 Sep 2005 22:43:05 -0500
Subject: [Omaha.pm] Perl Monger group maps?
In-Reply-To:
Message-ID: <3.0.6.32.20050915224305.007c2100@pop.radiks.net>
At 06:22 PM 9/15/2005 -0500, you wrote:
>Oooo!! Project!? Now that google.maps.com is global and not just US...
On a related note, one of the coolest Google Maps hacks yet...
http://www.mailinator.com/mailinator/map.html
-Sidney
From jay at jays.net Sat Sep 17 08:42:30 2005
From: jay at jays.net (Jay Hannah)
Date: Sat, 17 Sep 2005 10:42:30 -0500
Subject: [Omaha.pm] Perl Monger group map!
In-Reply-To:
References:
Message-ID:
Damn, that was easy! about 45 min of effort kicked this out:
http://jays.net/google_maps/index2.html
j
Omaha.pm
From jay at jays.net Mon Sep 19 19:23:56 2005
From: jay at jays.net (Jay Hannah)
Date: Mon, 19 Sep 2005 21:23:56 -0500
Subject: [Omaha.pm] Fwd: Newsletter from O'Reilly UG Program, September 14
Message-ID:
Snipped for Perl-only content.
Thankfully I haven't done much UTF-8 stuff yet. -grin-
j
***Perl Internationalization and Haskell:
An Interview with Autrijus Tang
Self-proclaimed "Net activist, artist, and anarchist" Autrijus Tang will
be a featured speaker at this October's EuroOSCON. He discusses one of
his conference topics--Haskell--extensively in this interview with
O'Reilly Network. Autrijus also covers Gettext bindings, Perl
internationalization tools, CPAN, and more in this wide-ranging
conversation.
http://www.perl.com/pub/a/2005/09/08/autrijus-tang.html
From jhannah at omnihotels.com Tue Sep 20 08:15:02 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Tue, 20 Sep 2005 10:15:02 -0500
Subject: [Omaha.pm] Ow!! || bit me
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC70@exchange2k3.omnihotels.net>
Code:
$res->set_child_qty ($cookie->{child_qty} ||
$q->param('child_qty'));
When:
$cookie->{child_qty} is 0
and
$q->param('child_qty') is undef
Then:
I'm running $res->set_child_qty(undef)
which is NOT what I wanted.
Doh! I need Perl 6's // operator! -grin-
New code:
if (defined $cookie->{child_qty}) {
$res->set_child_qty($cookie->{child_qty})
} else {
$res->set_child_qty($q->param('child_qty'))
}
Eww... Long and ugly. But it does do what I want and 0 is a valid value
for child_qty.
$live && $learn++;
j
From Scott.L.Miller at hp.com Tue Sep 20 14:06:33 2005
From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks))
Date: Tue, 20 Sep 2005 16:06:33 -0500
Subject: [Omaha.pm] Ow!! || bit me
Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E991@omaexc11.americas.cpqcorp.net>
What if both are undef? Given the snippet so far, that would seem to be
a valid possibility...
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Jay Hannah
Sent: Tuesday, September 20, 2005 10:15 AM
To: omaha-pm at pm.org
Subject: [Omaha.pm] Ow!! || bit me
Code:
$res->set_child_qty ($cookie->{child_qty} ||
$q->param('child_qty'));
When:
$cookie->{child_qty} is 0
and
$q->param('child_qty') is undef
Then:
I'm running $res->set_child_qty(undef)
which is NOT what I wanted.
Doh! I need Perl 6's // operator! -grin-
New code:
if (defined $cookie->{child_qty}) {
$res->set_child_qty($cookie->{child_qty})
} else {
$res->set_child_qty($q->param('child_qty'))
}
Eww... Long and ugly. But it does do what I want and 0 is a valid value
for child_qty.
$live && $learn++;
j
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From jay at jays.net Tue Sep 20 19:55:50 2005
From: jay at jays.net (Jay Hannah)
Date: Tue, 20 Sep 2005 21:55:50 -0500
Subject: [Omaha.pm] Ow!! || bit me
In-Reply-To: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E991@omaexc11.americas.cpqcorp.net>
References: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E991@omaexc11.americas.cpqcorp.net>
Message-ID: <7e6c9809084bf18e8bdd21833a1e0587@jays.net>
> Code:
>
> $res->set_child_qty ($cookie->{child_qty} ||
> $q->param('child_qty'));
> New code:
>
> if (defined $cookie->{child_qty}) {
> $res->set_child_qty($cookie->{child_qty})
> } else {
> $res->set_child_qty($q->param('child_qty'))
> }
On Sep 20, 2005, at 4:06 PM, Miller, Scott L (Omaha Networks) wrote:
> What if both are undef? Given the snippet so far, that would seem to
> be
> a valid possibility...
Both would have executed $res->set_child_qty(undef).
j
From bob at mccoy.net Wed Sep 21 06:15:44 2005
From: bob at mccoy.net (Bob McCoy)
Date: Wed, 21 Sep 2005 08:15:44 -0500
Subject: [Omaha.pm] Private library
Message-ID: <20050921131542.QVXA8829.eastrmmtao01.cox.net@bobnet03>
I need some help installing a private library. I want to use the
Cyrpt::Blowfish.pm
(http://search.cpan.org/~dparis/Crypt-Blowfish-2.09/Blowfish.pm) on the
UNO Phoenix system. However, I don't have admin right to install the
library. So ...
1. What is the appropriate make command line to direct the installation
to a private directory, e.g., /home/bob/lib? This is the one I'm really
stumped on.
2. Is "use lib '/home/bob/lib';" sufficient to get it then in the @INC
array for searching?
Bob
From mat at phpconsulting.com Wed Sep 21 07:20:34 2005
From: mat at phpconsulting.com (Mat Caughron)
Date: Wed, 21 Sep 2005 09:20:34 -0500 (CDT)
Subject: [Omaha.pm] Private library (FAQ suggests PERL5LIB shell var)
In-Reply-To: <20050921131542.QVXA8829.eastrmmtao01.cox.net@bobnet03>
References: <20050921131542.QVXA8829.eastrmmtao01.cox.net@bobnet03>
Message-ID:
Hi Bob:
http://www.cpan.org/misc/cpan-faq.html#How_use_private
There are several ways to use modules installed in private directories:
setenv PERL5LIB /path/to/module
sets the environment variable PERL5LIB.
use lib qw(/path/to/module);
used at the top of your script tells perl where to find your module.
perl -I/path/to/module
All of these will append /path/to/module to @INC.
Mat
On Wed, 21 Sep 2005, Bob McCoy wrote:
> I need some help installing a private library. I want to use the
> Cyrpt::Blowfish.pm
> (http://search.cpan.org/~dparis/Crypt-Blowfish-2.09/Blowfish.pm) on the
> UNO Phoenix system. However, I don't have admin right to install the
> library. So ...
>
> 1. What is the appropriate make command line to direct the installation
> to a private directory, e.g., /home/bob/lib? This is the one I'm really
> stumped on.
>
> 2. Is "use lib '/home/bob/lib';" sufficient to get it then in the @INC
> array for searching?
>
> Bob
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>
From bob at mccoy.net Wed Sep 21 06:57:57 2005
From: bob at mccoy.net (Bob McCoy)
Date: Wed, 21 Sep 2005 08:57:57 -0500
Subject: [Omaha.pm] Private library
In-Reply-To:
Message-ID: <20050921135755.OTHB20572.centrmmtao06.cox.net@bobnet03>
Thanks, Mat. I kind of figured that's how I could use it once it was
installed. However, the real issue I'm having is trying to figure out
how to tell the makefile where to install it. The generic command is
"make install". And Ilve been through the Makefile several times and
haven't figured out what params I need to pass in order for it to
install it someplace that I have permissions to.
-----Original Message-----
Hi Bob:
http://www.cpan.org/misc/cpan-faq.html#How_use_private
There are several ways to use modules installed in private directories:
setenv PERL5LIB /path/to/module
sets the environment variable PERL5LIB.
use lib qw(/path/to/module);
used at the top of your script tells perl where to find your
module.
perl -I/path/to/module
All of these will append /path/to/module to @INC.
Mat
On Wed, 21 Sep 2005, Bob McCoy wrote:
> I need some help installing a private library. I want to use the
> Cyrpt::Blowfish.pm
> (http://search.cpan.org/~dparis/Crypt-Blowfish-2.09/Blowfish.pm) on
the
> UNO Phoenix system. However, I don't have admin right to install the
> library. So ...
>
> 1. What is the appropriate make command line to direct the
installation
> to a private directory, e.g., /home/bob/lib? This is the one I'm
really
> stumped on.
>
> 2. Is "use lib '/home/bob/lib';" sufficient to get it then in the
@INC
> array for searching?
>
> Bob
From mat at phpconsulting.com Wed Sep 21 07:35:50 2005
From: mat at phpconsulting.com (Mat Caughron)
Date: Wed, 21 Sep 2005 09:35:50 -0500 (CDT)
Subject: [Omaha.pm] Private library
In-Reply-To: <20050921135755.OTHB20572.centrmmtao06.cox.net@bobnet03>
References: <20050921135755.OTHB20572.centrmmtao06.cox.net@bobnet03>
Message-ID:
When making the module, perhaps:
perl Makefile.PL PREFIX=/home/bob/lib
Mat
On Wed, 21 Sep 2005, Bob McCoy wrote:
> Thanks, Mat. I kind of figured that's how I could use it once it was
> installed. However, the real issue I'm having is trying to figure out
> how to tell the makefile where to install it. The generic command is
> "make install". And Ilve been through the Makefile several times and
> haven't figured out what params I need to pass in order for it to
> install it someplace that I have permissions to.
>
> -----Original Message-----
>
> Hi Bob:
>
>
> http://www.cpan.org/misc/cpan-faq.html#How_use_private
>
> There are several ways to use modules installed in private directories:
>
> setenv PERL5LIB /path/to/module
> sets the environment variable PERL5LIB.
>
> use lib qw(/path/to/module);
> used at the top of your script tells perl where to find your
> module.
>
> perl -I/path/to/module
>
> All of these will append /path/to/module to @INC.
>
> Mat
>
>
>
>
> On Wed, 21 Sep 2005, Bob McCoy wrote:
> > I need some help installing a private library. I want to use the
> > Cyrpt::Blowfish.pm
> > (http://search.cpan.org/~dparis/Crypt-Blowfish-2.09/Blowfish.pm) on
> the
> > UNO Phoenix system. However, I don't have admin right to install the
> > library. So ...
> >
> > 1. What is the appropriate make command line to direct the
> installation
> > to a private directory, e.g., /home/bob/lib? This is the one I'm
> really
> > stumped on.
> >
> > 2. Is "use lib '/home/bob/lib';" sufficient to get it then in the
> @INC
> > array for searching?
> >
> > Bob
>
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>
From bob at mccoy.net Wed Sep 21 07:01:55 2005
From: bob at mccoy.net (Bob McCoy)
Date: Wed, 21 Sep 2005 09:01:55 -0500
Subject: [Omaha.pm] Private library -- Disregard
In-Reply-To: <20050921135755.OTHB20572.centrmmtao06.cox.net@bobnet03>
Message-ID: <20050921140153.PTQJ24048.eastrmmtao05.cox.net@bobnet03>
OK, Mat. Right above "How to use Private" was "How to install Private"
http://www.cpan.org/misc/cpan-faq.html#How_install_private
Once again, I should have RTM. Thanks, Bob.
-----Original Message-----
Thanks, Mat. I kind of figured that's how I could use it once it was
installed. However, the real issue I'm having is trying to figure out
how to tell the makefile where to install it. The generic command is
"make install". And Ilve been through the Makefile several times and
haven't figured out what params I need to pass in order for it to
install it someplace that I have permissions to.
-----Original Message-----
Hi Bob:
http://www.cpan.org/misc/cpan-faq.html#How_use_private
There are several ways to use modules installed in private directories:
setenv PERL5LIB /path/to/module
sets the environment variable PERL5LIB.
use lib qw(/path/to/module);
used at the top of your script tells perl where to find your
module.
perl -I/path/to/module
All of these will append /path/to/module to @INC.
Mat
On Wed, 21 Sep 2005, Bob McCoy wrote:
> I need some help installing a private library. I want to use the
> Cyrpt::Blowfish.pm
> (http://search.cpan.org/~dparis/Crypt-Blowfish-2.09/Blowfish.pm) on
the
> UNO Phoenix system. However, I don't have admin right to install the
> library. So ...
>
> 1. What is the appropriate make command line to direct the
installation
> to a private directory, e.g., /home/bob/lib? This is the one I'm
really
> stumped on.
>
> 2. Is "use lib '/home/bob/lib';" sufficient to get it then in the
@INC
> array for searching?
>
> Bob
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From mat at phpconsulting.com Wed Sep 21 07:54:18 2005
From: mat at phpconsulting.com (Mat Caughron)
Date: Wed, 21 Sep 2005 09:54:18 -0500 (CDT)
Subject: [Omaha.pm] how to build Crypt::Blowfish without root
In-Reply-To: <20050921140153.PTQJ24048.eastrmmtao05.cox.net@bobnet03>
References: <20050921140153.PTQJ24048.eastrmmtao05.cox.net@bobnet03>
Message-ID:
Well, there's a dependency for Crypt-CBC.
Plus, I'm really excellent at beating dead horses. < grin >
So this should do it, complete:
setenv PERL5LIB ~/lib
mkdir ~/lib
cd ~/lib
wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/Crypt-CBC-2.15.tar.gz
tar -zxvf Crypt-CBC-2.15.tar.gz
cd Crypt-CBC-2.15
perl Makefile.PL PREFIX=~/lib LIB=~/lib
make
make test
make install
wget
http://search.cpan.org/CPAN/authors/id/D/DP/DPARIS/Crypt-Blowfish-2.09.tar.gz
tar -zxvf Crypt-Blowfish-2.09.tar.gz
cd ../Crypt-Blowfish-2.09
perl Makefile.PL PREFIX=~/lib LIB=~/lib
make
make test
make install
cd ../
vi test.pl
#!/usr/bin/perl
use Crypt::Blowfish;
my $key = pack("H16", "0123456789ABCDEF"); # min. 8 bytes
my $cipher = new Crypt::Blowfish $key;
my $ciphertext = $cipher->encrypt("plaintex");
print unpack("H16", $ciphertext), "\n";
perl test.pl
ea03e67434315a63
On Wed, 21 Sep 2005, Bob McCoy wrote:
> OK, Mat. Right above "How to use Private" was "How to install Private"
>
> http://www.cpan.org/misc/cpan-faq.html#How_install_private
>
> Once again, I should have RTM. Thanks, Bob.
>
> -----Original Message-----
>
> Thanks, Mat. I kind of figured that's how I could use it once it was
> installed. However, the real issue I'm having is trying to figure out
> how to tell the makefile where to install it. The generic command is
> "make install". And Ilve been through the Makefile several times and
> haven't figured out what params I need to pass in order for it to
> install it someplace that I have permissions to.
>
> -----Original Message-----
>
> Hi Bob:
>
>
> http://www.cpan.org/misc/cpan-faq.html#How_use_private
>
> There are several ways to use modules installed in private directories:
>
> setenv PERL5LIB /path/to/module
> sets the environment variable PERL5LIB.
>
> use lib qw(/path/to/module);
> used at the top of your script tells perl where to find your
> module.
>
> perl -I/path/to/module
>
> All of these will append /path/to/module to @INC.
>
> Mat
>
>
>
>
> On Wed, 21 Sep 2005, Bob McCoy wrote:
> > I need some help installing a private library. I want to use the
> > Cyrpt::Blowfish.pm
> > (http://search.cpan.org/~dparis/Crypt-Blowfish-2.09/Blowfish.pm) on
> the
> > UNO Phoenix system. However, I don't have admin right to install the
> > library. So ...
> >
> > 1. What is the appropriate make command line to direct the
> installation
> > to a private directory, e.g., /home/bob/lib? This is the one I'm
> really
> > stumped on.
> >
> > 2. Is "use lib '/home/bob/lib';" sufficient to get it then in the
> @INC
> > array for searching?
> >
> > Bob
>
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>
From bob at mccoy.net Wed Sep 21 07:46:12 2005
From: bob at mccoy.net (Bob McCoy)
Date: Wed, 21 Sep 2005 09:46:12 -0500
Subject: [Omaha.pm] how to build Crypt::Blowfish without root
In-Reply-To:
Message-ID: <20050921144609.TCRX8829.eastrmmtao01.cox.net@bobnet03>
Mat, You are the man! I'll buy you lunch at the CSF today! Bob.
-----Original Message-----
Well, there's a dependency for Crypt-CBC.
Plus, I'm really excellent at beating dead horses. < grin >
So this should do it, complete:
setenv PERL5LIB ~/lib
mkdir ~/lib
cd ~/lib
wget
http://search.cpan.org/CPAN/authors/id/L/LD/LDS/Crypt-CBC-2.15.tar.gz
tar -zxvf Crypt-CBC-2.15.tar.gz
cd Crypt-CBC-2.15
perl Makefile.PL PREFIX=~/lib LIB=~/lib
make
make test
make install
wget
http://search.cpan.org/CPAN/authors/id/D/DP/DPARIS/Crypt-Blowfish-2.09.t
ar.gz
tar -zxvf Crypt-Blowfish-2.09.tar.gz
cd ../Crypt-Blowfish-2.09
perl Makefile.PL PREFIX=~/lib LIB=~/lib
make
make test
make install
cd ../
vi test.pl
#!/usr/bin/perl
use Crypt::Blowfish;
my $key = pack("H16", "0123456789ABCDEF"); # min. 8 bytes
my $cipher = new Crypt::Blowfish $key;
my $ciphertext = $cipher->encrypt("plaintex");
print unpack("H16", $ciphertext), "\n";
perl test.pl
ea03e67434315a63
On Wed, 21 Sep 2005, Bob McCoy wrote:
> OK, Mat. Right above "How to use Private" was "How to install
Private"
>
> http://www.cpan.org/misc/cpan-faq.html#How_install_private
>
> Once again, I should have RTM. Thanks, Bob.
>
> -----Original Message-----
>
> Thanks, Mat. I kind of figured that's how I could use it once it was
> installed. However, the real issue I'm having is trying to figure out
> how to tell the makefile where to install it. The generic command is
> "make install". And Ilve been through the Makefile several times and
> haven't figured out what params I need to pass in order for it to
> install it someplace that I have permissions to.
>
> -----Original Message-----
>
> Hi Bob:
>
>
> http://www.cpan.org/misc/cpan-faq.html#How_use_private
>
> There are several ways to use modules installed in private
directories:
>
> setenv PERL5LIB /path/to/module
> sets the environment variable PERL5LIB.
>
> use lib qw(/path/to/module);
> used at the top of your script tells perl where to find your
> module.
>
> perl -I/path/to/module
>
> All of these will append /path/to/module to @INC.
>
> Mat
>
>
>
>
> On Wed, 21 Sep 2005, Bob McCoy wrote:
> > I need some help installing a private library. I want to use the
> > Cyrpt::Blowfish.pm
> > (http://search.cpan.org/~dparis/Crypt-Blowfish-2.09/Blowfish.pm) on
> the
> > UNO Phoenix system. However, I don't have admin right to install
the
> > library. So ...
> >
> > 1. What is the appropriate make command line to direct the
> installation
> > to a private directory, e.g., /home/bob/lib? This is the one I'm
> really
> > stumped on.
> >
> > 2. Is "use lib '/home/bob/lib';" sufficient to get it then in the
> @INC
> > array for searching?
> >
> > Bob
From jhannah at omnihotels.com Wed Sep 21 10:47:15 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 21 Sep 2005 12:47:15 -0500
Subject: [Omaha.pm] Chaining a method (called "init")
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC7B@exchange2k3.omnihotels.net>
This is just a sanity check that chaining methods works the way I
thought it did.
---------------------------
$ cat j.pl
#!/usr/bin/perl
use vars qw( @ISA );
package A;
sub new {
# I really don't understand this mojo,
# but we know it works when we use it...
my ($caller) = (@_);
my $caller_is_obj = ref($caller);
my $class = $caller_is_obj || $caller;
my $self = bless {}, ref($class) || $class;
}
sub init { print "a"; }
package B;
@ISA = ('A');
sub init { $_[0]->SUPER::init; print "b"; }
package C;
@ISA = ('B');
sub init { $_[0]->SUPER::init; print "c"; }
package D;
@ISA = ('C');
sub init { $_[0]->SUPER::init; print "d"; }
package E;
@ISA = ('D');
sub init { $_[0]->SUPER::init; print "e"; }
package main;
my $obj = E->new;
print "\$obj is $obj\n";
$obj->init;
print "\n";
---------------------------
Yup. It does what I expected:
---------------------------
$ perl j.pl
$obj is E=HASH(0x815c088)
abcde
---------------------------
Yay! I'm not losing my mind after all!
j
From bwiese at cotse.com Thu Sep 22 23:58:17 2005
From: bwiese at cotse.com (Brian Wiese)
Date: Thu, 22 Sep 2005 23:58:17 -0700
Subject: [Omaha.pm] Chaining a method (called "init")
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC7B@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC7B@exchange2k3.omnihotels.net>
Message-ID: <4333A789.8000802@cotse.com>
I'm a bit out of touch with my perl syntax, could your explain this with
some comments?
Jay Hannah wrote:
>This is just a sanity check that chaining methods works the way I
>thought it did.
>
>---------------------------
>$ cat j.pl
>#!/usr/bin/perl
>
>use vars qw( @ISA );
>
>package A;
>sub new {
> # I really don't understand this mojo,
> # but we know it works when we use it...
> my ($caller) = (@_);
> my $caller_is_obj = ref($caller);
> my $class = $caller_is_obj || $caller;
> my $self = bless {}, ref($class) || $class;
>}
>sub init { print "a"; }
>
>package B;
>@ISA = ('A');
>sub init { $_[0]->SUPER::init; print "b"; }
>
>package C;
>@ISA = ('B');
>sub init { $_[0]->SUPER::init; print "c"; }
>
>package D;
>@ISA = ('C');
>sub init { $_[0]->SUPER::init; print "d"; }
>
>package E;
>@ISA = ('D');
>sub init { $_[0]->SUPER::init; print "e"; }
>
>package main;
>my $obj = E->new;
>print "\$obj is $obj\n";
>$obj->init;
>print "\n";
>---------------------------
>
>Yup. It does what I expected:
>---------------------------
>$ perl j.pl
>$obj is E=HASH(0x815c088)
>abcde
>---------------------------
>
>Yay! I'm not losing my mind after all!
>
>j
>_______________________________________________
>Omaha-pm mailing list
>Omaha-pm at pm.org
>http://mail.pm.org/mailman/listinfo/omaha-pm
>
>
>
--
bwiese[at]cotse.com | brianwiese.net | 402.297.9392
"What we do in life echoes in eternity" - Gladiator
From jay at jays.net Sun Sep 25 18:06:01 2005
From: jay at jays.net (Jay Hannah)
Date: Sun, 25 Sep 2005 20:06:01 -0500
Subject: [Omaha.pm] Chaining a method (called "init")
In-Reply-To: <4333A789.8000802@cotse.com>
References: <29AB736ABCE5C745ABF9C93B02F2C27B031ACC7B@exchange2k3.omnihotels.net>
<4333A789.8000802@cotse.com>
Message-ID: <4de7d2a64bffc80d6a38593cf61e6d32@jays.net>
On Sep 23, 2005, at 1:58 AM, Brian Wiese wrote:
> I'm a bit out of touch with my perl syntax, could your explain this
> with
> some comments?
Sure, I'll try. The gist is that I've got a deep object hierarchy.
A is the base class of B. B is the base class of C, etc to E.
When I instantiate an E and call init(), I'm expecting the A init to
run, then the B init, then the C init, etc.
So the code below just demostrates that.
> Jay Hannah wrote:
>> This is just a sanity check that chaining methods works the way I
>> thought it did.
>>
>> ---------------------------
>> $ cat j.pl
>> #!/usr/bin/perl
>>
>> use vars qw( @ISA );
>>
>> package A;
>> sub new {
>> # I really don't understand this mojo,
>> # but we know it works when we use it...
>> my ($caller) = (@_);
>> my $caller_is_obj = ref($caller);
>> my $class = $caller_is_obj || $caller;
>> my $self = bless {}, ref($class) || $class;
>> }
>> sub init { print "a"; }
That was it for A. new() is inherited by all subclasses.
>> package B;
>> @ISA = ('A');
>> sub init { $_[0]->SUPER::init; print "b"; }
And that's all there is to each child. Each child just declares its
parent and then polymorph's the init() method, running it's parent's
init() first, then printing its own letter.
C, D, E are the same as B:
>> package C;
>> @ISA = ('B');
>> sub init { $_[0]->SUPER::init; print "c"; }
>>
>> package D;
>> @ISA = ('C');
>> sub init { $_[0]->SUPER::init; print "d"; }
>>
>> package E;
>> @ISA = ('D');
>> sub init { $_[0]->SUPER::init; print "e"; }
Then we write our "main" routine -- it's where the code starts running.
>> package main;
Instatiate an E:
>> my $obj = E->new;
Print a line of debug just to make sure that I do, indeed have an E now:
>> print "\$obj is $obj\n";
Then run init and see if it does what I expected/wanted. Plus a newline.
>> $obj->init;
>> print "\n";
That's it. When I run the program it does what I expected:
>> ---------------------------
>>
>> Yup. It does what I expected:
>> ---------------------------
>> $ perl j.pl
>> $obj is E=HASH(0x815c088)
>> abcde
>> ---------------------------
Is that what you were looking for?
I hope that helped,
j
From rps at willcomminc.com Tue Sep 27 15:02:04 2005
From: rps at willcomminc.com (Ryan Stille)
Date: Tue, 27 Sep 2005 17:02:04 -0500
Subject: [Omaha.pm] Help with parsing HTML
Message-ID: <9A8B75E3985324438F1BFA08B160E82057AE19@suxsvr.willconsult.com>
I need to parse my HTML pages and look for some things. I've tried
using HTML::Parser but am not having much luck with it. I thought it
would be a pretty simple thing but it's not turning out that way.
Any tips? Is there something better to use than HTML::Parser?
I just need something that feeds me the text between a specific tag,
then I will use a regular expression on it to find my string and report
on it.
Thanks,
-Ryan
From andy at petdance.com Tue Sep 27 15:04:54 2005
From: andy at petdance.com (Andy Lester)
Date: Tue, 27 Sep 2005 17:04:54 -0500
Subject: [Omaha.pm] Help with parsing HTML
In-Reply-To: <9A8B75E3985324438F1BFA08B160E82057AE19@suxsvr.willconsult.com>
References: <9A8B75E3985324438F1BFA08B160E82057AE19@suxsvr.willconsult.com>
Message-ID: <20050927220454.GA534@petdance.com>
On Tue, Sep 27, 2005 at 05:02:04PM -0500, Ryan Stille (rps at willcomminc.com) wrote:
> I need to parse my HTML pages and look for some things. I've tried
> using HTML::Parser but am not having much luck with it. I thought it
> would be a pretty simple thing but it's not turning out that way.
What are you trying to extract?
You can look at how I use it in WWW::Mechanize for an example.
xoox,
Andy
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From tedkat at gmail.com Tue Sep 27 15:13:46 2005
From: tedkat at gmail.com (Theodore Katseres)
Date: Tue, 27 Sep 2005 17:13:46 -0500
Subject: [Omaha.pm] Help with parsing HTML
In-Reply-To: <20050927220454.GA534@petdance.com>
References: <9A8B75E3985324438F1BFA08B160E82057AE19@suxsvr.willconsult.com>
<20050927220454.GA534@petdance.com>
Message-ID:
On 9/27/05, Andy Lester wrote:
> On Tue, Sep 27, 2005 at 05:02:04PM -0500, Ryan Stille (rps at willcomminc.com) wrote:
> > I need to parse my HTML pages and look for some things. I've tried
> > using HTML::Parser but am not having much luck with it. I thought it
> > would be a pretty simple thing but it's not turning out that way.
>
> What are you trying to extract?
>
> You can look at how I use it in WWW::Mechanize for an example.
I've always been partial to HTML::TokeParser;
--
Ted Katseres
||=O=||
From dthacker9 at cox.net Tue Sep 27 22:39:31 2005
From: dthacker9 at cox.net (Dave Thacker)
Date: Wed, 28 Sep 2005 00:39:31 -0500
Subject: [Omaha.pm] Pulling data back out of a hash of arrays.
Message-ID: <200509280039.31034.dthacker9@cox.net>
What I want to do:
Create a hash of arrays such that the key is the game id, and the rest of the
game data (currently just home and away teams) is the array. My print
statements tell me this seems to be working. Next I'd like to iterate
through the list of hash keys, and obtain the array contents for each key.
This is not working. I'm getting a pointer to the array. How do I get to
the actual data?
Code snippet:
while ( @fixture_rec = $sth->fetchrow_array ) {
my $game_id = $fixture_rec[0];
print "0=$fixture_rec[0] 1=$fixture_rec[1] 2=$fixture_rec[2]\n";
my @teams = @fixture_rec[1..2];
print "home=$teams[0] away=$teams[1]\n";
#stuff the hash
$fixture{$game_id} = [ @teams ];
}
return;
}
sub get_teamsheets {
while (($game_id, @teams) = each %fixture) {
print "Game=$game_id Home=$teams[0]\n";
}
return;
}
results:
0=2827 1=mba 2=mbb
home=mba away=mbb
0=2828 1=mbc 2=mbd
home=mbc away=mbd
0=2829 1=mbe 2=mbf
home=mbe away=mbf
0=2830 1=mbg 2=mbh
home=mbg away=mbh
0=2831 1=mbi 2=mbj
home=mbi away=mbj
Game=2828 Home=ARRAY(0x8338ad4)
Game=2830 Home=ARRAY(0x8338b34)
Game=2829 Home=ARRAY(0x8338b04)
Game=2831 Home=ARRAY(0x8338b64)
Game=2827 Home=ARRAY(0x8338a8c)
From jay at jays.net Wed Sep 28 04:41:11 2005
From: jay at jays.net (Jay Hannah)
Date: Wed, 28 Sep 2005 06:41:11 -0500 (CDT)
Subject: [Omaha.pm] Help with parsing HTML
In-Reply-To:
References: <9A8B75E3985324438F1BFA08B160E82057AE19@suxsvr.willconsult.com>
<20050927220454.GA534@petdance.com>
Message-ID:
On Tue, 27 Sep 2005, Theodore Katseres wrote:
> On 9/27/05, Andy Lester wrote:
> > On Tue, Sep 27, 2005 at 05:02:04PM -0500, Ryan Stille (rps at willcomminc.com) wrote:
> > > I need to parse my HTML pages and look for some things. I've tried
> > > using HTML::Parser but am not having much luck with it. I thought it
> > > would be a pretty simple thing but it's not turning out that way.
I've heard good things about Text::Balanced over the years.
j
From jay at jays.net Wed Sep 28 04:59:08 2005
From: jay at jays.net (Jay Hannah)
Date: Wed, 28 Sep 2005 06:59:08 -0500 (CDT)
Subject: [Omaha.pm] Pulling data back out of a hash of arrays.
In-Reply-To: <200509280039.31034.dthacker9@cox.net>
References: <200509280039.31034.dthacker9@cox.net>
Message-ID:
On Wed, 28 Sep 2005, Dave Thacker wrote:
> Code snippet:
>
> while ( @fixture_rec = $sth->fetchrow_array ) {
> my $game_id = $fixture_rec[0];
> print "0=$fixture_rec[0] 1=$fixture_rec[1] 2=$fixture_rec[2]\n";
> my @teams = @fixture_rec[1..2];
> print "home=$teams[0] away=$teams[1]\n";
> #stuff the hash
> $fixture{$game_id} = [ @teams ];
> }
>
> return;
> }
>
> sub get_teamsheets {
> while (($game_id, @teams) = each %fixture) {
> print "Game=$game_id Home=$teams[0]\n";
> }
> return;
> }
Looks like you're confusing yourself in get_teamsheets(). You think you're
pulling an array of elements into @teams, but you're not. You're pulling a
single element into @teams -- an array reference.
Try this instead and see if it works:
sub get_teamsheets {
while (($game_id, $teamsref) = each %fixture) {
print "Game=$game_id Home=$teamsref->[0]\n";
}
return;
}
- You also probably want to pass a %fixture reference into the sub, not
use a global %fixture. It'll be easier to support your code down the road
that way. Globals quickly get out of control.
- "return;" at the end of a sub doesn't do anything. It just tells perl to
do what it's about to do anyway. You can leave it out or, preferably, do
an explicit return of a true value (like "return 1;") so code calling your
sub can understand that the sub was successful if it happens to care
(which it probably should).
HTH,
j
From jay at jays.net Wed Sep 28 05:53:53 2005
From: jay at jays.net (Jay Hannah)
Date: Wed, 28 Sep 2005 07:53:53 -0500 (CDT)
Subject: [Omaha.pm] Genealogy & Perl
Message-ID:
Wow!!
http://www.pidcock.co.uk/gth/
Clickable up and down browsing! e.g.:
http://www.pidcock.co.uk/gth/Pidcock/I43.html
Too cool! I thought I was going to have to write my own... My GEDCOM isn't
online yet. Working on it... :)
j
From rps at willcomminc.com Wed Sep 28 08:41:37 2005
From: rps at willcomminc.com (Ryan Stille)
Date: Wed, 28 Sep 2005 10:41:37 -0500
Subject: [Omaha.pm] Help with parsing HTML
Message-ID: <9A8B75E3985324438F1BFA08B160E82057AE1F@suxsvr.willconsult.com>
> What are you trying to extract?
For example, I'd like the content inside the content inside each set of
tags in a given file.
Jay, I tried your suggestion of Text::Balanced, but didn't have any
luck.
Here's what I did with Text::Balanced :
__________________________
use Text::Balanced qw ( extract_tagged );
foreach $arg ( @ARGV ) {
open (IN,$arg) or next;
local $/;
$filecontent = ;
($extracted, $remainder)
= extract_tagged($filecontent, '', undef,
undef);
print "extracted: $extracted\n";
print "remainder: $remainder\n";
}
___________________________
But nothing was ever returned in the $extracted variable, everything was
always in the remainder. I tried many variations of the 2nd and 3rd
arguments to extract_tagged() but nothing worked. Is there anything
obviously wrong with how I am using it? Once I get that to work I plan
to put it inside a while loop to continue to call extract_tagged() until
I've gone through the whole file.
-Ryan
From andy at petdance.com Wed Sep 28 09:00:25 2005
From: andy at petdance.com (Andy Lester)
Date: Wed, 28 Sep 2005 11:00:25 -0500
Subject: [Omaha.pm] Help with parsing HTML
In-Reply-To: <9A8B75E3985324438F1BFA08B160E82057AE1F@suxsvr.willconsult.com>
References: <9A8B75E3985324438F1BFA08B160E82057AE1F@suxsvr.willconsult.com>
Message-ID: <20050928160025.GB20201@petdance.com>
On Wed, Sep 28, 2005 at 10:41:37AM -0500, Ryan Stille (rps at willcomminc.com) wrote:
> Jay, I tried your suggestion of Text::Balanced, but didn't have any
> luck.
Really, please go look at how it's done in WWW::Mechanize with
HTML::Parser. Once you get your head around callbacks, it's super
simple.
xoxo,
Andy
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From rps at willcomminc.com Wed Sep 28 10:00:55 2005
From: rps at willcomminc.com (Ryan Stille)
Date: Wed, 28 Sep 2005 12:00:55 -0500
Subject: [Omaha.pm] Help with parsing HTML
Message-ID: <9A8B75E3985324438F1BFA08B160E82057AE27@suxsvr.willconsult.com>
> Really, please go look at how it's done in WWW::Mechanize
> with HTML::Parser. Once you get your head around callbacks, it's
> super simple.
Ok I am getting closer. The problem is it is is ignoring nested tags.
File:
Blah blah AND blah blah
My Code:
my $p = HTML::TokeParser->new($arg) or die $!;
while ($p->get_tag("cfquery")) {
my $query = $p->get_trimmed_text("/cfquery");
print "$arg: $query\n";
}
Returns:
Blah blah AND blah blah
How do I tell it to leave the tags in there?
-Ryan
From andy at petdance.com Wed Sep 28 10:12:38 2005
From: andy at petdance.com (Andy Lester)
Date: Wed, 28 Sep 2005 12:12:38 -0500
Subject: [Omaha.pm] Help with parsing HTML
In-Reply-To: <9A8B75E3985324438F1BFA08B160E82057AE27@suxsvr.willconsult.com>
References: <9A8B75E3985324438F1BFA08B160E82057AE27@suxsvr.willconsult.com>
Message-ID: <20050928171238.GD20201@petdance.com>
On Wed, Sep 28, 2005 at 12:00:55PM -0500, Ryan Stille (rps at willcomminc.com) wrote:
> Ok I am getting closer. The problem is it is is ignoring nested tags.
You'll have to keep track of your own internal stack of them, I
believe. There may also be an option for it.
xoxo
Andy
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From rps at willcomminc.com Wed Sep 28 12:27:48 2005
From: rps at willcomminc.com (Ryan Stille)
Date: Wed, 28 Sep 2005 14:27:48 -0500
Subject: [Omaha.pm] Help with parsing HTML
Message-ID: <9A8B75E3985324438F1BFA08B160E82057AE32@suxsvr.willconsult.com>
Andy Lester wrote:
> On Wed, Sep 28, 2005 at 12:00:55PM -0500, Ryan Stille
> (rps at willcomminc.com) wrote:
>> Ok I am getting closer. The problem is it is ignoring nested tags.
>
> You'll have to keep track of your own internal stack of them,
> I believe. There may also be an option for it.
I got it working, pretty much. If I set "$p->{textify} =
{'cfqueryparam' => 'value'}" it tells the parser to treat the
tag as text. It does not display it exactly, instead it
displays the value in the 'value' attribute, i.e.
SELECT foo FROM table WHERE id =
Gets returned as: SELECT foo FROM table WHERE id = #myvalue#
Which is good enough for me. Now I can count the selects, inserts,
deletes, etc. inside each block and flag the ones that have more than
one. We are migrating to MySQL, which does not support more than one
query in a single statement.
Thanks for the help.
-Ryan
From andy at petdance.com Wed Sep 28 12:32:24 2005
From: andy at petdance.com (Andy Lester)
Date: Wed, 28 Sep 2005 14:32:24 -0500
Subject: [Omaha.pm] Help with parsing HTML
In-Reply-To: <9A8B75E3985324438F1BFA08B160E82057AE32@suxsvr.willconsult.com>
References: <9A8B75E3985324438F1BFA08B160E82057AE32@suxsvr.willconsult.com>
Message-ID: <20050928193224.GC22642@petdance.com>
On Wed, Sep 28, 2005 at 02:27:48PM -0500, Ryan Stille (rps at willcomminc.com) wrote:
> Which is good enough for me. Now I can count the selects, inserts,
> deletes, etc. inside each block and flag the ones that have more than
> one. We are migrating to MySQL, which does not support more than one
> query in a single statement.
Are you talking about subselects? Newer MySQLs do.
xoxo,
Andy
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From rps at willcomminc.com Wed Sep 28 12:43:55 2005
From: rps at willcomminc.com (Ryan Stille)
Date: Wed, 28 Sep 2005 14:43:55 -0500
Subject: [Omaha.pm] Help with parsing HTML
Message-ID: <9A8B75E3985324438F1BFA08B160E82057AE33@suxsvr.willconsult.com>
> Are you talking about subselects? Newer MySQLs do.
No, I am aware it supports subselects now. Which is good, I won't have
to change those. I'm talking about things like
INSERT INTO cfg (1, 'red', 'foo');
INSERT INTO pubcfg (1, 'red', 'foo');
Or
DELETE FROM taxcodes
INSERT INTO taxcodes ...
INSERT INTO taxcodes ...
And they get more complex from there. The MyODBC driver does not
support multiple queries in a single statement, so I have to separate
all these into separate cfquery blocks. The bigest use is where we
insert a new record into a table, then issue a select statement to grab
the auto-generated ID of the new record. These have to be put into
separate query blocks, and then those query blocks put inside a
transaction.
-Ryan
From andy at petdance.com Wed Sep 28 12:54:07 2005
From: andy at petdance.com (Andy Lester)
Date: Wed, 28 Sep 2005 14:54:07 -0500
Subject: [Omaha.pm] Help with parsing HTML
In-Reply-To: <9A8B75E3985324438F1BFA08B160E82057AE33@suxsvr.willconsult.com>
References: <9A8B75E3985324438F1BFA08B160E82057AE33@suxsvr.willconsult.com>
Message-ID: <20050928195406.GE22642@petdance.com>
On Wed, Sep 28, 2005 at 02:43:55PM -0500, Ryan Stille (rps at willcomminc.com) wrote:
>
> INSERT INTO cfg (1, 'red', 'foo');
> INSERT INTO pubcfg (1, 'red', 'foo');
>
> the auto-generated ID of the new record. These have to be put into
> separate query blocks, and then those query blocks put inside a
> transaction.
You didn't really even have transactions here, did you? If it wasn't in
a tag?
xoxo,
Andy
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From rps at willcomminc.com Wed Sep 28 13:31:15 2005
From: rps at willcomminc.com (Ryan Stille)
Date: Wed, 28 Sep 2005 15:31:15 -0500
Subject: [Omaha.pm] Help with parsing HTML
Message-ID: <9A8B75E3985324438F1BFA08B160E82057AE34@suxsvr.willconsult.com>
> You didn't really even have transactions here, did you? If
> it wasn't in a tag?
No. I will be using cftransaction now, to get the ID of the last
inserted record (see below). Previously I did not need to, I think the
group of statements was treated as a transaction when they were all
inside a single cfquery block.
INSERT INTO table (id, name) VALUES (NULL, foo)
SELECT LAST_INSERT_ID() as lastid
From dthacker9 at cox.net Wed Sep 28 21:14:38 2005
From: dthacker9 at cox.net (Dave Thacker)
Date: Wed, 28 Sep 2005 23:14:38 -0500
Subject: [Omaha.pm] Pulling data back out of a hash of arrays.
In-Reply-To:
References: <200509280039.31034.dthacker9@cox.net>
Message-ID: <200509282314.38572.dthacker9@cox.net>
On Wednesday 28 September 2005 06:59, Jay Hannah wrote:
> On Wed, 28 Sep 2005, Dave Thacker wrote:
> > Code snippet:
> >
> > while ( @fixture_rec = $sth->fetchrow_array ) {
> > my $game_id = $fixture_rec[0];
> > print "0=$fixture_rec[0] 1=$fixture_rec[1] 2=$fixture_rec[2]\n";
> > my @teams = @fixture_rec[1..2];
> > print "home=$teams[0] away=$teams[1]\n";
> > #stuff the hash
> > $fixture{$game_id} = [ @teams ];
> > }
> >
> > return;
> > }
> >
> > sub get_teamsheets {
> > while (($game_id, @teams) = each %fixture) {
> > print "Game=$game_id Home=$teams[0]\n";
> > }
> > return;
> > }
>
> Looks like you're confusing yourself in get_teamsheets(). You think you're
> pulling an array of elements into @teams, but you're not. You're pulling a
> single element into @teams -- an array reference.
>
> Try this instead and see if it works:
>
> sub get_teamsheets {
> while (($game_id, $teamsref) = each %fixture) {
> print "Game=$game_id Home=$teamsref->[0]\n";
> }
> return;
> }
The result is now.
"Unrecognized character \xC2 at ./auto-run.pl line 83."
I'm not at all sure where that is coming from...
>
> - You also probably want to pass a %fixture reference into the sub, not
> use a global %fixture. It'll be easier to support your code down the road
> that way. Globals quickly get out of control.
Perhaps it is already?
>
> - "return;" at the end of a sub doesn't do anything. It just tells perl to
> do what it's about to do anyway. You can leave it out or, preferably, do
> an explicit return of a true value (like "return 1;") so code calling your
> sub can understand that the sub was successful if it happens to care
> (which it probably should).
I can fix that.
> HTH,
>
> j
From jay at jays.net Thu Sep 29 18:16:40 2005
From: jay at jays.net (Jay Hannah)
Date: Thu, 29 Sep 2005 20:16:40 -0500
Subject: [Omaha.pm] Pulling data back out of a hash of arrays.
In-Reply-To: <200509282314.38572.dthacker9@cox.net>
References: <200509280039.31034.dthacker9@cox.net>
<200509282314.38572.dthacker9@cox.net>
Message-ID: <6eb189e19f324913417a65d3cf41fc40@jays.net>
On Sep 28, 2005, at 11:14 PM, Dave Thacker wrote:
> The result is now.
> "Unrecognized character \xC2 at ./auto-run.pl line 83."
> I'm not at all sure where that is coming from...
If you post the snippet and tell us which line is 83 maybe we can help?
j
From dan at linder.org Thu Sep 29 19:36:20 2005
From: dan at linder.org (Daniel Linder)
Date: Thu, 29 Sep 2005 21:36:20 -0500 (CDT)
Subject: [Omaha.pm] Pulling data back out of a hash of arrays.
In-Reply-To: <6eb189e19f324913417a65d3cf41fc40@jays.net>
References: <200509280039.31034.dthacker9@cox.net>
<200509282314.38572.dthacker9@cox.net>
<6eb189e19f324913417a65d3cf41fc40@jays.net>
Message-ID: <4956.68.13.86.85.1128047780.squirrel@mail.linder.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> On Sep 28, 2005, at 11:14 PM, Dave Thacker wrote:
>> The result is now.
>> "Unrecognized character \xC2 at ./auto-run.pl line
83."
>> I'm not at all sure where that is coming from...
FYI, I've copied and pasted from some e-mail clients before.?
Microsoft Outlook and other Rich Text mail clients try to put in
"typesetting quotes" rather than the simple ASCII quote
character.? When those (or other "pretty") characters are
pasted into a file for Perl to use, it sees the wrong character and not
the simple ASCII character it was expecting.
Try re-typing the line by hand to see if the \xC2 dissapears.
- - - - -
"Wait for that wisest of all counselors, time." -- Pericles
"I do not fear computer, I fear the lack of them." -- Isaac
Asimov
GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDPKSksrDMR0/em2gRAluNAKCUl9Zg0BWSOx/AoGtyvsGoEOWsTwCg46O8
T1w+LyPKfHUKDjufzm8JnsE=
=+7jG
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050930/5bd5e36b/attachment.html
From kthompson at omnihotels.com Fri Sep 30 12:38:25 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Fri, 30 Sep 2005 14:38:25 -0500
Subject: [Omaha.pm] Ow!! || bit me
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B03228212@exchange2k3.omnihotels.net>
So...
Wouldn't this work?
$res->set_child_qty($cookie->{child_qty} || $q->param('child_qty') ||
0);
Since it ignores the falses (0 and undef), it would fall through to the
last choice, which would be your default?
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Jay Hannah
Sent: Tuesday, September 20, 2005 10:15 AM
To: omaha-pm at pm.org
Subject: [Omaha.pm] Ow!! || bit me
Code:
$res->set_child_qty ($cookie->{child_qty} ||
$q->param('child_qty'));
When:
$cookie->{child_qty} is 0
and
$q->param('child_qty') is undef
Then:
I'm running $res->set_child_qty(undef)
which is NOT what I wanted.
Doh! I need Perl 6's // operator! -grin-
New code:
if (defined $cookie->{child_qty}) {
$res->set_child_qty($cookie->{child_qty})
} else {
$res->set_child_qty($q->param('child_qty'))
}
Eww... Long and ugly. But it does do what I want and 0 is a valid value
for child_qty.
$live && $learn++;
j
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From jay at jays.net Fri Sep 30 13:41:44 2005
From: jay at jays.net (Jay Hannah)
Date: Fri, 30 Sep 2005 15:41:44 -0500
Subject: [Omaha.pm] Ow!! || bit me
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B03228212@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B03228212@exchange2k3.omnihotels.net>
Message-ID: <53450ffcc589ec5dd0d0abde9972705b@jays.net>
On Sep 30, 2005, at 2:38 PM, Kenneth Thompson wrote:
> Wouldn't this work?
>
> $res->set_child_qty($cookie->{child_qty} || $q->param('child_qty') ||
> 0);
>
> Since it ignores the falses (0 and undef), it would fall through to the
> last choice, which would be your default?
As discussed: Yes, but it wouldn't Do The Right Thing
(set_child_qty(0)) if $cookie->{child_qty} was 0 and
$q->param('child_qty') was 7.
It would set_child_qty(7). The Wrong Thing. -grin-
j
From dthacker9 at cox.net Fri Sep 30 23:10:10 2005
From: dthacker9 at cox.net (Dave Thacker)
Date: Sat, 1 Oct 2005 01:10:10 -0500
Subject: [Omaha.pm] Pulling data back out of a hash of arrays.
In-Reply-To: <4956.68.13.86.85.1128047780.squirrel@mail.linder.org>
References: <200509280039.31034.dthacker9@cox.net>
<6eb189e19f324913417a65d3cf41fc40@jays.net>
<4956.68.13.86.85.1128047780.squirrel@mail.linder.org>
Message-ID: <200510010110.11209.dthacker9@cox.net>
On Thursday 29 September 2005 21:36, Daniel Linder wrote:
> > On Sep 28, 2005, at 11:14 PM, Dave Thacker wrote:
> >> The result is now.
> >>
> >> "Unrecognized character \xC2 at ./auto-run.pl line
>
> 83."
>
> >> I'm not at all sure where that is coming from...
>
> FYI, I've copied and pasted from some e-mail clients before.?
> Microsoft Outlook and other Rich Text mail clients try to put in
> "typesetting quotes" rather than the simple ASCII quote
> character.? When those (or other "pretty") characters are
> pasted into a file for Perl to use, it sees the wrong character and not
> the simple ASCII character it was expecting.
Ah, yes. Retyping Jay's syntax now gives a working statement.
Thanks to both of you.
DT