From jhannah at omnihotels.com Thu Aug 4 07:47:59 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Thu, 4 Aug 2005 09:47:59 -0500
Subject: [Omaha.pm] Template Toolkit l33t hax0rs
Message-ID: <200508041446.j74Ekcic028361@omares-email.omnihotels.com>
Our TT stuff is getting pretty slick... We're doing multilanguage templates
[% lang_code = q.param("lang_code") || "en-us" %]
[% IF lang_code == "fr";
lang_text8 = "fr:Rate total:"
lang_text9 = "fr:Taxes:"
lang_text10 = "fr:Fees:"
lang_text11 = "fr:Total:"
;ELSE;
lang_text8 = "Rate total:"
lang_text9 = "Taxes:"
lang_text10 = "Fees:"
lang_text11 = "Total:"
;END %]
Obviously we don't speak french or those fr: strings would actually be in French. We've got a company translating for us at some point.
Then, later, we're using my objects directly in TT, TT pipes, format(), basic TT algebra and flow control...
[% IF suppressed != "S" %]
[% rates = detail.rates_total;
taxes = detail.L_surcharges_data.total_taxes | format('%0.2f');
fees = detail.L_surcharges_data.total_fees | format('%0.2f');
total = rates + taxes + fees %]
$lang_text8 $rates $detail.currency
$lang_text9 $taxes $detail.currency
$lang_text10 $fees $detail.currency
$lang_text11 $total $detail.currency
[% END %]
$TT_5k1lz++;
Grin,
j
From jhannah at omnihotels.com Thu Aug 4 17:52:23 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Thu, 4 Aug 2005 19:52:23 -0500
Subject: [Omaha.pm] Subclassing Class::Date
Message-ID: <200508050051.j750p1ic027042@omares-email.omnihotels.com>
I subclassed Class::Date to bend it slightly to my own evil purposes today. Man that's cool software!
http://search.cpan.org/~dlux/Class-Date-1.1.7/Date.pod
Mainly I'm
- Overriding the constructor to make it a 1-liner instead of a 2-liner
- and to interpret some specific datetime formats "the Omni way" instead of a sensible way. -grin-
- Added a format() method to reduce a formatted string() call from a 2-liner to a 1-liner.
Thanks for the awesome software, dLux!
j
From jay at jays.net Fri Aug 5 08:34:07 2005
From: jay at jays.net (Jay Hannah)
Date: Fri, 5 Aug 2005 10:34:07 -0500
Subject: [Omaha.pm] SQL Attack exception
In-Reply-To: <20050729205440.GD15014@petdance.com>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02BDB440@exchange2k3.omnihotels.net>
<20050729205440.GD15014@petdance.com>
Message-ID:
On Jul 29, 2005, at 3:54 PM, Andy Lester wrote:
> On Fri, Jul 29, 2005 at 03:41:48PM -0500, Kenneth Thompson wrote:
>> foreach my $param ($q->param()) {
>> # Strip out all wacky characters to prevent SQL injections
>> #
>> next ($IgnoreParms{$param}); #ignored - bail now
>> my $value = $q->param($param); #Not ignored.. clean me up Scotty
>> $value =~ s/[`;'"\\]//g;
>> $q->delete($param);
>
> Please don't do this. Please use bind variables.
>
> my $sth = $dbh->prepare( "select * from users where foo=? and bar=?" );
> $sth->execute( $foo, $bar );
>
> The $foo matches up to the first ?, and $bar to the second. Then it
> doesn't matter WHAT you pass in as $foo or $bar because it's not
> interpolated into the SQL, and cannot possibly be executed.
Indeed, sir. We use both.
- The code Kenn posted isn't production code base, he's just playing
with some stuff.
- We commonly use $q->param filter junk to try to stop exploits for
more than just DBI calls. Our Internet systems are NEVER exposed to any
of these things, but: In some Intranet-only scripts we might access
files on the server based on user input and/or (heaven forbid) execute
things on the server using user input as arguments (like a CGI that
goes and grep's files for you based on what you're searching for).
The gist is to try to filter all $q->param's first thing before
anything else is ever done. Additionally I think we're using some CGI
"taint" stuff too.
Another common filter:
s/[^ -~]//g;
to strip all binary/non-printables out of user input.
- Bind variables work great here:
DBI -> DBD::Informix -> esqlC -> Informix RDBMS
but don't work here:
DBI -> DBD::Sybase -> freetds -> MS-SQL RDBMS
because freetds (MS-SQL?) doesn't support bind variables last time I
looked. Regrettable, especially since it would be much faster not to
have to prepare() statements over and over and over again every time
one query variable changes...
Thanks for the tip!
j
From jhannah at omnihotels.com Fri Aug 5 15:42:56 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Fri, 5 Aug 2005 17:42:56 -0500
Subject: [Omaha.pm] Using Class::Date subclass instead of arrays and
Date::Calc
Message-ID: <200508052241.j75Mfaic012767@omares-email.omnihotels.com>
BEFORE:
my @sd = $self->DateConvert($o_RequestAvail->get_arrival_date,6);
my @ed = $self->DateConvert($o_RequestAvail->get_depart_date,6);
my $stay_nights = Delta_Days(@sd, at ed);
AFTER:
my $sd = $o_RequestAvail->get_arrival_date('obj');
my $ed = $o_RequestAvail->get_depart_date('obj');
my $stay_nights = ($ed - $sd)->day;
We don't need 65 homebrew DateConvert() methods any more... or Date::Calc::Delta_Days()... and we can do automagical date subtraction! neato.
j
From jhannah at omnihotels.com Fri Aug 5 15:54:14 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Fri, 5 Aug 2005 17:54:14 -0500
Subject: [Omaha.pm] Using Class::Date subclass instead of arrays and
Date::Calc
Message-ID: <200508052252.j75Mqtic027720@omares-email.omnihotels.com>
Ooo...
BEFORE:
use Date::Calc qw( Today Add_Delta_Days );
$o_ra->set_arrival_date (sprintf("%04d-%02d-%02d", Today()));
$o_ra->set_depart_date (sprintf("%04d-%02d-%02d", Add_Delta_Days(Today(), 1)));
AFTER:
use Control::DateTime;
my $today = Control::DateTime->new();
$o_ra->set_arrival_date ($today);
$o_ra->set_depart_date ($today + "1D");
j
( Control::DateTime is my subclass of Class::Date qw( -DateParse ) )
From jhannah at omnihotels.com Mon Aug 8 13:14:54 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Mon, 8 Aug 2005 15:14:54 -0500
Subject: [Omaha.pm] perl -MDBI -e 'DBI->installed_versions'
Message-ID: <200508082012.j78KCVic015568@omares-email.omnihotels.com>
Database flunkies like me love this stuff:
$ perl -MDBI -e 'DBI->installed_versions'
Perl : 5.008003 (i686-linux)
OS : linux (2.4.21-199-default)
DBI : 1.42
DBD::mysql : 2.9007
DBD::Sybase : 1.04
DBD::Sponge : 11.10
DBD::SQLite : 1.07
DBD::Proxy : 0.2004
DBD::Multiplex : 0.9
DBD::Informix : 2003.04
DBD::File : 0.30
DBD::ExampleP : 11.12
DBD::DBM : 0.01
So much easier than compiling your own list of DBD's...
j
Upgrading perl, DBI, DBDs to latest stable... wish me luck
From dan at linder.org Tue Aug 9 09:45:21 2005
From: dan at linder.org (Daniel Linder)
Date: Tue, 9 Aug 2005 11:45:21 -0500 (CDT)
Subject: [Omaha.pm] perl -MDBI -e 'DBI->installed_versions'
In-Reply-To: <200508082012.j78KCVic015568@omares-email.omnihotels.com>
References: <200508082012.j78KCVic015568@omares-email.omnihotels.com>
Message-ID: <20444.12.160.138.68.1123605921.squirrel@12.160.138.68>
Jay Hannah said:
> Database flunkies like me love this stuff:
> $ perl -MDBI -e 'DBI->installed_versions'
> Perl : 5.008003 (i686-linux)
> OS : linux (2.4.21-199-default)
> DBI : 1.42
> DBD::mysql : 2.9007
> DBD::Sybase : 1.04
[snip...]
> DBD::ExampleP : 11.12
> DBD::DBM : 0.01
Very cool!
> Upgrading perl, DBI, DBDs to latest stable... wish me luck
So, do you do the DBI first, then the DBDs, or the reverse? Or is there a
CPAN module function that does the upgrade of all pieces together?
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:9EE8 ABAE 10D3 0B55 C536 E17A 3620 4DCA A533 19BF
From jhannah at omnihotels.com Tue Aug 9 17:33:20 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Tue, 9 Aug 2005 19:33:20 -0500
Subject: [Omaha.pm] 8784 subtests
Message-ID: <200508100031.j7A0Vtic008983@omares-email.omnihotels.com>
Yee-ha... 8784 tests in our test suite now...
I guess this mean our software pretty much works? We're 99.75% of the way to retirement... -grin-
j
$ prove -r
t/pod.........................................................ok
MVC/t/Base....................................................ok
MVC/View/OTA/t/soap_fault.....................................ok
-snip!-
MVC/Control/Multiplex/Payload/t/Raw...........................ok
MVC/Control/Multiplex/Payload/t/USW...........................ok
MVC/Control/Multiplex/Payload/t/ASCII00_Delim.................ok
Oracle/t/Companies............................................ok
6/6 skipped: Not on royal
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
MVC/Model/stats/Simple/t/L_dly_bk 255 65280 27 44 162.96% 6-27
1 test and 187 subtests skipped.
Failed 1/192 test scripts, 99.48% okay. 22/8784 subtests failed, 99.75% okay.
From jhannah at omnihotels.com Tue Aug 9 17:46:03 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Tue, 9 Aug 2005 19:46:03 -0500
Subject: [Omaha.pm] An ode to DBI::installed_versions()
Message-ID: <200508100044.j7A0icic023232@omares-email.omnihotels.com>
In MS-SQL servers
select @@version from anytable
kicks out some interesting stuff. So, I wrote an ode to DBI::installed_versions(). It connects to each of our hotels (showing that our new drivers are probably working) and kicks out version info.
j
$ perl -MControl::Hotels -e'Control::Hotels::installed_versions'
ATLCNN
PMS v3.01.38
Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: )
AUSCTR
PMS v2.04.31
Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: )
...etc...
From jhannah at omnihotels.com Tue Aug 9 18:05:53 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Tue, 9 Aug 2005 20:05:53 -0500
Subject: [Omaha.pm] Chinese / Taiwanese gossip about me
Message-ID: <200508100104.j7A14Ric018564@omares-email.omnihotels.com>
-laugh-
Looks like someone forwarded my post to a newsgroup that I can't read...
http://groups-beta.google.com/group/tw.bbs.comp.lang.perl/browse_thread/thread/736b3340a6a6c3a0/1de9dffd7a2422d3?lnk=st&q=%22jay+hannah%22&rnum=4#1de9dffd7a2422d3
I wonder if the Chinese word for "jackass" is in there anywhere.
Laugh,
j
From jhannah at omnihotels.com Wed Aug 10 08:20:12 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 10 Aug 2005 10:20:12 -0500
Subject: [Omaha.pm] :Sybase success, build errors
In-Reply-To: <200508100028.j7A0S4ic001997@omares-email.omnihotels.com>
Message-ID: <200508101518.j7AFIYic018669@omares-email.omnihotels.com>
> I did get quite a few build errors though, and only half of
> them (or so) are listed in
>
> DBD-Sybase-1.06/README.freetds
>
> so I thought I'd post my build dialogue here. I'm ignoring
> all the errors below unless someone slaps me.
Looks like last year I threatened to attempt to patch the tests so they'd run clean under freetds. I never did it. Now, feeling shamed, I've given exec.t a shot.
On my box (
Perl : 5.008007 (i686-linux)
OS : linux (2.4.21-243-default)
DBI : 1.48
DBD::Sybase : 1.06
freetds v0.63
(./configure --prefix=/usr/local/freetds --with-tdsver=7.0)
)
The below modified exec.t runs like so:
$ perl exec.t
1..41
ok 1 - use DBI;
ok 2 - use DBD::Sybase;
ok 3 - Connect
ok 4 - Prepare sp_helpindex
ok 5 - exec sysusers
ok 6 - -1 (create proc)
ok 7 - prepare dbitest
ok 8 - bind_param 1
ok 9 - bind_param 2
cs_convert failed (to_numeric(3.2)) at exec.t line 63.
ok 10 - bind_param 3
ok 11 - bind_param 4
ok 12 - bind_param 5
ok 13 # skip freetds seg faults here
ok 14 # skip freetds doesn't support placeholders
ok 15 # skip freetds doesn't support placeholders
ok 16 # skip freetds doesn't support $sth->func?
ok 17 # skip freetds doesn't support $sth->func?
ok 18 # skip freetds doesn't support placeholders
ok 19 # skip freetds doesn't support placeholders
ok 20 # skip freetds doesn't support placeholders
ok 21 # skip freetds doesn't support placeholders
ok 22 # skip freetds doesn't support placeholders
ok 23 # skip freetds doesn't support placeholders
ok 24 - drop proc dbitest 1
ok 25 - drop proc dbitest 2
ok 26 - -1 (create proc)
ok 27 # skip freetds doesn't support bind_param nor placeholders
ok 28 # skip freetds doesn't support bind_param nor placeholders
ok 29 # skip freetds doesn't support bind_param nor placeholders
ok 30 # skip freetds doesn't support bind_param nor placeholders
ok 31 # skip freetds doesn't support bind_param nor placeholders
ok 32 # skip freetds doesn't support bind_param nor placeholders
ok 33 # skip freetds doesn't support bind_param nor placeholders
ok 34 # skip freetds doesn't support bind_param nor placeholders
ok 35 # skip freetds doesn't support bind_param nor placeholders
ok 36 # skip freetds doesn't support bind_param nor placeholders
ok 37 # skip freetds doesn't support bind_param nor placeholders
ok 38 # skip freetds doesn't support bind_param nor placeholders
ok 39 # skip freetds doesn't support bind_param nor placeholders
ok 40 # skip freetds doesn't support bind_param nor placeholders
ok 41 - drop proc dbitest
I hope this diff format works for you and my patch is good. That diff command came from the perl5-porters FAQ, so I hope its what you want.
I hope this helps. If it does I can take a stab at the other test files too.
Cheers,
j
diff -ruN exec.t.original exec.t
--- exec.t.original 2005-08-10 09:25:52.000000000 -0500
+++ exec.t 2005-08-10 10:09:33.000000000 -0500
@@ -11,7 +11,7 @@
use strict;
#use Test::More qw(no_plan);
-use Test::More tests => 22;
+use Test::More tests => 41;
BEGIN { use_ok('DBI', ':sql_types');
@@ -20,6 +20,7 @@
use vars qw($Pwd $Uid $Srv $Db);
+my $using_freetds = ($ENV{SYBASE} =~ /freetds/i) ? 1 : 0;
#DBI->trace(3);
@@ -31,13 +32,11 @@
ok(defined($dbh), 'Connect');
$SIG{__WARN__} = sub { print @_; };
-my $sth = $dbh->prepare("exec sp_helpindex \@objname = ?");
+my $sth = $dbh->prepare("exec sp_helpindex \@objname = 'sysusers'"); # Placeholders not supported in freetds
ok(defined($sth), 'Prepare sp_helpindex');
my $rc;
-
-$rc = $sth->execute("sysusers");
-
+$rc = $sth->execute();
ok(defined($rc), "exec sysusers");
get_all_results($sth);
@@ -45,38 +44,45 @@
#$dbh->do("use tempdb");
$dbh->do("set arithabort off");
$dbh->do("if object_id('dbitest') != NULL drop proc dbitest");
-$rc = $dbh->do(qq{
-create proc dbitest \@one varchar(20), \@two int, \@three numeric(5,2), \@four smalldatetime, \@five float output
+$rc = $dbh->do(q{
+create proc dbitest @one varchar(20), @two int, @three numeric(5,2), @four smalldatetime, @five float output
as
- select \@one, \@two, \@three, \@four
+ select @one, @two, @three, @four
select * from master..sysprocesses
- return \@two
+ return @two
});
-ok(defined($rc), "$rc (create proc)\n");
+ok(defined($rc), "$rc (create proc)");
$sth = $dbh->prepare("exec dbitest \@one = ?, \@two = ?, \@three = ?, \@four = ?, \@five = ? output");
#$rc = $sth->execute("one", 2, 3.2, "jan 1 2001", 5.4);
ok(defined($sth), "prepare dbitest");
-$sth->bind_param(1, "one");
-$sth->bind_param(2, 2, SQL_INTEGER);
-$sth->bind_param(3, 3.2, SQL_DECIMAL);
-$sth->bind_param(4, "jan 1 2001");
-$sth->bind_param(5, 5.4, SQL_FLOAT);
-$rc = $sth->execute();
-ok(defined($rc), "execute dbitest 1");
-#DBI->trace(4);
-get_all_results($sth);
+ok($sth->bind_param(1, "one"), "bind_param 1");
+ok($sth->bind_param(2, 2, SQL_INTEGER), "bind_param 2");
+ok($sth->bind_param(3, 3.2, SQL_DECIMAL), "bind_param 3");
+ok($sth->bind_param(4, "jan 1 2001"), "bind_param 4");
+ok($sth->bind_param(5, 5.4, SQL_FLOAT), "bind_param 5");
+SKIP: {
+ skip "freetds seg faults here", 1 if $using_freetds;
+ ok($rc = $sth->execute(), "execute dbitest 1");
+}
-$rc = $sth->execute("one", 25, 333.2, "jan 1 2001", 5.4);
-ok(defined($rc), "exec dbitest 2");
-get_all_results($sth);
+SKIP: {
+ skip "freetds doesn't support placeholders", 2 if $using_freetds;
+ #DBI->trace(4);
+ get_all_results($sth);
+ ok($rc = $sth->execute("one", 25, 333.2, "jan 1 2001", 5.4), "exec dbitest 2");
+ get_all_results($sth);
+ ok($rc = $sth->execute(undef, 25, 3.2234, "jan 3 2001", 5.4), "exec dbitest 3");
+}
+
+SKIP: {
+ skip "freetds doesn't support \$sth->func?", 2 if $using_freetds;
+ ok(my @out = $sth->func('syb_output_params'), '$sth->func');
+ is($out[0], 5.4, "out param 1");
+}
-$rc = $sth->execute(undef, 25, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "exec dbitest 3");
-my @out = $sth->func('syb_output_params');
-ok($out[0] == 5.4, "out param 1");
#print "@out\n";
#do {
@@ -91,72 +97,74 @@
$sth->{syb_do_proc_status} = 1;
$dbh->{syb_flush_finish} = 0;
-$rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 1");
-get_all_results($sth);
-#DBI->trace(3);
-$rc = $sth->execute("raise", 1, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 2");
-get_all_results($sth);
-$rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4);
-#DBI->trace(0);
-ok(defined($rc), "execute fail mode 3");
-get_all_results($sth);
-
-$dbh->{syb_flush_finish} = 1;
-$rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 4");
-get_all_results($sth);
-#DBI->trace(3);
-$rc = $sth->execute(undef, 1, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 5");
-get_all_results($sth);
-#DBI->trace(0);
-$rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 6");
-get_all_results($sth);
-
+SKIP: {
+ skip "freetds doesn't support placeholders", 6 if $using_freetds;
+ ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4), "execute fail mode 1");
+ get_all_results($sth);
+ #DBI->trace(3);
+ ok($rc = $sth->execute("raise", 1, 3.2234, "jan 3 2001", 5.4), "execute fail mode 2");
+ get_all_results($sth);
+ ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4), "execute fail mode 3");
+ #DBI->trace(0);
+ get_all_results($sth);
+
+ $dbh->{syb_flush_finish} = 1;
+ ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4), "execute fail mode 4");
+ get_all_results($sth);
+ #DBI->trace(3);
+ ok($rc = $sth->execute(undef, 1, 3.2234, "jan 3 2001", 5.4), "execute fail mode 5");
+ get_all_results($sth);
+ #DBI->trace(0);
+ ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4), "execute fail mode 6");
+ get_all_results($sth);
+}
-$dbh->do("drop proc dbitest");
-$dbh->do("if object_id('dbitest') != NULL drop proc dbitest");
-$rc = $dbh->do(qq{
-create proc dbitest \@one varchar(20), \@two int, \@three numeric(5,2), \@four smalldatetime --, \@five float = null output
+ok($dbh->do("drop proc dbitest"), "drop proc dbitest 1");
+ok($dbh->do("if object_id('dbitest') != NULL drop proc dbitest"), "drop proc dbitest 2");
+$rc = $dbh->do(q{
+create proc dbitest @one varchar(20), @two int, @three numeric(5,2), @four smalldatetime --, @five float = null output
as
- select \@one, \@two, \@three, \@four
+ select @one, @two, @three, @four
});
-ok(defined($rc), "$rc (create proc)\n");
+ok(defined($rc), "$rc (create proc)");
-$sth = $dbh->prepare("exec dbitest ?, ?, ?, ?");
-$sth->bind_param(1, 'String 1', SQL_VARCHAR);
-$sth->bind_param(2, 1, SQL_INTEGER);
-$sth->bind_param(3, 3.25, SQL_DECIMAL);
-$sth->bind_param(4, '2005-06-27', SQL_DATETIME);
+SKIP: {
+ skip "freetds doesn't support bind_param nor placeholders", 7 if $using_freetds;
+ ok($sth = $dbh->prepare("exec dbitest ?, ?, ?, ?"), "prepare");
+ ok($sth->bind_param(1, 'String 1', SQL_VARCHAR), "bind_param 1");
+ ok($sth->bind_param(2, 1, SQL_INTEGER), "bind_param 2");
+ ok($sth->bind_param(3, 3.25, SQL_DECIMAL), "bind_param 3");
+ ok($sth->bind_param(4, '2005-06-27', SQL_DATETIME), "bind param 4");
-for (0 .. 1) {
+ for (0 .. 1) {
$sth->execute('String 1', 1, 3.25, '2005-06-27');
while(my $row = $sth->fetch) {
- ok($row->[2] == 3.25, "Implicit finish handling");
+ ok($row->[2] == 3.25, "Implicit finish handling");
}
+ }
}
-$dbh->{syb_do_proc_status} = 1;
-$sth = $dbh->prepare("exec dbitest ?, ?, ?, ?");
-$sth->bind_param(1, 'String 1', SQL_VARCHAR);
-$sth->bind_param(2, 1, SQL_INTEGER);
-$sth->bind_param(3, 3.25, SQL_DECIMAL);
-$sth->bind_param(4, '2005-06-27', SQL_DATETIME);
+SKIP: {
+ skip "freetds doesn't support bind_param nor placeholders", 7 if $using_freetds;
+ $dbh->{syb_do_proc_status} = 1;
+ ok($sth = $dbh->prepare("exec dbitest ?, ?, ?, ?"), "prepare");
+ ok($sth->bind_param(1, 'String 1', SQL_VARCHAR), "bind_param 1");
+ ok($sth->bind_param(2, 1, SQL_INTEGER), "bind_param 2");
+ ok($sth->bind_param(3, 3.25, SQL_DECIMAL), "bind_param 3");
+ ok($sth->bind_param(4, '2005-06-27', SQL_DATETIME), "bind_param 4");
-for (0 .. 1) {
+ for (0 .. 1) {
$sth->execute('String 1', 1, 3.25, '2005-06-27');
while(my $row = $sth->fetch) {
- ok($row->[2] == 3.25, "Implicit finish handling");
+ ok($row->[2] == 3.25, "Implicit finish handling");
}
+ }
}
-$dbh->do("drop proc dbitest");
+ok($dbh->do("drop proc dbitest"), "drop proc dbitest");
sub get_all_results {
my $sth = shift;
From jhannah at omnihotels.com Wed Aug 10 08:26:46 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 10 Aug 2005 10:26:46 -0500
Subject: [Omaha.pm] :Sybase success, build errors
Message-ID: <200508101525.j7AFP7ic030227@omares-email.omnihotels.com>
> diff -ruN exec.t.original exec.t
Hmm... The patch was longer than the file.
If you prefer, here's the full contents of the modified file.
j
#!perl
#
# $Id: exec.t,v 1.8 2005/06/27 18:04:18 mpeppler Exp $
use lib 'blib/lib';
use lib 'blib/arch';
use lib 't';
use _test;
use strict;
#use Test::More qw(no_plan);
use Test::More tests => 41;
BEGIN { use_ok('DBI', ':sql_types');
use_ok('DBD::Sybase');}
use vars qw($Pwd $Uid $Srv $Db);
my $using_freetds = ($ENV{SYBASE} =~ /freetds/i) ? 1 : 0;
#DBI->trace(3);
($Uid, $Pwd, $Srv, $Db) = _test::get_info();
#DBI->trace(3);
my $dbh = DBI->connect("dbi:Sybase:server=$Srv;database=$Db", $Uid, $Pwd, {PrintError=>1});
#exit;
ok(defined($dbh), 'Connect');
$SIG{__WARN__} = sub { print @_; };
my $sth = $dbh->prepare("exec sp_helpindex \@objname = 'sysusers'"); # Placeholders not supported in freetds
ok(defined($sth), 'Prepare sp_helpindex');
my $rc;
$rc = $sth->execute();
ok(defined($rc), "exec sysusers");
get_all_results($sth);
#$dbh->do("use tempdb");
$dbh->do("set arithabort off");
$dbh->do("if object_id('dbitest') != NULL drop proc dbitest");
$rc = $dbh->do(q{
create proc dbitest @one varchar(20), @two int, @three numeric(5,2), @four smalldatetime, @five float output
as
select @one, @two, @three, @four
select * from master..sysprocesses
return @two
});
ok(defined($rc), "$rc (create proc)");
$sth = $dbh->prepare("exec dbitest \@one = ?, \@two = ?, \@three = ?, \@four = ?, \@five = ? output");
#$rc = $sth->execute("one", 2, 3.2, "jan 1 2001", 5.4);
ok(defined($sth), "prepare dbitest");
ok($sth->bind_param(1, "one"), "bind_param 1");
ok($sth->bind_param(2, 2, SQL_INTEGER), "bind_param 2");
ok($sth->bind_param(3, 3.2, SQL_DECIMAL), "bind_param 3");
ok($sth->bind_param(4, "jan 1 2001"), "bind_param 4");
ok($sth->bind_param(5, 5.4, SQL_FLOAT), "bind_param 5");
SKIP: {
skip "freetds seg faults here", 1 if $using_freetds;
ok($rc = $sth->execute(), "execute dbitest 1");
}
SKIP: {
skip "freetds doesn't support placeholders", 2 if $using_freetds;
#DBI->trace(4);
get_all_results($sth);
ok($rc = $sth->execute("one", 25, 333.2, "jan 1 2001", 5.4), "exec dbitest 2");
get_all_results($sth);
ok($rc = $sth->execute(undef, 25, 3.2234, "jan 3 2001", 5.4), "exec dbitest 3");
}
SKIP: {
skip "freetds doesn't support \$sth->func?", 2 if $using_freetds;
ok(my @out = $sth->func('syb_output_params'), '$sth->func');
is($out[0], 5.4, "out param 1");
}
#print "@out\n";
#do {
# local $^W = 0;
# while(my $d = $sth->fetch) {
# print "@$d\n";
# }
#} while($sth->{syb_more_results});
# test various failure modes:
$sth->{syb_do_proc_status} = 1;
$dbh->{syb_flush_finish} = 0;
SKIP: {
skip "freetds doesn't support placeholders", 6 if $using_freetds;
ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4), "execute fail mode 1");
get_all_results($sth);
#DBI->trace(3);
ok($rc = $sth->execute("raise", 1, 3.2234, "jan 3 2001", 5.4), "execute fail mode 2");
get_all_results($sth);
ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4), "execute fail mode 3");
#DBI->trace(0);
get_all_results($sth);
$dbh->{syb_flush_finish} = 1;
ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4), "execute fail mode 4");
get_all_results($sth);
#DBI->trace(3);
ok($rc = $sth->execute(undef, 1, 3.2234, "jan 3 2001", 5.4), "execute fail mode 5");
get_all_results($sth);
#DBI->trace(0);
ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4), "execute fail mode 6");
get_all_results($sth);
}
ok($dbh->do("drop proc dbitest"), "drop proc dbitest 1");
ok($dbh->do("if object_id('dbitest') != NULL drop proc dbitest"), "drop proc dbitest 2");
$rc = $dbh->do(q{
create proc dbitest @one varchar(20), @two int, @three numeric(5,2), @four smalldatetime --, @five float = null output
as
select @one, @two, @three, @four
});
ok(defined($rc), "$rc (create proc)");
SKIP: {
skip "freetds doesn't support bind_param nor placeholders", 7 if $using_freetds;
ok($sth = $dbh->prepare("exec dbitest ?, ?, ?, ?"), "prepare");
ok($sth->bind_param(1, 'String 1', SQL_VARCHAR), "bind_param 1");
ok($sth->bind_param(2, 1, SQL_INTEGER), "bind_param 2");
ok($sth->bind_param(3, 3.25, SQL_DECIMAL), "bind_param 3");
ok($sth->bind_param(4, '2005-06-27', SQL_DATETIME), "bind param 4");
for (0 .. 1) {
$sth->execute('String 1', 1, 3.25, '2005-06-27');
while(my $row = $sth->fetch) {
ok($row->[2] == 3.25, "Implicit finish handling");
}
}
}
SKIP: {
skip "freetds doesn't support bind_param nor placeholders", 7 if $using_freetds;
$dbh->{syb_do_proc_status} = 1;
ok($sth = $dbh->prepare("exec dbitest ?, ?, ?, ?"), "prepare");
ok($sth->bind_param(1, 'String 1', SQL_VARCHAR), "bind_param 1");
ok($sth->bind_param(2, 1, SQL_INTEGER), "bind_param 2");
ok($sth->bind_param(3, 3.25, SQL_DECIMAL), "bind_param 3");
ok($sth->bind_param(4, '2005-06-27', SQL_DATETIME), "bind_param 4");
for (0 .. 1) {
$sth->execute('String 1', 1, 3.25, '2005-06-27');
while(my $row = $sth->fetch) {
ok($row->[2] == 3.25, "Implicit finish handling");
}
}
}
ok($dbh->do("drop proc dbitest"), "drop proc dbitest");
sub get_all_results {
my $sth = shift;
do {
while(my $d = $sth->fetch) {
#print "@$d\n";
;
}
} while($sth->{syb_more_results});
}
From jay at jays.net Thu Aug 11 21:44:01 2005
From: jay at jays.net (Jay Hannah)
Date: Thu, 11 Aug 2005 23:44:01 -0500
Subject: [Omaha.pm] perl -MDBI -e 'DBI->installed_versions'
In-Reply-To: <20444.12.160.138.68.1123605921.squirrel@12.160.138.68>
References: <200508082012.j78KCVic015568@omares-email.omnihotels.com>
<20444.12.160.138.68.1123605921.squirrel@12.160.138.68>
Message-ID: <077df03f0a4dd27df9e9ce4e35374d70@jays.net>
On Aug 9, 2005, at 11:45 AM, Daniel Linder wrote:
>> Upgrading perl, DBI, DBDs to latest stable... wish me luck
>
> So, do you do the DBI first, then the DBDs, or the reverse? Or is
> there a
> CPAN module function that does the upgrade of all pieces together?
From scratch you build/install DBI, DBD dependencies, then the DBD. For
upgrades you can piecemeal them. Usually DBDs support DBIs 2 or more
years old, so you usually aren't forced to upgrade quickly.
When I'm motivated to upgrade anything I usually shoot the moon,
though, just to make sure "latest stable" works across the board. This
last round started because I thought an upgrade might disperse some
weirdness that showed up w/ a fetchrow_hashref() call we were doing.
Yup, it worked.
j
From jhannah at omnihotels.com Mon Aug 15 08:53:27 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Mon, 15 Aug 2005 10:53:27 -0500
Subject: [Omaha.pm] Aug mtg MOVED to Aug 25th
Message-ID: <200508151552.j7FFpxic000898@omares-email.omnihotels.com>
Howdy howdy howdy --
This Thr is my 30th b-day, and my wife won't let me have Perl Mongers, so let's move it back a week:
http://omaha.pm.org/
Attendance has been pretty lackluster lately. Can anyone come on Aug 25th?
Any ideas for meeting topics? Shall I bring a karaoke machine or juggle? -grin-
Here's a PM group census results so far (still underway):
http://jays.net/tmp/Perl%20Mongers%20Census.html
j
From kthompson at omnihotels.com Mon Aug 15 13:59:17 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Mon, 15 Aug 2005 15:59:17 -0500
Subject: [Omaha.pm] Omaha-pm Digest, Vol 16, Issue 7
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B02DE03BC@exchange2k3.omnihotels.net>
I can come- where is it held?
I'd love to see some discussion of state management in a web environment
and ways to accomplish it (Gratuitous attempt at knowledge leeching
based on current tasks in the workplace ;) )
-----Original Message-----
Attendance has been pretty lackluster lately. Can anyone come on Aug
25th?
Any ideas for meeting topics? Shall I bring a karaoke machine or juggle?
-grin-
From jay at jays.net Mon Aug 15 18:05:19 2005
From: jay at jays.net (Jay Hannah)
Date: Mon, 15 Aug 2005 20:05:19 -0500
Subject: [Omaha.pm] Oreilly Discount Code?
In-Reply-To: <200508140656.06089.dthacker9@cox.net>
References: <200508140656.06089.dthacker9@cox.net>
Message-ID: <6d8bc81049466c5026409d6c7450bb0f@jays.net>
On Aug 14, 2005, at 6:56 AM, Dave Thacker wrote:
> Is O'Reilly still honoring the LUG/Monger discount code? What's the
> code
> again? I'm going to order The Damian's new book.
Ya.
j
***Discount information
Don't forget to remind your members about our 20% discount on O'Reilly,
No Starch, Paraglyph, Pragmatic Bookshelf, SitePoint, and Syngress
books and O'Reilly conferences.
Just use code DSUG.
From andy at petdance.com Mon Aug 15 18:08:19 2005
From: andy at petdance.com (Andy Lester)
Date: Mon, 15 Aug 2005 20:08:19 -0500
Subject: [Omaha.pm] Oreilly Discount Code?
In-Reply-To: <6d8bc81049466c5026409d6c7450bb0f@jays.net>
References: <200508140656.06089.dthacker9@cox.net>
<6d8bc81049466c5026409d6c7450bb0f@jays.net>
Message-ID:
>> again? I'm going to order The Damian's new book.
>>
>
> Ya.
And Perl Testing: A Developer's Notebook is good too.
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From bob at mccoy.net Mon Aug 15 18:15:10 2005
From: bob at mccoy.net (Bob McCoy)
Date: Mon, 15 Aug 2005 20:15:10 -0500
Subject: [Omaha.pm] Oreilly Discount Code?
In-Reply-To: <6d8bc81049466c5026409d6c7450bb0f@jays.net>
Message-ID: <20050816011510.UMBG21289.eastrmmtao01.cox.net@bobnet03>
Although when looking for O'Reilly books, you probably want to start at
www.bookpool.com as they typically give 40% discounts for ORA. Bob.
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Jay Hannah
Sent: Monday, August 15, 2005 8:05 PM
To: Omaha Perl Mongers; Dave Thacker
Subject: Re: [Omaha.pm] Oreilly Discount Code?
On Aug 14, 2005, at 6:56 AM, Dave Thacker wrote:
> Is O'Reilly still honoring the LUG/Monger discount code? What's the
> code
> again? I'm going to order The Damian's new book.
Ya.
j
***Discount information
Don't forget to remind your members about our 20% discount on O'Reilly,
No Starch, Paraglyph, Pragmatic Bookshelf, SitePoint, and Syngress
books and O'Reilly conferences.
Just use code DSUG.
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From jay at jays.net Mon Aug 15 18:25:16 2005
From: jay at jays.net (Jay Hannah)
Date: Mon, 15 Aug 2005 20:25:16 -0500
Subject: [Omaha.pm] webby state mgmt
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02DE03BC@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02DE03BC@exchange2k3.omnihotels.net>
Message-ID:
On Aug 15, 2005, at 3:59 PM, Kenneth Thompson wrote:
> I can come- where is it held?
http://omaha.pm.org/
> I'd love to see some discussion of state management in a web
> environment
> and ways to accomplish it (Gratuitous attempt at knowledge leeching
> based on current tasks in the workplace ;) )
State management? Like the state of Nebraska? Or did you mean like my
typical state of confusion? -grin-
If no one else shows up at the meeting and saves you I'll walk through
how I'd do it.
For others to help, you'll probably have to describe your problem to
the list.
j
From jay at jays.net Mon Aug 15 21:35:38 2005
From: jay at jays.net (Jay Hannah)
Date: Mon, 15 Aug 2005 23:35:38 -0500
Subject: [Omaha.pm] Oh... O'Reilly discount is 30% now, etc.
Message-ID: <0a97dd7ea7a8ae572e27fd9b66fb0ac6@jays.net>
O'Reilly newsletter snipped for Perl content...
j
Begin forwarded message:
From: Marsee Henon
Date: August 10, 2005 7:51:28 PM CDT
***Discount information
Don't forget to remind your members about the 30% discount on
O'Reilly, No Starch, Paraglyph, PC Publishing, Pragmatic Bookshelf,
SitePoint, and Syngress books. Just use code DSUG.
***Promotional Material Available:
The following items are available for your next meeting.
Numbers are limited so please don't wait too long.
Let me know the item and the amount you'd like
and I'll do my best.
-Photoshop World Tech Expo Pass, Boston, MA--Sept 8 only
-EuroOSCON Brochures
-PhotoPlus Expo Pass, New York, NY--October 20-22
-30% UG Discount bookmarks
-MAKE Magazine (limit one per group)
(I'm going to ask for a MAKE magazine. Promos looks sweet. -Jay)
***Learning Perl, 4th Edition
Publisher: O'Reilly
ISBN: 0596101058
Informed by their years of success at teaching Perl as consultants, the
authors have re-engineered the Llama to better match the pace and scope
appropriate for readers getting started with Perl, while retaining the
detailed discussion and eclectic wit for which the Llama is famous. This
latest edition has been updated to account for all the recent changes to
the language up to Perl 5.8.
http://www.oreilly.com/catalog/learnperl4/
Chapter 11, "File Tests," is available online:
http://www.oreilly.com/catalog/learnperl4/
***Porting Test::Builder to Perl 6
With Pugs and Parrot playing nicely and bringing Perl 6 to the rest of
us, enterprising early adopters are experimenting with porting their
popular Perl 5 modules to Perl 6. O'Reilly editor chromatic recently
pushed the limits of Pugs by porting Test::Builder to Perl 6. Here's
what he learned about Perl 6, Pugs, and his design along the way.
chromatic is the coauthor of "Perl Testing: A Developer's Notebook."
http://www.perl.com/pub/a/2005/07/28/test_builder_p6.html
From jhannah at omnihotels.com Tue Aug 16 08:26:37 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Tue, 16 Aug 2005 10:26:37 -0500
Subject: [Omaha.pm] push, push, push, push, push?
Message-ID: <200508161525.j7GFPGic021314@omares-email.omnihotels.com>
Before
my $common;
push @$common, "ref_pagesrc";
push @$common, "ref_pagedst";
push @$common, "debug_mode";
push @$common, "demo";
push @$common, "lang_code";
return $common;
After
return ([qw( ref_pagesrc ref_pagedst debug_mode demo lang_code )]);
j
From andy at petdance.com Tue Aug 16 08:28:57 2005
From: andy at petdance.com (Andy Lester)
Date: Tue, 16 Aug 2005 10:28:57 -0500
Subject: [Omaha.pm] push, push, push, push, push?
In-Reply-To: <200508161525.j7GFPGic021314@omares-email.omnihotels.com>
References: <200508161525.j7GFPGic021314@omares-email.omnihotels.com>
Message-ID: <20050816152857.GD22264@petdance.com>
On Tue, Aug 16, 2005 at 10:26:37AM -0500, Jay Hannah (jhannah at omnihotels.com) wrote:
> return ([qw( ref_pagesrc ref_pagedst debug_mode demo lang_code )]);
How about:
return [qw(
ref_pagesrc
ref_pagedst
debug_mode
demo
lang_code
)];
I find vertical lists much easier to read.
xoa
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From jhannah at omnihotels.com Tue Aug 16 10:41:19 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Tue, 16 Aug 2005 12:41:19 -0500
Subject: [Omaha.pm] SQL . sprintf
Message-ID: <200508161739.j7GHdqic028087@omares-email.omnihotels.com>
Before
my @T = Date::Calc::Today;
$filter .= " AND extend(arrival_date,year to day) >= '" .
sprintf("%04d-%02d-%02d",$T[0..2]) . "'";
After
$filter .= " AND extend(arrival_date,year to day) >= " .
sprintf("'%04d-%02d-%02d'", Date::Calc::Today);
j
From kthompson at omnihotels.com Tue Aug 16 13:05:32 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Tue, 16 Aug 2005 15:05:32 -0500
Subject: [Omaha.pm] Cool Hash Count Shortcut
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0A8C@exchange2k3.omnihotels.net>
Ok, so maybe this is old hat, but I found it incredible simple to
implement and even understand.
So here's the scenario... I have an object which contains all the
attributes of a reservation. I also have a list class which contains
many of my reservation objects. What I want is a count of how many of
each type of room I would need if all these reservations were to be
submitted for creation so I can reject them all up front before going
through the effort of running out of inventory half way through creating
them.
In SQL, it would be easy:
SELECT room_type, Count(*)
FROM reservations_to_be
GROUP BY room_type
Here's what I did given my existing structures:
my %RoomTypes;
$self->get_list->rewind;
while (my $o_rl = $self->get_list->next) {
$RoomTypes{$o_rl->get_room_type}++;
}
So now, I can pre-check availability based on summary counts:
If ($RoomTypes{"KN"} > [_some other availability number_]) {
die "Not enough inventory available to fulfill request";
}
The cool part about this is the key won't exist unless there is at least
one room type being requested in my batch or requests - it gets added
automagically as it's found. Plus, if I want to further break it down
Say, counts per type per day), I can just add more keys when adding it
up:
my %RoomTypes;
$self->get_list->rewind;
while (my $o_rl = $self->get_list->next) {
my $StartDate;
my $EndDate = $o_rl->get_depart_date('obj');
for ($StartDate = $o_rl->get_arrival_date('obj'); $StartDate <=
$EndDate; $StartDate += "1D" ) {
$RoomTypes{$StartDate->format("%Y-%m-%d")}{$o_rl->get_room_type}++;
}
}
If ($RoomTypes{"2005-10-01"}{"KN"} > [_some other availability
number_]) {
die "Not enough inventory available to fulfill request";
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050816/df73eba3/attachment.html
From kthompson at omnihotels.com Tue Aug 16 13:16:46 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Tue, 16 Aug 2005 15:16:46 -0500
Subject: [Omaha.pm] SQL . sprintf
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0ABE@exchange2k3.omnihotels.net>
I'm beginning to really like perl...
Before
my @T = Date::Calc::Today;
$filter .= " AND extend(arrival_date,year to day) >= '" .
sprintf("%04d-%02d-%02d",$T[0..2]) . "'";
After
$filter .= " AND extend(arrival_date,year to day) >= " .
sprintf("'%04d-%02d-%02d'", Date::Calc::Today);
After-After
$filter .= " AND extend(arrival_date,year to day) >= '" .
new Control::DateTime->format("%Y-%02d-%02d") . "'";
(Control::DateTime being a massaged Class::Date)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050816/0f094eb2/attachment.html
From pbaker at omnihotels.com Tue Aug 16 13:51:34 2005
From: pbaker at omnihotels.com (Sean Baker)
Date: Tue, 16 Aug 2005 15:51:34 -0500
Subject: [Omaha.pm] SQL . sprintf
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B02BBEC77@exchange2k3.omnihotels.net>
Depending on the database, and if you're only working with "Today" you
may not need to use any Class::Date spinoffs:
$filter .= " AND extend(arrival_date,year to day) >= extend(Today, year
to day) ";
________________________________
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Kenneth Thompson
Sent: Tuesday, August 16, 2005 3:17 PM
To: omaha-pm at pm.org
Subject: Re: [Omaha.pm] SQL . sprintf
I'm beginning to really like perl...
Before
my @T = Date::Calc::Today;
$filter .= " AND extend(arrival_date,year to day) >= '" .
sprintf("%04d-%02d-%02d",$T[0..2]) . "'";
After
$filter .= " AND extend(arrival_date,year to day) >= " .
sprintf("'%04d-%02d-%02d'", Date::Calc::Today);
After-After
$filter .= " AND extend(arrival_date,year to day) >= '" .
new Control::DateTime->format("%Y-%02d-%02d") . "'";
(Control::DateTime being a massaged Class::Date)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050816/fd4f6b4b/attachment-0001.html
From noel at metc.net Tue Aug 16 14:30:36 2005
From: noel at metc.net (Noel Leistad)
Date: Tue, 16 Aug 2005 16:30:36 -0500
Subject: [Omaha.pm] pm lister
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0A8C@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0A8C@exchange2k3.omnihotels.net>
Message-ID: <43025AFC.1050809@metc.net>
Overrun by laziness, inability to form "search phrase" (that works)
something about reading @INC?? maybe I'm completely twisted.
Anybody got a small script that lists installed perl modules. Attempting
a postgrey rpm install, get TONS of grief about dependancies for modules
I'm fairly certain are installed.
Many thanks.
--
/======================================\
| Noel Leistad |
| noel at metc.net |
\======================================/
From pbaker at omnihotels.com Tue Aug 16 15:20:02 2005
From: pbaker at omnihotels.com (Sean Baker)
Date: Tue, 16 Aug 2005 17:20:02 -0500
Subject: [Omaha.pm] pm lister
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B02BBEC78@exchange2k3.omnihotels.net>
I don't know if this will help or not:
#!/usr/bin/perl
use File::Find;
find(\&wanted, @INC);
sub wanted { /\.p[m]$/ && print "$File::Find::name\n" }
A deja.com search returns gobs of other useless information....
For dependencies and Perl packages, I like to use perl -MCPAN because it
automagically installs all of the dependencies for you..... you can
always try that.
0> perl -MCPAN -e 'shell'
cpan shell -- CPAN exploration and modules installation (v1.7601)
ReadLine support enabled
cpan> install Some::Module
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Noel Leistad
Sent: Tuesday, August 16, 2005 4:31 PM
To: Perl Mongers of Omaha, Nebraska USA
Subject: [Omaha.pm] pm lister
Overrun by laziness, inability to form "search phrase" (that works)
something about reading @INC?? maybe I'm completely twisted.
Anybody got a small script that lists installed perl modules. Attempting
a postgrey rpm install, get TONS of grief about dependancies for modules
I'm fairly certain are installed.
Many thanks.
--
/======================================\
| Noel Leistad |
| noel at metc.net |
\======================================/
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From jay at jays.net Tue Aug 16 15:51:52 2005
From: jay at jays.net (Jay Hannah)
Date: Tue, 16 Aug 2005 17:51:52 -0500
Subject: [Omaha.pm] pm lister
In-Reply-To: <43025AFC.1050809@metc.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0A8C@exchange2k3.omnihotels.net>
<43025AFC.1050809@metc.net>
Message-ID: <6b61bf693cb4383b0d7732945b10489a@jays.net>
On Aug 16, 2005, at 4:30 PM, Noel Leistad wrote:
> Anybody got a small script that lists installed perl modules.
perldoc -q installed
HTH,
j
From noel at metc.net Tue Aug 16 15:53:56 2005
From: noel at metc.net (Noel Leistad)
Date: Tue, 16 Aug 2005 17:53:56 -0500
Subject: [Omaha.pm] pm lister
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02BBEC78@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02BBEC78@exchange2k3.omnihotels.net>
Message-ID: <43026E84.2030901@metc.net>
This is what I'm seeing, maybe I'm missing something after a frustrating
day....
#rpm -Uvh postgrey-1.21-0.noarch.rpm
error: Failed dependencies:
perl(BerkeleyDB) is needed by postgrey-1.21-0
perl(Net::Server::Daemonize) is needed by postgrey-1.21-0
perl(Net::Server::Multiplex) is needed by postgrey-1.21-0
perl-BerkeleyDB is needed by postgrey-1.21-0
perl-IO-Multiplex is needed by postgrey-1.21-0
perl-Net-Server is needed by postgrey-1.21-0
#perl -MCPAN -e shell
Undefined value assigned to typeglob at (eval 15) line 15, line 11.
Warning [/etc/inputrc line 11]:
Invalid variable `mark-symlinked-directories'
cpan shell -- CPAN exploration and modules installation (v1.76)
ReadLine support enabled
cpan> install Net::Server::Daemonize
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Database was generated on Mon, 15 Aug 2005 23:07:58 GMT
Net::Server::Daemonize is up to date.
cpan>
cpan> install BerkeleyDB
BerkeleyDB is up to date.
cpan>
cpan> install Net::Server::Multiplex
Net::Server::Multiplex is up to date.
cpan>
So, I'm stumped. I could go through the whole list, but I think you get
the idea...
Noel
Sean Baker wrote:
> I don't know if this will help or not:
>
> #!/usr/bin/perl
> use File::Find;
> find(\&wanted, @INC);
> sub wanted { /\.p[m]$/ && print "$File::Find::name\n" }
>
> A deja.com search returns gobs of other useless information....
>
> For dependencies and Perl packages, I like to use perl -MCPAN because it
> automagically installs all of the dependencies for you..... you can
> always try that.
>
> 0> perl -MCPAN -e 'shell'
> cpan shell -- CPAN exploration and modules installation (v1.7601)
> ReadLine support enabled
>
> cpan> install Some::Module
--
/======================================\
| Noel Leistad |
| noel at metc.net |
\======================================/
From jay at jays.net Tue Aug 16 15:55:37 2005
From: jay at jays.net (Jay Hannah)
Date: Tue, 16 Aug 2005 17:55:37 -0500
Subject: [Omaha.pm] Cool Hash Count Shortcut
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0A8C@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0A8C@exchange2k3.omnihotels.net>
Message-ID: <60d14d767f727796dea317e33f82348d@jays.net>
On Aug 16, 2005, at 3:05 PM, Kenneth Thompson wrote:
> The cool part about this is the key won?t exist unless there is at
> least one room type being requested in my batch or requests ? it gets
> added automagically as it?s found.
Indeed. Autovivification is good*.
http://www.awprofessional.com/articles/article.asp?p=28513&rl=1
"This article explains autovivification, and shows you how to use it
to be lazy."
Laugh,
j
* Usually. 'specially for black hats like me....
From jay at jays.net Tue Aug 16 16:07:12 2005
From: jay at jays.net (Jay Hannah)
Date: Tue, 16 Aug 2005 18:07:12 -0500
Subject: [Omaha.pm] SQL . sprintf
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0ABE@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0ABE@exchange2k3.omnihotels.net>
Message-ID: <8cbd7da160bbcfb11d16060e17c8e072@jays.net>
On Aug 16, 2005, at 3:16 PM, Kenneth Thompson wrote:
> After-After
> ??? $filter .= " AND extend(arrival_date,year to day) >= ?" .
> ?????? new Control::DateTime->format("%Y-%02d-%02d") . "'";
Whoah... That *does* compile. new() is called, then format()... Scary.
I wouldn't actually use that if I were you. Just my $0.02.
Regardless, I think that format() string is garbage in Class::Date
land...
Code:
--------
use Control::DateTime;
# Bogus:
print new Control::DateTime->format("%Y-%02d-%02d");
print "\n";
# Good:
print new Control::DateTime->format("%Y-%m-%d");
print "\n";
--------
Output:
--------
2005-16-16
2005-08-16
--------
Ya can't mix printf format stuff and Class::Date format stuff. They're
different beasties.
Cheers,
j
From jay at jays.net Tue Aug 16 16:08:20 2005
From: jay at jays.net (Jay Hannah)
Date: Tue, 16 Aug 2005 18:08:20 -0500
Subject: [Omaha.pm] SQL . sprintf
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0ABE@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0ABE@exchange2k3.omnihotels.net>
Message-ID:
On Aug 16, 2005, at 3:16 PM, Kenneth Thompson wrote:
> I?m beginning to really like perl...
Mwooo haha aha haha haa haahaha
Welcome to the dark side...
Grin,
j
From jay at jays.net Tue Aug 16 16:13:04 2005
From: jay at jays.net (Jay Hannah)
Date: Tue, 16 Aug 2005 18:13:04 -0500
Subject: [Omaha.pm] pm lister
In-Reply-To: <43026E84.2030901@metc.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02BBEC78@exchange2k3.omnihotels.net>
<43026E84.2030901@metc.net>
Message-ID: <846f688bc93480cb48fa72a8d2c4e032@jays.net>
On Aug 16, 2005, at 5:53 PM, Noel Leistad wrote:
> This is what I'm seeing, maybe I'm missing something after a
> frustrating
> day....
>
> #rpm -Uvh postgrey-1.21-0.noarch.rpm
> error: Failed dependencies:
> perl(BerkeleyDB) is needed by postgrey-1.21-0
> cpan> install BerkeleyDB
> BerkeleyDB is up to date.
Yikes. I never use rpm, so I'm not sure I'll be any help.
What OS are you on? Does your rpm have a more verbose output option?
Can it tell you exactly what files in what paths its looking for? Is
there more than one perl installed on the box? Perhaps "which perl"
shows one, but rpm is looking somewhere else?
j
From andy at petdance.com Tue Aug 16 17:10:16 2005
From: andy at petdance.com (Andy Lester)
Date: Tue, 16 Aug 2005 19:10:16 -0500
Subject: [Omaha.pm] SQL . sprintf
In-Reply-To: <8cbd7da160bbcfb11d16060e17c8e072@jays.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0ABE@exchange2k3.omnihotels.net>
<8cbd7da160bbcfb11d16060e17c8e072@jays.net>
Message-ID: <7C9D2A35-F280-4F37-868F-C1BC95A0A084@petdance.com>
>> new Control::DateTime->format("%Y-%02d-%02d") . "'";
>>
>
> Whoah... That *does* compile. new() is called, then format()... Scary.
> I wouldn't actually use that if I were you. Just my $0.02.
What are you basing that on? What do you imagine will go wrong?
xoa
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From jay at jays.net Tue Aug 16 21:02:05 2005
From: jay at jays.net (Jay Hannah)
Date: Tue, 16 Aug 2005 23:02:05 -0500
Subject: [Omaha.pm] SQL . sprintf
In-Reply-To: <7C9D2A35-F280-4F37-868F-C1BC95A0A084@petdance.com>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0ABE@exchange2k3.omnihotels.net>
<8cbd7da160bbcfb11d16060e17c8e072@jays.net>
<7C9D2A35-F280-4F37-868F-C1BC95A0A084@petdance.com>
Message-ID: <639b043a119745b996b06df435ef85b7@jays.net>
On Aug 16, 2005, at 7:10 PM, Andy Lester wrote:
>>> new Control::DateTime->format("%Y-%02d-%02d") . "'";
>>
>> Whoah... That *does* compile. new() is called, then format()... Scary.
>> I wouldn't actually use that if I were you. Just my $0.02.
>
> What are you basing that on?
Personal preference.
> What do you imagine will go wrong?
My brain might explode. -grin- You'd write this w/o hesitation:?
new X->format()
If I felt compelled to do it all in one line these scare me less:
X->new()->format()
(X->new())->format()
Plus @ OSCON 2003 Damian Conway said "new X" is evil, and that
"X->new()" is the way to go. Can't remember his reasons. Something
about potential ambiguity in Perl 6 or something.
-shrug- Just my $0.02 from the peanut gallery,
j
From jhannah at omnihotels.com Wed Aug 17 07:21:32 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 17 Aug 2005 09:21:32 -0500
Subject: [Omaha.pm] Millionth SQL -> HTML table script
Message-ID: <200508171420.j7HEK2ic031176@omares-email.omnihotels.com>
This is probably the millionth time I've written a 10 minute program to dump the results of an SQL out to a web browser in an HTML table...
j
#!/usr/bin/perl
use strict;
use Omni::DB;
use CGI;
my $q = new CGI;
print
$q->header,
"Select Rewards: Work Queue?
\n";
my $dbh = Omni::DB::connect_prod();
my $strsql = <$strsql\n";
print "\n";
my $sth = $dbh->prepare($strsql);
$sth->execute;
my @row;
while (@row = $sth->fetchrow) {
for (@row) { s/\s+$//; }
print "";
print join " | ", @row;
print " |
\n";
}
$sth->finish;
print "
";
}
$dbh->disconnect;
From kthompson at omnihotels.com Wed Aug 17 07:52:05 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Wed, 17 Aug 2005 09:52:05 -0500
Subject: [Omaha.pm] Millionth SQL -> HTML table script
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0E98@exchange2k3.omnihotels.net>
Nice.
An addition nicety might be to add the column names as headers-
especially if you don't know what the column names are when you start
(like select * from blah):
The reason for instead of actual | is so that you could
potentially work in a 'print the columns names every x number of rows'
if you were going to dump a ton of rows.
Code:
sub print_SQL_and_results {
my ($strsql) = @_;
print "$strsql \n";
print "\n";
my $sth = $dbh->prepare($strsql);
$sth->execute;
my @row;
my $bHeadersPrinted;
while (my $haref = $sth->fetchrow_hashref()) {
my %hash = \$haref;
if (!$bHeadersPrinted) {
print " ";
foreach my $attr (keys %$haref) {
print " ".$attr." | ";
}
print " ";
$bHeadersPrinted = "Yuppers";
}
print " ";
foreach my $attr (sort keys %$haref) {
print " ".$haref->{$attr}." | ";
}
print " ";
}
$sth->finish;
print " ";
}
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Jay Hannah
Sent: Wednesday, August 17, 2005 9:22 AM
To: omaha-pm at pm.org
Subject: [Omaha.pm] Millionth SQL -> HTML table script
This is probably the millionth time I've written a 10 minute program to
dump the results of an SQL out to a web browser in an HTML table...
j
#!/usr/bin/perl
use strict;
use Omni::DB;
use CGI;
my $q = new CGI;
print
$q->header,
"Select Rewards: Work Queue?\n";
my $dbh = Omni::DB::connect_prod();
my $strsql = <$strsql\n";
print "\n";
my $sth = $dbh->prepare($strsql);
$sth->execute;
my @row;
while (@row = $sth->fetchrow) {
for (@row) { s/\s+$//; }
print "";
print join " | ", @row;
print " | \n";
}
$sth->finish;
print " ";
}
$dbh->disconnect;
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From jhannah at omnihotels.com Wed Aug 17 08:38:18 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 17 Aug 2005 10:38:18 -0500
Subject: [Omaha.pm] Excel -> text file
Message-ID: <200508171536.j7HFamic000871@omares-email.omnihotels.com>
I got sick of dealing with an archive full of Excel spreadsheets. Takes forever to find anything. So I spent 10m writing an .xls to text file dumping program.
Now I can grep my archive! Yay!
j
#!/usr/bin/perl
use strict;
use Spreadsheet::ParseExcel;
my $file = $ARGV[0];
die "Can't read file $file" unless (-r $file);
my $newfile = $file;
$newfile =~ s/\.xls$/\.unl/;
open (OUT, ">$newfile") or die "Can't write $newfile";
my $oExcel = Spreadsheet::ParseExcel->new();
my $oBook = $oExcel->Parse($file) or die "Can't parse Excel file '$file'";
my $oWks = $oBook->{Worksheet}[0];
my $row;
foreach $row ($oWks->{MinRow} .. $oWks->{MaxRow}) {
next if ($row == 0); # Header row
last unless ($oWks->{Cells}[$row][0]); # Blank line means stop
foreach my $col (0..20) {
my $value;
if ($oWks->{Cells}[$row][$col]) {
$value = $oWks->{Cells}[$row][$col]->Value;
}
print OUT "$value|";
}
print OUT "\n";
}
close OUT;
From jay at jays.net Wed Aug 17 20:43:36 2005
From: jay at jays.net (Jay Hannah)
Date: Wed, 17 Aug 2005 22:43:36 -0500
Subject: [Omaha.pm] Millionth SQL -> HTML table script
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0E98@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02DE0E98@exchange2k3.omnihotels.net>
Message-ID: <228e5bc102a4e8b0a99ad6abb1e5087d@jays.net>
On Aug 17, 2005, at 9:52 AM, Kenneth Thompson wrote:
> An addition nicety might be to add the column names as headers-
> especially if you don't know what the column names are when you start
> (like select * from blah):
Ya. Good patch. -grin-
> The reason for instead of actual | is so that you could
> potentially work in a 'print the columns names every x number of rows'
> if you were going to dump a ton of rows.
Why couldn't you do that w/ | 's ?
I often code that something like
print_header_row() unless ($rowcount % 30);
> sub print_SQL_and_results {
> my ($strsql) = @_;
>
> print "$strsql \n";
> print "\n";
> my $sth = $dbh->prepare($strsql);
> $sth->execute;
> my @row;
You don't use @row anywhere...?
> my $bHeadersPrinted;
> while (my $haref = $sth->fetchrow_hashref()) {
> my %hash = \$haref;
- Did you mean this?
%hash = %$haref;
- You don't use %hash anywhere, so I'm not sure why you pulled it.
> if (!$bHeadersPrinted) {
> print " ";
> foreach my $attr (keys %$haref) {
I'd call that $key or $column.
> print " ".$attr." | ";
> }
> print " ";
> $bHeadersPrinted = "Yuppers";
> }
> print " ";
> foreach my $attr (sort keys %$haref) {
> print " ".$haref->{$attr}." | ";
> }
You're getting it! Woo-hoo! Congrats!
Before:
print " ".$haref->{$attr}." | ";
After:
print " $$haref{$attr} | ";
(That's one nice thing about avoiding -> hash access syntax: you can do
$$hash{$key} straight in your double quotes.)
> print " ";
You might want to throw a \n in there too in case you want to view HTML
source some day.
> }
> $sth->finish;
> print " ";
> }
Good work!
$0.02,
j
From dan at linder.org Thu Aug 18 07:09:02 2005
From: dan at linder.org (Daniel Linder)
Date: Thu, 18 Aug 2005 09:09:02 -0500 (CDT)
Subject: [Omaha.pm] pm lister
In-Reply-To: <846f688bc93480cb48fa72a8d2c4e032@jays.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02BBEC78@exchange2k3.omnihotels.net>
<43026E84.2030901@metc.net>
<846f688bc93480cb48fa72a8d2c4e032@jays.net>
Message-ID: <26016.12.160.138.65.1124374142.squirrel@mail.linder.org>
> On Aug 16, 2005, at 5:53 PM, Noel Leistad wrote:
>> This is what I'm seeing, maybe I'm missing something after a
>> frustrating
>> day....
>>
>> #rpm -Uvh postgrey-1.21-0.noarch.rpm
>> error: Failed dependencies:
>> perl(BerkeleyDB) is needed by postgrey-1.21-0
>
>> cpan> install BerkeleyDB
>> BerkeleyDB is up to date.
I assume you are inferring that you then re-run the "rpm -Uvh..." again
and it complains about missing dependancies?
That's because RPM uses it's own internal database to track what other RPM
packages you have installed. The "failed dependencies" mean that the RPM
database doesn't have the various pre-packaged Perl RPMs installed.
I can see two routes around this:
1: Use the "force" option to install the 'postgrey' RPM to make it skip
doing the dependancy check. Not always the best option since a future
update could break the setup if you don't keep your manually installed
CPAN modules updated along with it.
2: Find the various missing dependencies as the RPM files (probably from
the same place you downloaded the postgrey RPM file) and install those.
You can put multiple .RPM files on the same "rpm -Uvh" line so it will
check that all install or all fail.
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
From jhannah at omnihotels.com Thu Aug 18 13:52:59 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Thu, 18 Aug 2005 15:52:59 -0500
Subject: [Omaha.pm] Another || quickie
Message-ID: <200508182051.j7IKpeic004650@omares-email.omnihotels.com>
BEFORE
my $type = "error";
$type = $args{type} if ($args{type});
AFTER
my $type = $args{type} || "error";
j
From jhannah at omnihotels.com Thu Aug 18 14:30:18 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Thu, 18 Aug 2005 16:30:18 -0500
Subject: [Omaha.pm] Yet another || quickie
Message-ID: <200508182128.j7ILSxic016649@omares-email.omnihotels.com>
BEFORE
my $text = $args{text};
$text = $error_codes->{$args{code}} if (!$text);
AFTER
my $text = $args{text} || $error_codes->{$args{code}};
j
From andy at petdance.com Thu Aug 18 14:55:07 2005
From: andy at petdance.com (Andy Lester)
Date: Thu, 18 Aug 2005 16:55:07 -0500
Subject: [Omaha.pm] Another || quickie
In-Reply-To: <200508182051.j7IKpeic004650@omares-email.omnihotels.com>
References: <200508182051.j7IKpeic004650@omares-email.omnihotels.com>
Message-ID: <20050818215507.GD3424@petdance.com>
On Thu, Aug 18, 2005 at 03:52:59PM -0500, Jay Hannah (jhannah at omnihotels.com) wrote:
>
> BEFORE
>
> my $type = "error";
> $type = $args{type} if ($args{type});
>
> AFTER
>
> my $type = $args{type} || "error";
Which is fine unless $args{type} is 0. :-/
Future Perls introduce the // operator, which does what you mean.
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From jay at jays.net Thu Aug 18 15:00:51 2005
From: jay at jays.net (Jay Hannah)
Date: Thu, 18 Aug 2005 17:00:51 -0500
Subject: [Omaha.pm] Another || quickie
In-Reply-To: <20050818215507.GD3424@petdance.com>
References: <200508182051.j7IKpeic004650@omares-email.omnihotels.com>
<20050818215507.GD3424@petdance.com>
Message-ID: <1b27cac81595566e41ea7c22e4b676bc@jays.net>
On Aug 18, 2005, at 4:55 PM, Andy Lester wrote:
> On Thu, Aug 18, 2005 at 03:52:59PM -0500, Jay Hannah
> (jhannah at omnihotels.com) wrote:
>>
>> BEFORE
>>
>> my $type = "error";
>> $type = $args{type} if ($args{type});
>>
>> AFTER
>>
>> my $type = $args{type} || "error";
>
> Which is fine unless $args{type} is 0. :-/
Ya, 0 catches me on occasion. In this case, though, BEFORE and AFTER
would both handle 0 the same way, correct?
> Future Perls introduce the // operator, which does what you mean.
Oooo... Is there a :-/ operator too? That looks fancy. -grin-
j
:)
From kthompson at omnihotels.com Fri Aug 19 10:57:12 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Fri, 19 Aug 2005 12:57:12 -0500
Subject: [Omaha.pm] Another || quickie
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B02ECBB5C@exchange2k3.omnihotels.net>
So if I understand this correctly:
This:
if ($oWkS->{Cells}[$iR][0]) {
if ($oWkS->{Cells}[$iR][0]->Value != "") {
$myVar = ($oWkS->{Cells}[$iR][0]->Value)
}
}
Is the same as this:
if (!$oWkS->{Cells}[$iR][0]) {}
elsif {$oWkS->{Cells}[$iR][0]->Value == "") {}
else {
$myVar = ($oWkS->{Cells}[$iR][0]->Value);
}
Which is shortcut(ed?) as this? :
My $t = (!$oWkS->{Cells}[$iR][0];
$myVar = ((!$t) || ($t->Value != "") || $t->Value);
Which appears to work. However, this article (http://tinyurl.com/a3pt7)
seems to say it's bad to do this for assignment and should only be used
for flow control. Do I need to be concerned?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050819/bd4058e5/attachment.html
From Scott.L.Miller at hp.com Fri Aug 19 14:20:30 2005
From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks))
Date: Fri, 19 Aug 2005 16:20:30 -0500
Subject: [Omaha.pm] Another || quickie
Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E96D@omaexc11.americas.cpqcorp.net>
I don't think you came away with the correct understanding of what that
snippet of text was saying.
What it was trying to say was you need to be a little bit careful when
using the || operator in an assignment statement because the || binds
more tightly than the =
This allows things like $a = $b || $c; to mean $a = $b when $b is
something that evaluates to true, and $a = $c when $b evaluates to
false. Which seems to be exactly what you're attempting to do in your
example below, so you're fine.
Where you might run into trouble is if you attempt to use || when doing
something like:
@array = split || die "nothing to split";
Because the || binds tighter than =, die will always be evaluated no
matter what might happen to exist in $_; split will do it's thing to $_,
and then the die will evaluate, halting your script.
In this case, you are trying to use || for flow control, not for
assignment. In this case, you want to use the 'or' keyword because it
binds less tightly than '=' and then the die will only be evaluated if
the assignment results in nothing being assigned.
DB<3> p $_
DB<4> @array = split or die "nothing to split";
nothing to split at (eval
44)[/usr/local/lib/perl5/5.6.1/perl5db.pl:1522] line 2.
DB<5> $_ = "this is a test";
DB<6> @array = split or die "nothing to split";
DB<7> p join " ", @array;
this is a test
-Scott
________________________________
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Kenneth Thompson
Sent: Friday, August 19, 2005 12:57 PM
To: Perl Mongers of Omaha, Nebraska USA
Subject: Re: [Omaha.pm] Another || quickie
So if I understand this correctly:
This:
if ($oWkS->{Cells}[$iR][0]) {
if ($oWkS->{Cells}[$iR][0]->Value != "") {
$myVar = ($oWkS->{Cells}[$iR][0]->Value)
}
}
Is the same as this:
if (!$oWkS->{Cells}[$iR][0]) {}
elsif {$oWkS->{Cells}[$iR][0]->Value == "") {}
else {
$myVar = ($oWkS->{Cells}[$iR][0]->Value);
}
Which is shortcut(ed?) as this? :
My $t = (!$oWkS->{Cells}[$iR][0];
$myVar = ((!$t) || ($t->Value != "") || $t->Value);
Which appears to work. However, this article (http://tinyurl.com/a3pt7)
seems to say it's bad to do this for assignment and should only be used
for flow control. Do I need to be concerned?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050819/c237295f/attachment.html
From Scott.L.Miller at hp.com Fri Aug 19 14:25:48 2005
From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks))
Date: Fri, 19 Aug 2005 16:25:48 -0500
Subject: [Omaha.pm] Another || quickie
Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E96E@omaexc11.americas.cpqcorp.net>
Oops, that wasn't completely correct, the || binding more tightly means
that it will force a scalar context onto the split, and if you ask split
for a scalar, it will tell you how many things it was able to split out,
so your assignment gets a scalar instead of the array.
DB<8> @array = split || die "nothing to split";
DB<9> p join " ", @array;
4
Not quite what we wanted...
-Scott
________________________________
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Miller, Scott L (Omaha Networks)
Sent: Friday, August 19, 2005 4:21 PM
To: Perl Mongers of Omaha, Nebraska USA
Subject: Re: [Omaha.pm] Another || quickie
I don't think you came away with the correct understanding of what that
snippet of text was saying.
What it was trying to say was you need to be a little bit careful when
using the || operator in an assignment statement because the || binds
more tightly than the =
This allows things like $a = $b || $c; to mean $a = $b when $b is
something that evaluates to true, and $a = $c when $b evaluates to
false. Which seems to be exactly what you're attempting to do in your
example below, so you're fine.
Where you might run into trouble is if you attempt to use || when doing
something like:
@array = split || die "nothing to split";
Because the || binds tighter than =, die will always be evaluated no
matter what might happen to exist in $_; split will do it's thing to $_,
and then the die will evaluate, halting your script.
In this case, you are trying to use || for flow control, not for
assignment. In this case, you want to use the 'or' keyword because it
binds less tightly than '=' and then the die will only be evaluated if
the assignment results in nothing being assigned.
DB<3> p $_
DB<4> @array = split or die "nothing to split";
nothing to split at (eval
44)[/usr/local/lib/perl5/5.6.1/perl5db.pl:1522] line 2.
DB<5> $_ = "this is a test";
DB<6> @array = split or die "nothing to split";
DB<7> p join " ", @array;
this is a test
-Scott
________________________________
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Kenneth Thompson
Sent: Friday, August 19, 2005 12:57 PM
To: Perl Mongers of Omaha, Nebraska USA
Subject: Re: [Omaha.pm] Another || quickie
So if I understand this correctly:
This:
if ($oWkS->{Cells}[$iR][0]) {
if ($oWkS->{Cells}[$iR][0]->Value != "") {
$myVar = ($oWkS->{Cells}[$iR][0]->Value)
}
}
Is the same as this:
if (!$oWkS->{Cells}[$iR][0]) {}
elsif {$oWkS->{Cells}[$iR][0]->Value == "") {}
else {
$myVar = ($oWkS->{Cells}[$iR][0]->Value);
}
Which is shortcut(ed?) as this? :
My $t = (!$oWkS->{Cells}[$iR][0];
$myVar = ((!$t) || ($t->Value != "") || $t->Value);
Which appears to work. However, this article (http://tinyurl.com/a3pt7)
seems to say it's bad to do this for assignment and should only be used
for flow control. Do I need to be concerned?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050819/32a3ff6e/attachment-0001.html
From jhannah at omnihotels.com Mon Aug 22 09:30:01 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Mon, 22 Aug 2005 11:30:01 -0500
Subject: [Omaha.pm] FW: SlimServer
Message-ID: <200508221628.j7MGSOic012388@omares-email.omnihotels.com>
-----Original Message-----
From: Sean J. Edwards
Sent: Friday, August 19, 2005 9:13 AM
To: Dave Thacker; Jay Hannah; Sean Baker; Kenneth Thompson
Subject: SlimServer
SlimServer is an mp3 streamer written in PERL. You can download it
here:
http://www.slimdevices.com/su_downloads.html
--
-=Sean Edwards=-
From jay at jays.net Mon Aug 22 19:38:44 2005
From: jay at jays.net (Jay Hannah)
Date: Mon, 22 Aug 2005 21:38:44 -0500
Subject: [Omaha.pm] Other Omaha User Groups
In-Reply-To:
References:
Message-ID:
On Aug 22, 2005, at 9:20 AM, Matt Secoske wrote:
> Anyone know of other IT User Groups in the Omaha area?? Thinking along
> the lines of Linux Users Group, etc.
I created a wiki page on the Omaha Perl Mongers wiki:
http://omaha.pm.org/kwiki/index.cgi?OmahaUserGroups
Feel free to add to it.
j
From jay at jays.net Mon Aug 22 19:55:18 2005
From: jay at jays.net (Jay Hannah)
Date: Mon, 22 Aug 2005 21:55:18 -0500
Subject: [Omaha.pm] Another || quickie
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02ECBB5C@exchange2k3.omnihotels.net>
References: <29AB736ABCE5C745ABF9C93B02F2C27B02ECBB5C@exchange2k3.omnihotels.net>
Message-ID: <9354d4f17ee925b65d5e77c49150ba09@jays.net>
On Aug 19, 2005, at 12:57 PM, Kenneth Thompson wrote:
> So if I understand this correctly:
> ?
> This:
> ?
> ??? if ($oWkS->{Cells}[$iR][0]) {
> ????? if ($oWkS->{Cells}[$iR][0]->Value != "") {
> ??????? $myVar = ($oWkS->{Cells}[$iR][0]->Value)
> ????? }
> ??? }
> ?
> Is the same as this:
> ?
> ??? if (!$oWkS->{Cells}[$iR][0]) {}
> ??? elsif {$oWkS->{Cells}[$iR][0]->Value == "") {}
> ??? else {
> ?????? $myVar = ($oWkS->{Cells}[$iR][0]->Value);
> ??? }
IMHO the 2nd is less readable.
> Which is shortcut(ed?) as this? :
> ?
> ??? My $t = (!$oWkS->{Cells}[$iR][0];
> ? ??$myVar = ((!$t) || ($t->Value != "") || $t->Value);
I think your unmatched ( and "My" will syntax error. Perhaps this?:
??? my $t = $oWkS->{Cells}[$iR][0];
? ??$myVar = $t->Value if ($t && $t->Value);
?
j
From Scott.L.Miller at hp.com Tue Aug 23 07:37:00 2005
From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks))
Date: Tue, 23 Aug 2005 09:37:00 -0500
Subject: [Omaha.pm] Another || quickie
Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E96F@omaexc11.americas.cpqcorp.net>
The last version below doesn't completely satisfy his original logic... Actually, maybe it does; because looking at it more closely, the original logic and the derived versions all have issues. Using the shorthand variable $t->Value, it is being numerically compared to an empty string, which can be a problem. An actual zero in $t->Value will fail to pass the original test because numerically the empty string is also zero; in fact all strings that do not start with a number will fail the 2nd if statement in the original version. Only strings that evaluate to a non-zero value will get past that 2nd if statement.
So, if $t->Value is supposed to have a string, we need to use the string comparison operations, eq and ne, for equal and not-equal respectively. Otherwise we should replace the "" with a zero.
Without further context I can't tell if this would actually cause problems in the logic of this snippet of code.
If we're attempting to test if $oWkS->{Cells}[$iR][0] is defined, which it looks like we are, then to make it easier to read later, we should be using a defined() test. We shouldn't be relying on the fact that if it is a valid pointer, the memory address residing in $t is not going to be zero.
Another subtle issue that could come up is that if $oWkS->{Cells} didn't even exist before this snippet, it will as soon as the if statement is hit. This nice little "feechur" is called auto-vivification. Read up on it if you haven't heard about it before.
-Scott
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf Of Jay Hannah
Sent: Monday, August 22, 2005 9:55 PM
To: Perl Mongers of Omaha, Nebraska USA
Subject: Re: [Omaha.pm] Another || quickie
On Aug 19, 2005, at 12:57 PM, Kenneth Thompson wrote:
> So if I understand this correctly:
> ?
> This:
> ?
> ??? if ($oWkS->{Cells}[$iR][0]) {
> ????? if ($oWkS->{Cells}[$iR][0]->Value != "") {
> ??????? $myVar = ($oWkS->{Cells}[$iR][0]->Value)
> ????? }
> ??? }
> ?
> Is the same as this:
> ?
> ??? if (!$oWkS->{Cells}[$iR][0]) {}
> ??? elsif {$oWkS->{Cells}[$iR][0]->Value == "") {}
> ??? else {
> ?????? $myVar = ($oWkS->{Cells}[$iR][0]->Value);
> ??? }
IMHO the 2nd is less readable.
> Which is shortcut(ed?) as this? :
> ?
> ??? My $t = (!$oWkS->{Cells}[$iR][0];
> ? ??$myVar = ((!$t) || ($t->Value != "") || $t->Value);
I think your unmatched ( and "My" will syntax error. Perhaps this?:
??? my $t = $oWkS->{Cells}[$iR][0];
? ??$myVar = $t->Value if ($t && $t->Value);
?
j
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From kthompson at omnihotels.com Tue Aug 23 08:28:31 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Tue, 23 Aug 2005 10:28:31 -0500
Subject: [Omaha.pm] Another || quickie
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B02ECC91E@exchange2k3.omnihotels.net>
Lol- which is what it ended up being, I just didn't include it since it was about && and not || ;)
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf Of Jay Hannah
Sent: Monday, August 22, 2005 9:55 PM
To: Perl Mongers of Omaha, Nebraska USA
Subject: Re: [Omaha.pm] Another || quickie
On Aug 19, 2005, at 12:57 PM, Kenneth Thompson wrote:
> So if I understand this correctly:
> ?
> This:
> ?
> ??? if ($oWkS->{Cells}[$iR][0]) {
> ????? if ($oWkS->{Cells}[$iR][0]->Value != "") {
> ??????? $myVar = ($oWkS->{Cells}[$iR][0]->Value)
> ????? }
> ??? }
> ?
> Is the same as this:
> ?
> ??? if (!$oWkS->{Cells}[$iR][0]) {}
> ??? elsif {$oWkS->{Cells}[$iR][0]->Value == "") {}
> ??? else {
> ?????? $myVar = ($oWkS->{Cells}[$iR][0]->Value);
> ??? }
IMHO the 2nd is less readable.
> Which is shortcut(ed?) as this? :
> ?
> ??? My $t = (!$oWkS->{Cells}[$iR][0];
> ? ??$myVar = ((!$t) || ($t->Value != "") || $t->Value);
I think your unmatched ( and "My" will syntax error. Perhaps this?:
??? my $t = $oWkS->{Cells}[$iR][0];
? ??$myVar = $t->Value if ($t && $t->Value);
?
j
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From rps at willconsult.com Wed Aug 24 07:47:35 2005
From: rps at willconsult.com (Ryan Stille)
Date: Wed, 24 Aug 2005 09:47:35 -0500
Subject: [Omaha.pm] Changing the current database in DBI
Message-ID: <9A8B75E3985324438F1BFA08B160E8203FEF8D@suxsvr.willconsult.com>
I have a perl script that goes through a list of mysql databases and
does things. It gets the list of databases from the SHOW DATABASES
command.
As I go through and issue SQL commands in each database, I use
$dbh->do("USE $database"); to change databases.
This worked fine until I added some databases with dashes in their
names. Now when the script runs I get:
DBD::mysql::db do failed: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near '-clientvars' at line 1 at /usr/sbin/mysql_backup.pl
line 27.
I tried adding single quotes around $database, but that didn't help. If
I use the mysql command line interface, I can use the USE command with
or without quotes, on any database, and it works fine.
Is there perhaps a DBI method I should be using to switch databases?
Thanks,
-Ryan
From kthompson at omnihotels.com Wed Aug 24 08:15:17 2005
From: kthompson at omnihotels.com (Kenneth Thompson)
Date: Wed, 24 Aug 2005 10:15:17 -0500
Subject: [Omaha.pm] Changing the current database in DBI
Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B02F32BAA@exchange2k3.omnihotels.net>
Shot in the dark here- but is it a DBI issue, or an SQL issue? Most ANSI
compliant sql db's use [] to enclose object names which don't comply...
so I'd try :
$dbh->do("USE [$database]");
Hth
Kenn
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Ryan Stille
Sent: Wednesday, August 24, 2005 9:48 AM
To: omaha-pm at pm.org
Subject: [Omaha.pm] Changing the current database in DBI
I have a perl script that goes through a list of mysql databases and
does things. It gets the list of databases from the SHOW DATABASES
command.
As I go through and issue SQL commands in each database, I use
$dbh->do("USE $database"); to change databases.
This worked fine until I added some databases with dashes in their
names. Now when the script runs I get:
DBD::mysql::db do failed: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near '-clientvars' at line 1 at /usr/sbin/mysql_backup.pl
line 27.
I tried adding single quotes around $database, but that didn't help. If
I use the mysql command line interface, I can use the USE command with
or without quotes, on any database, and it works fine.
Is there perhaps a DBI method I should be using to switch databases?
Thanks,
-Ryan
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From jhannah at omnihotels.com Wed Aug 24 12:00:44 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 24 Aug 2005 14:00:44 -0500
Subject: [Omaha.pm] Find all files containing '\n\n'
Message-ID: <200508241859.j7OIxQic019839@omares-email.omnihotels.com>
$ cat j.pl
while (<>) {
chomp;
local $/ = undef;
open IN, $_;
$file = ;
print "$_\n" if ($file =~ m#\n\n#);
}
$ find ./ | perl j.pl
./Web/lib/Waitlist/header.entry.html
./Web/lib/Waitlist/header.report.html
./Web/lib/Perseus/debug.AvailResp
./Web/lib/Perseus/Reports/header.Reports.html
./Web/lib/Procurement/header.admin.html
./Web/lib/column_title.html
./Web/lib/Rewards/header.billing.html
./Web/lib/Surveys/header.admin.html
./Web/lib/SessionControl/record.travelagent.html
Cheers,
j
From rps at willconsult.com Wed Aug 24 12:13:10 2005
From: rps at willconsult.com (Ryan Stille)
Date: Wed, 24 Aug 2005 14:13:10 -0500
Subject: [Omaha.pm] Changing the current database in DBI
Message-ID: <9A8B75E3985324438F1BFA08B160E8203FEF98@suxsvr.willconsult.com>
Kenneth Thompson wrote:
> Shot in the dark here- but is it a DBI issue, or an SQL
> issue? Most ANSI compliant sql db's use [] to enclose object
> names which don't comply...
> so I'd try :
>
> $dbh->do("USE [$database]");
Thanks, but that didn't work either.
Any other ideas? By backups are going to fail again tonight unless I
get this figured out...
-Ryan
From jhannah at omnihotels.com Wed Aug 24 12:21:12 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Wed, 24 Aug 2005 14:21:12 -0500
Subject: [Omaha.pm] Find all files containing '\n\n'
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02F32E2A@exchange2k3.omnihotels.net>
Message-ID: <200508241919.j7OJJsic013304@omares-email.omnihotels.com>
From: Kenneth Thompson
> Isn't this the same as
>
> fgrep -drecurse "\n\n" *
>
> ?
Apparently not...
$ find ./ | perl j.pl
./Web/lib/Waitlist/header.entry.html
./Web/lib/Waitlist/header.report.html
./Web/lib/Perseus/debug.AvailResp
./Web/lib/Perseus/Reports/header.Reports.html
./Web/lib/Procurement/header.admin.html
./Web/lib/column_title.html
./Web/lib/Rewards/header.billing.html
./Web/lib/Surveys/header.admin.html
./Web/lib/SessionControl/record.travelagent.html
$ fgrep -drecurse "\n\n" *
j.pl: print "$_\n" if ($file =~ m#\n\n#);
grep: Web/lib/FG/Guest/.detail.SG6_1_4.html.swp: Permission denied
grep: Web/cgi-bin/secure/.grl.pl.swp: Permission denied
Before writing that little Perl thingy I first tried grep -E, but it didn't see "\n" as newline... -shrug-
j
From Scott.L.Miller at hp.com Wed Aug 24 12:44:11 2005
From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks))
Date: Wed, 24 Aug 2005 14:44:11 -0500
Subject: [Omaha.pm] Changing the current database in DBI
Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E972@omaexc11.americas.cpqcorp.net>
Have you tried escaping the '-'? Various characters need to be escaped
when they are part of an sql query/command... Since I haven't had to
do much with SQL from perl, I'm not entirely sure how to go about it,
but I'm guessing a single \ character is probably not going to do it
correctly, but I could be wrong.
-Scott
-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Ryan Stille
Sent: Wednesday, August 24, 2005 2:13 PM
To: Perl Mongers of Omaha, Nebraska USA
Subject: Re: [Omaha.pm] Changing the current database in DBI
Kenneth Thompson wrote:
> Shot in the dark here- but is it a DBI issue, or an SQL
> issue? Most ANSI compliant sql db's use [] to enclose object
> names which don't comply...
> so I'd try :
>
> $dbh->do("USE [$database]");
Thanks, but that didn't work either.
Any other ideas? By backups are going to fail again tonight unless I
get this figured out...
-Ryan
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
From rps at willconsult.com Wed Aug 24 14:54:34 2005
From: rps at willconsult.com (Ryan Stille)
Date: Wed, 24 Aug 2005 16:54:34 -0500
Subject: [Omaha.pm] Changing the current database in DBI
Message-ID: <9A8B75E3985324438F1BFA08B160E8203FEF9C@suxsvr.willconsult.com>
I figured it out. I needed to quote it with backticks (`).
http://dev.mysql.com/doc/mysql/en/legal-names.html
Thanks,
-Ryan
From jhannah at omnihotels.com Fri Aug 26 11:38:20 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Fri, 26 Aug 2005 13:38:20 -0500
Subject: [Omaha.pm] TT algebra, format
Message-ID: <200508261836.j7QIaoic029534@omares-email.omnihotels.com>
I was just asked how to do algebra and format stuff in Template Toolkit.
Here's the example I gave him. I think it's valid. It may be one-linerable but I've learned not to struggle to compress TT syntax nearly as much as I compress my Perl...
j
[% a = b / 2;
a = a | format('0.2f');
%]
From jhannah at omnihotels.com Fri Aug 26 15:30:39 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Fri, 26 Aug 2005 17:30:39 -0500
Subject: [Omaha.pm] Changed Permissions->has_permission
In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B02F818D8@exchange2k3.omnihotels.net>
Message-ID: <200508262229.j7QMTAic025593@omares-email.omnihotels.com>
> Dunno if this is good or bad... but it works. Ok?
Before
$o_user_attrib->get_subsystem eq $subsystem or
$o_user_attrib->get_subsystem eq 'ALL' or
$o_user_attrib->get_subsystem eq 'OMARES' or
$o_user_attrib->get_subsystem eq 'DALCOR'
After?
$o_user_attrib->get_subsystem =~ /^($subsytem|ALL|OMARES|DALCOR)$/
$0.02,
j
From jhannah at omnihotels.com Fri Aug 26 16:51:37 2005
From: jhannah at omnihotels.com (Jay Hannah)
Date: Fri, 26 Aug 2005 18:51:37 -0500
Subject: [Omaha.pm] return from sub: array vs. arrayref
Message-ID: <200508262350.j7QNo9ic025898@omares-email.omnihotels.com>
The ? was posed to me: Why would you ever return a single array ref from a sub? Why not just return an array?
One possible argument is efficiency/speed: arrayrefs can be faster if you have huge (or huge number of) arrays you're returning. Save Perl one forced copy/clear of an array.
j
j.pl:
---
use Benchmark qw(:all) ;
timethese(100000, {
'array' => 'loop_array()',
'arrayref' => 'loop_arrayref()'
});
sub loop_array {
my @a = return_array();
foreach (@a) { $_; }
}
sub return_array {
@ret = 1..100;
return @ret;
}
sub loop_arrayref {
my $a = return_arrayref();
foreach (@$a) { $_; }
}
sub return_arrayref {
@ret = 1..100;
return \@ret;
}
---
$ perl j.pl
Benchmark: timing 100000 iterations of array, arrayref...
array: 8 wallclock secs ( 8.28 usr + 0.00 sys = 8.28 CPU) @ 12077.29/s (n=100000)
arrayref: 3 wallclock secs ( 4.83 usr + 0.00 sys = 4.83 CPU) @ 20703.93/s (n=100000)
From jay at jays.net Fri Aug 26 21:06:46 2005
From: jay at jays.net (Jay Hannah)
Date: Fri, 26 Aug 2005 23:06:46 -0500
Subject: [Omaha.pm] Got our free Make Mag!
Message-ID:
Sweet! Got our free sample mag from O'Reilly. Thick! I'll bring it to
the next mtg.
http://www.makezine.com/
j
From jay at jays.net Sun Aug 28 18:33:14 2005
From: jay at jays.net (Jay Hannah)
Date: Sun, 28 Aug 2005 20:33:14 -0500
Subject: [Omaha.pm] Business cards
Message-ID:
http://omaha.pm.org/kwiki/?BusinessCards
Thoughts? Feedback welcome on the wiki and/or on the list(s).
j
Omaha.pm
From dan at linder.org Mon Aug 29 07:37:51 2005
From: dan at linder.org (Daniel Linder)
Date: Mon, 29 Aug 2005 09:37:51 -0500 (CDT)
Subject: [Omaha.pm] Business cards
In-Reply-To:
References:
Message-ID: <25597.12.160.138.65.1125326271.squirrel@mail.linder.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sun, August 28, 2005 20:33, Jay Hannah wrote:
> http://omaha.pm.org/kwiki/?BusinessCards
>
> Thoughts? Feedback welcome on the wiki and/or on the list(s).
I like them.? I agree with the comments that Joshua made -- I'm not
great at layout/grammar/content, but I think he's on to something with the
tweaks.
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)
iD8DBQFDEx2/srDMR0/em2gRAmhPAJwMyV2FzpdA9BTrQMz+yhot1cG3ZQCg0Pce
xSY30EttUrRxNxJkKOGMumQ=
=qPAT
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050829/0cd0ef43/attachment.html
From jay at jays.net Mon Aug 29 08:06:20 2005
From: jay at jays.net (Jay Hannah)
Date: Mon, 29 Aug 2005 10:06:20 -0500
Subject: [Omaha.pm] [pm_groups] Business cards
In-Reply-To: <20050829141822.GA3553@bybent.com>
References:
<20050829141822.GA3553@bybent.com>
Message-ID: <578fb2ddf855a7d16176178846432522@jays.net>
> On Sun, Aug 28, 2005 at 08:33:14PM -0500, Jay Hannah wrote:
>> http://omaha.pm.org/kwiki/?BusinessCards
>>
>> Thoughts? Feedback welcome on the wiki and/or on the list(s).
On Aug 29, 2005, at 9:18 AM, Wayne Walker wrote:
> I suspect we need permission from O'Rielly to use the camel.
>
> But I like them :)
Yes. I've asked "permissions at oreilly.com" about that.
j
From jay at jays.net Mon Aug 29 12:40:05 2005
From: jay at jays.net (Jay Hannah)
Date: Mon, 29 Aug 2005 14:40:05 -0500
Subject: [Omaha.pm] [pm_groups] Business cards
In-Reply-To: <20050829154538.GO66116@perlguy.com>
References:
<20050829141822.GA3553@bybent.com>
<578fb2ddf855a7d16176178846432522@jays.net>
<20050829154538.GO66116@perlguy.com>
Message-ID: <5ed16005eab0625843a99d07db264d53@jays.net>
On Aug 29, 2005, at 10:45 AM, Kevin Meltzer wrote:
> http://www.perlfoundation.org/legal/trademark.html
Weird. It says all links should go to perl.org. Then perl.org has 2
camels on it. favicon.ico and in the bottom right corner...
j
Omaha.pm
From chlo.prog at gmail.com Tue Aug 30 15:37:27 2005
From: chlo.prog at gmail.com (r c)
Date: Tue, 30 Aug 2005 17:37:27 -0500
Subject: [Omaha.pm] Perl training
Message-ID: <5e2006d10508301537df6c65f@mail.gmail.com>
Does anyone know of any good Perl training classes? Something from
intermediate to advanced/object oriented. It doesn't matter if it's in
Omahaor not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20050830/879257ee/attachment.html
From andy at petdance.com Tue Aug 30 15:48:41 2005
From: andy at petdance.com (Andy Lester)
Date: Tue, 30 Aug 2005 17:48:41 -0500
Subject: [Omaha.pm] Perl training
In-Reply-To: <5e2006d10508301537df6c65f@mail.gmail.com>
References: <5e2006d10508301537df6c65f@mail.gmail.com>
Message-ID: <20050830224841.GA25840@petdance.com>
On Tue, Aug 30, 2005 at 05:37:27PM -0500, r c (chlo.prog at gmail.com) wrote:
> Does anyone know of any good Perl training classes? Something from
> intermediate to advanced/object oriented. It doesn't matter if it's in
> Omahaor not.
Well, there's this one that I was going to teach:
http://www.bignerdranch.com/about/perl1005pr.shtml
http://www.bignerdranch.com/classes/perl.shtml
Unless we have a lot of people who sign up real soon, it's going to get
pushed back to 2006. Contact BNR and tell them you're interested.
xoa
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
From omaha.pm.knitter at recursor.net Tue Aug 30 16:02:48 2005
From: omaha.pm.knitter at recursor.net (omaha.pm.knitter@recursor.net)
Date: Tue, 30 Aug 2005 18:02:48 -0500
Subject: [Omaha.pm] Opera web browser free registration today
In-Reply-To: <20050830224841.GA25840@petdance.com>
References: <5e2006d10508301537df6c65f@mail.gmail.com>
<5e2006d10508301537df6c65f@mail.gmail.com>
Message-ID: <3.0.6.32.20050830180248.0093ba30@pop.radiks.net>
Opera is celebrating their tenth aniversary by giving out free
registration codes, today only (they're in norway, so 'today' may end
before or after midnight. )
http://my.opera.com/community/party/reg.dml
-Sidney
From jay at jays.net Tue Aug 30 18:26:51 2005
From: jay at jays.net (Jay Hannah)
Date: Tue, 30 Aug 2005 20:26:51 -0500
Subject: [Omaha.pm] Opera web browser free registration today
In-Reply-To: <3.0.6.32.20050830180248.0093ba30@pop.radiks.net>
References: <5e2006d10508301537df6c65f@mail.gmail.com>
<5e2006d10508301537df6c65f@mail.gmail.com>
<3.0.6.32.20050830180248.0093ba30@pop.radiks.net>
Message-ID: <7df04e7c22a5f25653714acf33ee3df1@jays.net>
On Aug 30, 2005, at 6:02 PM, omaha.pm.knitter at recursor.net wrote:
> Opera is celebrating their tenth aniversary by giving out free
> registration codes, today only (they're in norway, so 'today' may end
> before or after midnight. )
>
> http://my.opera.com/community/party/reg.dml
I like supporting Opera by letting their little strip of banner ads
run. Sometimes I even click one. -grin-
j
| |