[22557] in Perl-Users-Digest
Perl-Users Digest, Issue: 4778 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 28 18:06:03 2003
Date: Fri, 28 Mar 2003 15:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 28 Mar 2003 Volume: 10 Number: 4778
Today's topics:
Re: CGI.pm or roll-your-own? <johnsen@eskimo.com>
Re: CGI.pm or roll-your-own? <dha@panix.com>
Re: CGI.pm or roll-your-own? (William C. Ray)
Re: CGI.pm or roll-your-own? <me@privacy.net>
Re: CGI.pm or roll-your-own? <uri@stemsystems.com>
Re: CGI.pm or roll-your-own? <me@privacy.net>
Re: CGI.pm or roll-your-own? <me@privacy.net>
confused about tie <mfield@ernie.botany.ubc.ca>
counting repetition in an array with Perl (Justin)
Re: counting repetition in an array with Perl <me@verizon.invalid>
CPAN Sloooooww <bigus NO @ SPAM creationfactor .net>
Re: CPAN Sloooooww <tassilo.parseval@rwth-aachen.de>
DBD-ODBC <bigus NO @ SPAM creationfactor .net>
Re: DBD-ODBC <bigus NO @ SPAM creationfactor .net>
DBI problem <bigus NO @ SPAM creationfactor .net>
how to turn these 2 steps into 1 <no_email@none.abc>
Re: how to turn these 2 steps into 1 <abigail@abigail.nl>
I wrote a module! <pfeiffer@iu-bremen.de>
implicit vs explicit variable usage in loop w/ range re (Upstart)
Re: implicit vs explicit variable usage in loop w/ rang (Malcolm Dew-Jones)
Re: make error loading module via 'cpan' <none@none.com>
Re: make error loading module via 'cpan' <nobull@mail.com>
Re: make error loading module via 'cpan' <none@none.com>
match this except if it's between that <user@someserver123abc.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 28 Mar 2003 18:45:19 GMT
From: Brian Johnsen <johnsen@eskimo.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <HCH2rJ.C02@news.boeing.com>
ray@soyokaze.biosci.ohio-state.edu (William C. Ray) wrote in
news:b5vpff$qf5@soyokaze.biosci.ohio-state.edu:
> Traditional Macintosh users migrating to OS X are a very strange
> phenomenon, and in many ways they tend to "Think Different". I'll
> not for a moment suggest that using CGI.pm _is_ harder, but from
If you're teaching CGI stuff, then your students, at some point or
another, are going to be putting scripts on a server somewhere on a
network. Right?
If one of your students put a hand rolled script on *my* ISPs
server with security holes large enough to fly a C17 through and my
ISP gets 'rm -rf /*'d by way of this script, I'll be very miffed at
them, at your publisher, your collaborators, you
and the horse you rode in on.
> I spend a good
> portion of the command-line chapters trying to educate the readers
> regarding the Unix culture that they've suddenly been dropped into,
> and how to behave like conscientious citizens in the culture, and
Please try to get though the message that when they are messing
around in networks, it affects more than just their own pretty new
MacIntosh. Teach the stuff that's been debugged as far as possible.
--
Brian Johnsen johnsen@eskimo.com http://fighterkites.org
------------------------------
Date: Fri, 28 Mar 2003 19:49:28 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <slrnb899q8.i9g.dha@panix2.panix.com>
In article <b61pq7$t9vl$1@ID-184292.news.dfncis.de>, Gunnar Hjalmarsson wrote:
> David H. Adler wrote:
>> In article <b61mnp$sqcm$1@ID-184292.news.dfncis.de>, Gunnar Hjalmarsson wrote:
>>>Without arguing against the use of CGI.pm, I find the discussion about
>>>it far too polarized.
>>
>> I'm not sure it's polarized enough, actually.
>> [snip]
>> If, however, you're writing code
>> that is actually going to be used by people, you should either really
>> know what you're doing or use code written by people who do.
>
> The latest CGI thing I wrote without using CGI.pm is a CGI module:
> http://www.cpan.org/modules/by-authors/id/G/GU/GUNNAR/
>
> It's a trivial module, and I believe that the code is good enough for
> its purpose. Nevertheless, please feel free to criticize it, and let
> me know if I know what I'm doing. Maybe, if you would find a security
> hole or something, you'd shut my mouth on this topic. Maybe. ;-)
Are you kidding? I'm one of the people who knows better than to write
his own code for CGI. :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
however, if people don't like Perl, they don't have to use it. they
can stay at the office solving their problems while the Perl Mongers
go out and drink. ;) - brian d foy in c.l.p.misc
------------------------------
Date: 28 Mar 2003 17:05:45 -0500
From: ray@soyokaze.biosci.ohio-state.edu (William C. Ray)
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b62gvp$ge@soyokaze.biosci.ohio-state.edu>
In article <HCH2rJ.C02@news.boeing.com>,
Brian Johnsen <johnsen@eskimo.com> wrote:
>ray@soyokaze.biosci.ohio-state.edu (William C. Ray) wrote in
>news:b5vpff$qf5@soyokaze.biosci.ohio-state.edu:
>
>> Traditional Macintosh users migrating to OS X are a very strange
>> phenomenon, and in many ways they tend to "Think Different". I'll
>> not for a moment suggest that using CGI.pm _is_ harder, but from
>
> If you're teaching CGI stuff, then your students, at some point or
>another, are going to be putting scripts on a server somewhere on a
>network. Right?
Yes, and no. The explicit assumption is that they're using Apache
from their own machine, connecting to it from their own machine,
and risking, if they choose to ignore security issues, their own
machine.
> If one of your students put a hand rolled script on *my* ISPs
>server with security holes large enough to fly a C17 through and my
>ISP gets 'rm -rf /*'d by way of this script, I'll be very miffed at
>them, at your publisher, your collaborators, you
> and the horse you rode in on.
If your ISP allows user scripts to rm -rf anything
important, they, and the horse they rode in upon deserve all the
miffing you care to send their way. Basing your system security on
the ludicrous hope that no user will ever make a mistake is just
plain stupid.
>> I spend a good
>> portion of the command-line chapters trying to educate the readers
>> regarding the Unix culture that they've suddenly been dropped into,
>> and how to behave like conscientious citizens in the culture, and
>
> Please try to get though the message that when they are messing
> around in networks, it affects more than just their own pretty new
> MacIntosh. Teach the stuff that's been debugged as far as possible.
Teaching the readers to be conscientious of computer and network
security issues, and to behave as responsible network citizens is
one of my primary concerns when writing. I won't however treat
the readers like idiots just because some more seasoned members
of the online community think that they're a bunch of dangerous
poseurs. If we only taught them about the stuff that's been
debugged to the Nth degree, they wouldn't learn anything.
I agree that John's cautioning readers that CGI.pm might be more
complex than they're going to be comfortable with, is not the
right way to put things, but I don't agree that it's the place
of OS topics survey books to teach formal, production-grade
programming topics. It's bad form to teach poor practices, and
dangerous techniques, but The role of this book is to provide an
overview of system capabilities, give enough samples that to
convince the reader that they're interested in learning more, and
then to point them at the appropriate resources where they can
learn good programming habits, etc. It's Randal's job to write
books that teach production-grade coding practices.
Will Ray
coauthor, MacOS X Unleashed
------------------------------
Date: Sat, 29 Mar 2003 09:39:52 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b62ivp$10lfq$1@ID-172104.news.dfncis.de>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:b61pq7$t9vl$1@ID-184292.news.dfncis.de...
> The latest CGI thing I wrote without using CGI.pm is a CGI module:
> http://www.cpan.org/modules/by-authors/id/G/GU/GUNNAR/
>
> It's a trivial module, and I believe that the code is good enough for
> its purpose. Nevertheless, please feel free to criticize it, and let
> me know if I know what I'm doing. Maybe, if you would find a security
> hole or something, you'd shut my mouth on this topic. Maybe. ;-)
Here's the relevant sub from the module
sub readform {
%in = ();
read STDIN, my $input, $ENV{'CONTENT_LENGTH'};
$input =~ s/\+/ /g;
for (split /&/, $input) {
my ($name, $value) = split /=/;
$value =~ s/%(..)/pack 'c', hex $1/ge;
$in{$name} = $value;
}
# trim whitespace in message headers
for (qw/name email subject/) {
$in{$_} =~ s/^\s+//;
$in{$_} =~ s/\s+$//;
$in{$_} =~ s/\s+/ /g;
}
# Windows fix
$in{'message'} =~ s/\r\n/\n/g;
}
1. Only supports POST requests.
2. Open to buffer overflows.
3. Doesn't handle ; as a parameter separator
And probably a few others that more CGI savvy people will know.
------------------------------
Date: Fri, 28 Mar 2003 22:54:30 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <x7znnf2jbt.fsf@mail.sysarch.com>
>>>>> "WCR" == William C Ray <ray@soyokaze.biosci.ohio-state.edu> writes:
WCR> Yes, and no. The explicit assumption is that they're using Apache
WCR> from their own machine, connecting to it from their own machine,
WCR> and risking, if they choose to ignore security issues, their own
WCR> machine.
but they are newbies who don't know anything about security. why give
them a possible hole to create at all? assuming (even explicitly) that
their machine is safe is not a good idea to put into their heads.
WCR> I agree that John's cautioning readers that CGI.pm might be more
WCR> complex than they're going to be comfortable with, is not the
WCR> right way to put things, but I don't agree that it's the place
WCR> of OS topics survey books to teach formal, production-grade
WCR> programming topics. It's bad form to teach poor practices, and
WCR> dangerous techniques, but The role of this book is to provide an
WCR> overview of system capabilities, give enough samples that to
WCR> convince the reader that they're interested in learning more, and
WCR> then to point them at the appropriate resources where they can
WCR> learn good programming habits, etc. It's Randal's job to write
WCR> books that teach production-grade coding practices.
i don't see how you can claim cgi.pm is complex. the basic operation to
get params which is all you need to do many cgi things is so simple. it
just can't get simpler. teaching a newbie that using a standard (and it
is standard with perl these days as has been pointed out) is as valuable
as anything else. perl is as much about using existing modules (think
cpan and why it is so useful. it is one of the major reasons for perl's
success) as it is about coding.
use GCI qw( :standard ) ;
my $foo_val = param( 'foo' ) ;
if you call that complex or can think of any possible way to make it
simpler i will be amazed. it is not a matter about learning how to parse
cgi as that is known to be tricky and fraught with dangers. it is a
matter of showing how simple it is to create a basic cgi script in perl.
beginners need simple working things and the fact that there be daemons
behind the curtain is fine. you tell them not to look there.
later, when they even understand the whole cgi flow (as someone else
pointed out in this thread), they can be told about cgi parsing issues
and told they can experiment and learn how to do it for EDUCATIONAL
reasons only. anything real should use the standard module. and bringing
up speed issues to a newbie is also a bad thing. getting it right is
much more important than premature optimization.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 29 Mar 2003 09:57:49 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b62k1d$19431$1@ID-172104.news.dfncis.de>
"William C. Ray" <ray@soyokaze.biosci.ohio-state.edu> wrote in message
news:b62gvp$ge@soyokaze.biosci.ohio-state.edu...
> In article <HCH2rJ.C02@news.boeing.com>,
> Brian Johnsen <johnsen@eskimo.com> wrote:
> >ray@soyokaze.biosci.ohio-state.edu (William C. Ray) wrote in
> >news:b5vpff$qf5@soyokaze.biosci.ohio-state.edu:
> >
> >> Traditional Macintosh users migrating to OS X are a very strange
> >> phenomenon, and in many ways they tend to "Think Different". I'll
> >> not for a moment suggest that using CGI.pm _is_ harder, but from
> >
> > If you're teaching CGI stuff, then your students, at some point or
> >another, are going to be putting scripts on a server somewhere on a
> >network. Right?
>
> Yes, and no. The explicit assumption is that they're using Apache
> from their own machine, connecting to it from their own machine,
> and risking, if they choose to ignore security issues, their own
> machine.
But the problem is that they won't know what the security issues are.
Getting CGI/Security right is very difficult.
>
> > If one of your students put a hand rolled script on *my* ISPs
> >server with security holes large enough to fly a C17 through and my
> >ISP gets 'rm -rf /*'d by way of this script, I'll be very miffed at
> >them, at your publisher, your collaborators, you
> > and the horse you rode in on.
>
> If your ISP allows user scripts to rm -rf anything
> important, they, and the horse they rode in upon deserve all the
> miffing you care to send their way. Basing your system security on
> the ludicrous hope that no user will ever make a mistake is just
> plain stupid.
But it is much better to give the students tools that will reduce the
likelyhood of security blunders.
------------------------------
Date: Sat, 29 Mar 2003 10:02:05 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b62k9d$15opv$1@ID-172104.news.dfncis.de>
"Edwin Horneij" <usenet@delete.orange-triangle.net> wrote in message
news:fNRga.238422$3D1.126800@sccrnsc01...
> The reason beginners don't like to use CGI.pm is because, for a
> beginner, the documentation is incomprehensible.
Really! There are loads of simple examples, which I would have thought
would be simple enough to follow.
>
> Also, if the beginner is coming from a background in a specialized web
> scripting language like PHP, CGI support is built into the language.
> Someone like that thinks of external modules as something to use for
> highly specialized purposes, but thinks of CGI as core functionality.
CGI is part of the Perl core.
> I'm still a beginner, so trust me on this.
As a Perl beginner (a few years ago), I quickly recognised the value of
using well written modules to make my life much easier.
------------------------------
Date: Fri, 28 Mar 2003 14:52:43 -0800
From: mfield <mfield@ernie.botany.ubc.ca>
Subject: confused about tie
Message-Id: <3E84D23B.137B9C20@ernie.botany.ubc.ca>
Hi, I am new to the tie thing so this question may be way off but here
it goes.
I have a perl script (CGI) that runs a whole bunch of times and each
time it needs to add a new key/value combination to a global hash. I
need the script to actually tie the hash the first time the script is
run in a session but to simply add to the hash every time after this. I
have tried things like:
if (!%hash)
{
$db = tie %hash, DB_File, "myhash", O_RDWR|O_CREAT, 0640 || &Webdie
("Can't tie DB_FILE: $!");
}
....
but I seem to enter this case every time. Is what I'm trying to do
possible with tie? Is the syntax correct? Is there a better way? Thanks
and sorry if this is a stupid question but I'm stuck.
Matt
------------------------------
Date: 28 Mar 2003 10:29:17 -0800
From: justingrondines@hotmail.com (Justin)
Subject: counting repetition in an array with Perl
Message-Id: <a595fb13.0303281029.110a765@posting.google.com>
Hi! I just begin to learn Perl and need some help here. I work on
windows 2000
with perl5.8.
I have 1 database that contains 2 fields: gestionnal age and birth
weight.
Now, i want to sort the file by GA and BW, and add an extra variable
who will count the number of repetition ( i dont want duplicate in my
output file).
The sorting is done, but i need hints for the next step.
Here my code:
$InPut = 'C:\growth1.txt';
$OutPut = 'C:\growth1sorted.txt';
# Open the input database file but quit if it doesn't exist
open(INDB, $InPut) or die "The input database $InPut could not be
opened.\n";
# Open the output database file in overwrite mode and quit if it fails
open(OUTDB, ">$OutPut") or die "The output database $OutPut could not
be
opened.\n";
@Unsort = <INDB>; #put input file in an array
@idx1 = (); #define an empty array for first sort index
for (@Unsort) {
($item) = substr ($_, 0, 2); #populate idx1 array with GA
push @idx1, ($item);
}
@idx2 = (); # define an empty array for second sort index
for (@Unsort) {
($item) = substr ($_, 3, 4); #populate idx2 array with BW
push @idx2, ($item);
}
@sorted = @Unsort[ sort { $idx1[$a] <=> $idx1[$b] or $idx2[$a] <=>
$idx2[$b] } 0 .. $#idx2]; #sort on idx1
print OUTDB @sorted;
output should look like this:
17 120 1
17 189 3
18 100 2
18 224 6
...
thanks
------------------------------
Date: Fri, 28 Mar 2003 18:59:39 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: counting repetition in an array with Perl
Message-Id: <vY0ha.726$_14.110@nwrdny02.gnilink.net>
"Justin" <justingrondines@hotmail.com> wrote in message
news:a595fb13.0303281029.110a765@posting.google.com...
> Hi! I just begin to learn Perl and need some help here. I work on
> windows 2000
> with perl5.8.
>
> I have 1 database that contains 2 fields: gestionnal age and birth
> weight.
> Now, i want to sort the file by GA and BW, and add an extra variable
> who will count the number of repetition ( i dont want duplicate in my
> output file).
> The sorting is done, but i need hints for the next step.
> Here my code:
>
> $InPut = 'C:\growth1.txt';
> $OutPut = 'C:\growth1sorted.txt';
>
> # Open the input database file but quit if it doesn't exist
> open(INDB, $InPut) or die "The input database $InPut could not be
> opened.\n";
> # Open the output database file in overwrite mode and quit if it fails
> open(OUTDB, ">$OutPut") or die "The output database $OutPut could not
> be
> opened.\n";
>
> @Unsort = <INDB>; #put input file in an array
> @idx1 = (); #define an empty array for first sort index
> for (@Unsort) {
> ($item) = substr ($_, 0, 2); #populate idx1 array with GA
> push @idx1, ($item);
> }
> @idx2 = (); # define an empty array for second sort index
> for (@Unsort) {
> ($item) = substr ($_, 3, 4); #populate idx2 array with BW
> push @idx2, ($item);
> }
> @sorted = @Unsort[ sort { $idx1[$a] <=> $idx1[$b] or $idx2[$a] <=>
> $idx2[$b] } 0 .. $#idx2]; #sort on idx1
>
> print OUTDB @sorted;
>
> output should look like this:
> 17 120 1
> 17 189 3
> 18 100 2
> 18 224 6
> ...
>
> thanks
open (INDB, ...)
open (OUTDB, ...)
%data = ();
while (<INDB>) {
$data{substr($_,0,2)}{substr($_,3,4)} ++;
}
foreach $idx1 (sort keys %data) {
foreach $idx2 (sort keys %{$data{$idx1}}) {
print OUTDB "$idx1 $idx2 $data{$idx1}{$idx2}\n"
}
}
------------------------------
Date: Fri, 28 Mar 2003 18:10:05 -0000
From: "Bigus" <bigus NO @ SPAM creationfactor .net>
Subject: CPAN Sloooooww
Message-Id: <be0ha.120$Qt4.17@newsfep4-winn.server.ntli.net>
Is it me or is the CPAN site incredibly slow the past few days?
Bigus
------------------------------
Date: 28 Mar 2003 19:35:33 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: CPAN Sloooooww
Message-Id: <b62865$qa6$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Bigus:
> Is it me or is the CPAN site incredibly slow the past few days?
I wish it was. It hasn't been accessible for me at all during the past
two days. I'm sure someone will look after that soon.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Fri, 28 Mar 2003 19:22:04 -0000
From: "Bigus" <bigus NO @ SPAM creationfactor .net>
Subject: DBD-ODBC
Message-Id: <Eh1ha.179$Qt4.21@newsfep4-winn.server.ntli.net>
Hi
I'm on a Win2k box with ActiveState Perl 5.8. I can't find DBD-ODBC when I
search via PPM. That is, if I type in "search dbd", I get:
1. DBD-AnyData [0.05] DBI access to XML, CSV and other formats
2. DBD-Chart [0.80] DBI driver abstraction for Rendering Charts and
G~
3. DBD-CSV [0.2002] DBI driver for CSV files
4. DBD-Multiplex [1.9] A multiplexing driver for the DBI.
5. DBD-mysql [2.1026] MySQL driver for the Perl5 Database Interface
(DB~
6. DBD-mysqlPP [0.04] Pure Perl MySQL driver for the DBI
7. DBD-Ovrimos [0.12] DBI Driver for Ovrimos (formerly Altera SQL
Serve~
8. DBD-PgPP [0.04] Pure Perl PostgreSQL driver for the DBI
9. DBD-Sprite [0.44] Perl extension for DBI, providing database
emmula~
10. DBD-SQLrelay [0.1] perl DBI driver for SQL Relay
11. DBD-Template [0.01] A template/sample class for DBI drivers.
12. DBD-XBase [0.231] Reads and writes XBase (dbf) files, includes
DBI ~
13. DBIx-AnyDBD [2.01] DBD independant class
but no actual DBD-ODBC. Am I missing something?
Thanks
Bigus
------------------------------
Date: Fri, 28 Mar 2003 19:43:02 -0000
From: "Bigus" <bigus NO @ SPAM creationfactor .net>
Subject: Re: DBD-ODBC
Message-Id: <jB1ha.197$Qt4.86@newsfep4-winn.server.ntli.net>
"Bigus" <bigus NO @ SPAM creationfactor .net> wrote in message
news:Eh1ha.179$Qt4.21@newsfep4-winn.server.ntli.net...
> Hi
>
> I'm on a Win2k box with ActiveState Perl 5.8. I can't find DBD-ODBC when I
> search via PPM. That is, if I type in "search dbd", I get:
>
> 1. DBD-AnyData [0.05] DBI access to XML, CSV and other formats
> 2. DBD-Chart [0.80] DBI driver abstraction for Rendering Charts
and
> G~
> 3. DBD-CSV [0.2002] DBI driver for CSV files
> 4. DBD-Multiplex [1.9] A multiplexing driver for the DBI.
> 5. DBD-mysql [2.1026] MySQL driver for the Perl5 Database Interface
> (DB~
> 6. DBD-mysqlPP [0.04] Pure Perl MySQL driver for the DBI
> 7. DBD-Ovrimos [0.12] DBI Driver for Ovrimos (formerly Altera SQL
> Serve~
> 8. DBD-PgPP [0.04] Pure Perl PostgreSQL driver for the DBI
> 9. DBD-Sprite [0.44] Perl extension for DBI, providing database
> emmula~
> 10. DBD-SQLrelay [0.1] perl DBI driver for SQL Relay
> 11. DBD-Template [0.01] A template/sample class for DBI drivers.
> 12. DBD-XBase [0.231] Reads and writes XBase (dbf) files, includes
> DBI ~
> 13. DBIx-AnyDBD [2.01] DBD independant class
>
> but no actual DBD-ODBC. Am I missing something?
Found this:
http://ppm.activestate.com/PPMPackages/zips/8xx-builds-only/Windows/DBD-ODBC
.zip
But it doesn't want to install under Perl 5.8.. might have to downgrade to
5.6 at this rate :-(
Bigus
------------------------------
Date: Fri, 28 Mar 2003 21:24:12 -0000
From: "Bigus" <bigus NO @ SPAM creationfactor .net>
Subject: DBI problem
Message-Id: <943ha.2308$8s6.17937@newsfep4-glfd.server.ntli.net>
I have the following code which updates a table in an Access database on
Win2k:
# check if table exists & create it if not
$sth = $db->prepare("SELECT * FROM $groupdb ORDER BY article DESC");
if(!$sth->execute)
{
if(!$db->do("CREATE TABLE $groupdb (article number,poster text(255),refs
memo,subject text(255),thedate text(16),client text(255),messageid
text(255))")){$msg = "Failed to create table $groupdb"; &dberror();}
}
# table exists so find out last article number and set $first to that + 1
else
{
while(@row = $sth->fetchrow_array)
{
$chk = $row[0]; last;
}
$first = $chk+1;
}
What it does is checks if the table exists by attempting to perform a SELECT
query. If the table doesn't exist it creates it. That works fine and
therefore the if() block is working.
If the table does exist then what it's supposed to do is get the article id
($row[0]) of the first record returned by the original SELECT statement.
However, it skips the while() block altogether, so the SELECT statement
doesn't appear to be returning any records even though there are loads in
the table.
Any ideas what could be going wrong? I have recently changed over from
WIN32::ODBC where this worked fine. ie: I've made no changes to the actual
statement. $groupdb in the select statement is still correctly defined with
the tablename "news_games".
Changing over form WIN32::ODBC is not going well :-(
Bigus
------------------------------
Date: Fri, 28 Mar 2003 21:45:13 GMT
From: joe dekk <no_email@none.abc>
Subject: how to turn these 2 steps into 1
Message-Id: <3E84C269.4000903@none.abc>
$p=~ s/\/+/\//g;
$p=~ s/\/+$//g;
I don't know how.
Thanks
------------------------------
Date: 28 Mar 2003 22:05:23 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: how to turn these 2 steps into 1
Message-Id: <slrnb89hp3.a57.abigail@alexandra.abigail.nl>
joe dekk (no_email@none.abc) wrote on MMMCDXCVI September MCMXCIII in
<URL:news:3E84C269.4000903@none.abc>:
() $p=~ s/\/+/\//g;
() $p=~ s/\/+$//g;
Take your pick:
1) $p =~ s !/+(?=/|$)!!g;
2) $p =~ s !//+!/!g xor $p =~ s !/+$!!;
3) $p = join "/" => split m !/+! => $p;
4) $p =~ s !/+(?=(.?))!length $1 ? "/" : ""!ge;
Abigail
--
BEGIN {$^H {q} = sub {$_ [1] =~ y/S-ZA-IK-O/q-tc-fe-m/d; $_ [1]}; $^H = 0x28100}
print "Just another PYTHON hacker\n";
------------------------------
Date: Fri, 28 Mar 2003 23:50:38 +0100
From: Kevin Pfeiffer <pfeiffer@iu-bremen.de>
Subject: I wrote a module!
Message-Id: <1888443.9Rdd6ioVVB@sputnik.tiros.net>
Okay, perhaps not sooo exciting, but it was for me. I have a script which
needed to be 'expanded' but I didn't want to extensively modify it. So I
took my new function and placed it in a module (created using h2xs).
And, after some tweaking (normal for my beginner efforts), it worked! Easier
than I thought.
-Night!
--
Kevin Pfeiffer
International University Bremen - www.iu-bremen.de
------------------------------
Date: 28 Mar 2003 12:11:06 -0800
From: stimonyhall@netscape.net (Upstart)
Subject: implicit vs explicit variable usage in loop w/ range regexp
Message-Id: <79516caa.0303281211.e8b8c42@posting.google.com>
Hi, (re-posting to comp.lang.perl.misc)
Perl newbie, and i need help. Trying to use the "range" regexp in perl and
am having a problem with the one version of the script:
This one works:
#!/usr/bin/perl
#foo.pl
use strict;
while (<>) {
if (/^BEGIN:/.../^END:/) {
chomp;
print;
print "\n";
}
}
with this input file test.txt:
hello
BEGIN:
PatchPro Related:
- Feedback <mailto:patchpro_feedback1@sun.com>
- Help </help/patch-list.html>
Search SunSolve:
END:
goodbye
The result I get from foo.pl test.txt is:
BEGIN:
PatchPro Related:
- Feedback <mailto:patchpro_feedback1@sun.com>
- Help </help/patch-list.html>
Search SunSolve:
END:
Now I try it without using $_; instead i use $line:
#!/usr/bin/perl
use strict;
while (my $line = <>) {
if ($line =~ /^BEGIN:/.../^END:/) {
chomp $line;
print "$line\n";
}
}
This results in:
BEGIN:
PatchPro Related:
- Feedback <mailto:patchpro_feedback1@sun.com>
- Help </help/patch-list.html>
Search SunSolve:
END:
goodbye
Why the extra goodbye?
------------------------------
Date: 28 Mar 2003 12:56:06 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: implicit vs explicit variable usage in loop w/ range regexp
Message-Id: <3e84b6e6@news.victoria.tc.ca>
Upstart (stimonyhall@netscape.net) wrote:
: Hi, (re-posting to comp.lang.perl.misc)
: Perl newbie, and i need help. Trying to use the "range" regexp in perl and
: am having a problem with the one version of the script:
The range operator to which you are refering is not a regular expression
(regexp).
: This one works:
: #!/usr/bin/perl
: #foo.pl
: use strict;
: while (<>) {
: if (/^BEGIN:/.../^END:/) {
: chomp;
: print;
: print "\n";
: }
: }
: Now I try it without using $_; instead i use $line:
: #!/usr/bin/perl
: use strict;
: while (my $line = <>) {
: if ($line =~ /^BEGIN:/.../^END:/) {
This line does not do what you think it does. My added brackets show what
it is doing.
if ( ($line =~ /^BEGIN:/) ... (/^END:/) ) {
which is of course the same as
if ( ($line =~ /^BEGIN:/) ... ( $_ =~ /^END:/) ) {
which is not what you want.
------------------------------
Date: Fri, 28 Mar 2003 16:46:08 +0000
From: Garry Heaton <none@none.com>
Subject: Re: make error loading module via 'cpan'
Message-Id: <iU_ga.2570$yF3.269173@stones.force9.net>
Even worse, I've just installed a perl-Magick rpm which required:
ImageMagick
... which required
libMagick5
After all this I still can't find Image/Magick.pm in my Perl tree.
Garry
Garry Heaton wrote:
> I've just tried loading a module with:
>
> [root@localhost]# cpan Image::Magick
>
> ... but it chokes at the end with:
>
> make: **** [Magick.o] Error 2
> /usr/bin/make -- NOT OK
>
> What the .....?
>
> Garry Heaton
>
>
------------------------------
Date: 28 Mar 2003 17:34:06 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: make error loading module via 'cpan'
Message-Id: <u9smt7tmy9.fsf@wcl-l.bham.ac.uk>
Garry Heaton <none@none.com> rudely vomits TOFU in out faces:
[ rudeness corrected ]
> Garry Heaton wrote:
> > I've just tried loading a module with:
> >
> > [root@localhost]# cpan Image::Magick
> >
> > ... but it chokes at the end with:
> >
> > make: **** [Magick.o] Error 2
> > /usr/bin/make -- NOT OK
The "Error 2" from make means an error occured in one of the programs
called by make. Look back in the output to see what it was.
> Even worse, I've just installed a perl-Magick rpm which required:
>
> ImageMagick
>
> ... which required
>
> libMagick5
>
> After all this I still can't find Image/Magick.pm in my Perl tree.
Hmm... was the RPM from the same place as you got your Perl RPM?
In general if you get Perl modules as RPMs you need to be sure that
they belond to the Perl RPM you are using.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 28 Mar 2003 21:17:35 +0000
From: Garry Heaton <none@none.com>
Subject: Re: make error loading module via 'cpan'
Message-Id: <NS2ha.2634$yF3.278974@stones.force9.net>
Brian McCauley wrote:
> Garry Heaton <none@none.com> rudely vomits TOFU in out faces:
>
> [ rudeness corrected ]
>
>
>>Garry Heaton wrote:
>>
>>>I've just tried loading a module with:
>>>
>>>[root@localhost]# cpan Image::Magick
>>>
>>>... but it chokes at the end with:
>>>
>>>make: **** [Magick.o] Error 2
>>>/usr/bin/make -- NOT OK
>
>
> The "Error 2" from make means an error occured in one of the programs
> called by make. Look back in the output to see what it was.
>
>
>>Even worse, I've just installed a perl-Magick rpm which required:
>>
>>ImageMagick
>>
>>... which required
>>
>>libMagick5
>>
>>After all this I still can't find Image/Magick.pm in my Perl tree.
>
>
> Hmm... was the RPM from the same place as you got your Perl RPM?
>
> In general if you get Perl modules as RPMs you need to be sure that
> they belond to the Perl RPM you are using.
>
All the same. Mandrake Cooker.
Garry
------------------------------
Date: Fri, 28 Mar 2003 15:07:32 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: match this except if it's between that
Message-Id: <3E84AB84.6C8B37F9@someserver123abc.com>
I'm trying to match this string but only if it's not between something.
if my string is
abc hello abc hello abc (hello) abc hello
I got it to match "hello" 4 times.
If I'm doing something like HTML I only want to match "hello" if it's
outside of the lt-gt brackets.
so I want to match "hello" 3 times.
I'm using parentheses in my test, but I'd like to do this with other
chars also.
here's my garbage:
print "content-type: text/html \n\n";
push @x, "abc 123 !@# +-=_ 768 Hello uuu";
push @x, "outsideLeft(inside)outSiDeRight";
$match="side";
$fontO="<font color=\"#ff0000\"><b>";
$fontC="</b></font>";
foreach (@x) {
$new=$_;
$new=~ s/!(\(.*\))/$fontO$&$fontC/ig;
print "$new<br>\n";
}
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4778
***************************************