[15584] in Perl-Users-Digest
Perl-Users Digest, Issue: 2997 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 9 21:05:39 2000
Date: Tue, 9 May 2000 18:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957920716-v9-i2997@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 9 May 2000 Volume: 9 Number: 2997
Today's topics:
Re: Accessing Perl code parser (Bart Lateur)
Re: Clear and then Reuse a package name space (Mark-Jason Dominus)
Re: Co (Abigail)
Re: Co <lr@hpl.hp.com>
Re: Converting Macintosh files to UNIX <lr@hpl.hp.com>
Re: Crypt::Twofish error <rootbeer@redcat.com>
Re: Evaluating string as math expression (Abigail)
Re: FAQ for configuring Perl on Win NT <lord_kthulu@hotmail.com>
Re: FAQ for configuring Perl on Win NT <jeff@vpservices.com>
File Upload Script <adinoam@aquanet.co.il>
Re: File Upload Script <makarand_kulkarni@My-Deja.com>
Re: File Upload Script <lr@hpl.hp.com>
Re: Help Needed - Perl Matching Operator <Jonathan.L.Ericson@jpl.nasa.gov>
Re: Help with Perl and Mysql DBI/DBD Programming?????? <makarand_kulkarni@My-Deja.com>
Re: How many times is it found? (Abigail)
Re: How many times is it found? <lr@hpl.hp.com>
Re: If slices are so great... (Abigail)
Re: Is Perl fast enough? <andy@u2me3.com>
Re: Is Perl fast enough? (Eric Bohlman)
Re: Iterating an array question? (Bart Lateur)
Re: NetworkSolutions - example of lapse security (brian d foy)
Re: Newbie brain fade <mordecai@teleport.com>
Re: Newbie brain fade <lr@hpl.hp.com>
Perl DBI <jamalone@earthlink.net>
Re: Perl DBI <jamalone@earthlink.net>
Re: Perl DBI <makarand_kulkarni@My-Deja.com>
Re: Perl DBI <jamalone@earthlink.net>
Re: Perl DBI <jeff@vpservices.com>
Re: Perl DBI <makarand_kulkarni@My-Deja.com>
problem with blat <dbsk3NOdbSPAM@hotmail.com.invalid>
Re: problem with blat <jamalone@earthlink.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 09 May 2000 22:50:00 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Accessing Perl code parser
Message-Id: <39228db6.48338888@news.skynet.be>
Rodney Broom wrote:
>I'm looking for a way to parse Perl code and glean out all of the variable
>names and their respecive scope. I'm guessing that the fastest way to get this
>done is to just rip the parser out of Perl and recompile it for myself, but
>I'm not married to that method.
I was looking through the standard modules the other day. The "B::*"
tree is particularily interesting. Maybe the B::Xref module already does
what you want. From the pod:
The B::Xref module is used to generate a cross reference listing
of all definitions and uses of variables, subroutines and
formats in a Perl program. It is implemented as a backend for
the Perl compiler.
--
Bart.
------------------------------
Date: Tue, 09 May 2000 22:13:08 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Clear and then Reuse a package name space
Message-Id: <39188d73.723e$42@news.op.net>
In article <39155774.4C9360FF@snet.net>, Richard Chen <qchen@snet.net> wrote:
>The scrub_package written by Mark Jason Dominus
>almost does it except a fatal flaw which results in the undef
>of the source subroutine.
That is not a fatal flaw, or a bug. It is a feature.
The function erases everything in a package. If the package that you
ask it to erase contains the function itself, it erases itself. If it
didn't do this, *that* would be a bug.
Your complaint is like someone complaining that
/bin/rm /bin/*
erases the `rm' command. But that is what it was designed to do.
------------------------------
Date: 9 May 2000 22:57:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Co
Message-Id: <slrn8hh5uk.efl.abigail@ucan.foad.org>
On Fri, 28 Apr 2000 11:46:55 -0700,
Lauren Smith <lauren_smith13@hotmail.com> wrote:
++
++ Drew Simonis <care227@attglobal.net> wrote in message
++ news:3909D8AD.37BAB757@attglobal.net...
++ >
++ > I look at the subject and think I got distracted. Co?
++ > Anyway, what Im doing with this is printing the array
++ > out to a text file line by line, kinda like this:
++ >
++ > for ($i = 0; $i <= $#$ref; $i++){
++ >
++ > print DATA $ref->[$i] . "blah blah blah \n";
++ >
++ > }
++ >
++ > Is there an easier way?
++
++ Yep.
++
++ for (@$ref) {
++ print DATA $_."blah blah blah \n";
++ }
{local $" = "blah blah blah \n"; print qq '@$ref$"' if @$ref}
Abigail
------------------------------
Date: Tue, 9 May 2000 16:24:55 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Co
Message-Id: <MPG.13823e24c7ec453798aa42@nntp.hpl.hp.com>
In article <slrn8hh5uk.efl.abigail@ucan.foad.org> on 9 May 2000 22:57:24
GMT, Abigail <abigail@foad.org> says...
> On Fri, 28 Apr 2000 11:46:55 -0700,
> Lauren Smith <lauren_smith13@hotmail.com> wrote:
...
> ++ for (@$ref) {
> ++ print DATA $_."blah blah blah \n";
> ++ }
>
>
> {local $" = "blah blah blah \n"; print qq '@$ref$"' if @$ref}
Equivalently, but shorter:
print join "blah blah blah \n" => @$ref, "";
Append the statement modifier
... if @$ref;
to avoid a warning should @$ref not be defined.
We're each missing the DATA filehandle (what a horrible name for an
output filehandle, anyhow!), but why should I penalize myself only?
If the array is very large neither of these solutions makes good use of
memory (because of the serialization of the array into a single string).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 9 May 2000 14:57:09 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Converting Macintosh files to UNIX
Message-Id: <MPG.1382299222df4feb98aa3d@nntp.hpl.hp.com>
In article <391e7ebf.44508144@news.skynet.be> on Tue, 09 May 2000
21:25:32 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Abigail wrote:
>
> >Larry Rosler <lr@hpl.hp.com> wrote:
> >
> >++ tr/\r\n/\n\r/
> >++
> >++ The s///g approach can't do that without considerable complication.
> >++
> >++ s/([\r\n])/$1 eq "\r" ? "\n" : "\r"/eg
> >
> > %& = ("\n", "\r", "\r", "\n");
> > s/[\r\n]/$&{$&}/g;
>
> s/([\r\n])/$1 ^ "\r" ^ "\n"/ge;
Cute.
> You may replace '"\r" ^ "\n"' with '"\07"' if you like, but it's not as
> clear.
The compiler should do that constant folding. But you have to help it
with parentheses around the constants.
Adding these cases to my previous benchmark:
Expr1 => '(my $x = $a) =~ s/[\r\n]/$& eq "\r" ? "\n" : "\r"/eg',
Xor0 => '(my $x = $a) =~ s/([\r\n])/$1 ^ "\r" ^ "\n"/eg',
Xor1 => '(my $x = $a) =~ s/([\r\n])/$1 ^ ("\r" ^ "\n")/eg',
Xor2 => '(my $x = $a) =~ s/([\r\n])/$1 ^ "\07"/eg',
Xor3 => '(my $x = $a) =~ s/[\r\n]/$& ^ "\07"/eg',
Name "main::a" used only once: possible typo at e:\Test\b3.txt line 5.
Benchmark: timing 16384 iterations of Expr1, Xor0, Xor1, Xor2, Xor3...
Expr1: 3 wallclock secs ( 3.31 usr + 0.00 sys = 3.31 CPU) @
4945.37/s (n=16384)
Xor0: 4 wallclock secs ( 4.23 usr + 0.00 sys = 4.23 CPU) @
3869.63/s (n=16384)
Xor1: 2 wallclock secs ( 3.70 usr + 0.00 sys = 3.70 CPU) @
4425.72/s (n=16384)
Xor2: 4 wallclock secs ( 3.67 usr + 0.00 sys = 3.67 CPU) @
4460.66/s (n=16384)
Xor3: 4 wallclock secs ( 3.44 usr + 0.00 sys = 3.44 CPU) @
4766.95/s (n=16384)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 9 May 2000 15:23:30 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Crypt::Twofish error
Message-Id: <Pine.GSO.4.10.10005091512220.3921-100000@user2.teleport.com>
On Tue, 9 May 2000, Thomas Åhlen wrote:
> It works just fine on a Solaris2.6 system.
> But on my RedHat6.1 system it gives me a Segmentation fault(out of memory).
That should never happen with normal user-level code; it indicates a bug
in the implementation (or configuration, or compilation) of the
compiled-in code. Almost certainly, that's a problem with the module
you're using. You should probably double-check that it was configured
and built correctly by re-building it and ensuring that 'make test'
reported no problems. At that point, it's time to send a bug report to the
author of the module. Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 9 May 2000 23:08:22 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Evaluating string as math expression
Message-Id: <slrn8hh6j6.efl.abigail@ucan.foad.org>
On Fri, 28 Apr 2000 21:21:59 GMT, Craig Berry <cberry@cinenet.net> wrote:
++ Sigurd Schi|th (sigurd.schioth@ilf.uio.no) wrote:
++ : Is there a compact (and pref. fast) way to evaluate/convert a string
++ : as/to a mathematical expression in Perl (without splitting and
++ : iterating)? Say, for a string like "1+2*3" I want the scalar '7'.
++
++ If you use standard Perl math syntax, eval() makes this a breeze:
++
++ /usr2/people/cberry > perl -we '$exp = "1+2*3"; print eval $exp'
++ 7
++
++ All the usual cautions about string eval apply, of course. In particular,
++ be extremely careful about accepting a string for evaluation from the
++ user; evaluating "system('rm -rf /')" could ruin your whole day. See
++ taint checking for a nice way to force yourself to pay attention to such
++ issues.
Well, only if the "user" is someone else than the "executioner". Not
the whole world is CGI programs. Not even most of it. And suid programs
are relatively rare.
perl -wle 'eval shift'
might be "insecure", but anyone who can execute that can do 'rm -rf /'
anyway.
Abigail
------------------------------
Date: Wed, 10 May 2000 08:43:21 +1000
From: "Kthulu" <lord_kthulu@hotmail.com>
Subject: Re: FAQ for configuring Perl on Win NT
Message-Id: <sz0S4.19110$PL4.432893@ozemail.com.au>
I can run simple scripts, Perl just dies when I try to read or write to a
file. Any Ideas ?
Kthulu <lord_kthulu@hotmail.com> wrote in message
news:JhrR4.15400$PL4.383799@ozemail.com.au...
> Hello from a Perl Newbee,
> Is there a FAQ for setting up Perl
> on IIS 4 on Win NT Server. I've set security permissions of my CGI
> directory to Full Access, I can run *.pl files from a command line but
cant
> run through a browser. No doubt this is a common and simple problem, does
> anyone know what the answer is, or can anyone point me to a relevant FAQ.
>
> TIA,
>
> K
>
>
>
>
------------------------------
Date: Tue, 09 May 2000 15:48:41 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: FAQ for configuring Perl on Win NT
Message-Id: <391895C9.2BBDE442@vpservices.com>
Kthulu wrote:
>
> I can run simple scripts, Perl just dies when I try to read or write to a
> file. Any Ideas ?
Always check the results of open to see why they fail. It is probably
because you are not who you think you are and/or you are not where you
think you are.
...
use CGI::Carp qw(fatalsToBrowser);
open(IN,"<$file") or die "Couldn't open $file: $!";
--
Jeff
------------------------------
Date: Tue, 09 May 2000 02:54:58 +0200
From: Noam Peled <adinoam@aquanet.co.il>
Subject: File Upload Script
Message-Id: <391761E2.FD8002C@aquanet.co.il>
Hi,
I am trying to develop a script which will upload files (JPG, GIF, TXT
etc.) from a local computer to a pre-specified webserver directory.
All through a browser, of course.
However, all the methods I have taken have failed and I am really in
need for help in this matter.
Can anyone help me?
If you can, please email me at: adinoam@aquanet.co.il
Thanks,
Noam
------------------------------
Date: Tue, 09 May 2000 17:22:42 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: File Upload Script
Message-Id: <3918ABD2.D1B2E2E1@My-Deja.com>
> However, all the methods I have taken have failed and I am really in
> need for help in this matter.
The book "OFFICIAL GUIDE TO PROGRAMMING WITH CGI.PM"
has a script upload.pl that does this
http://www.wiley.com/compbooks/stein/source.html
==
------------------------------
Date: Tue, 9 May 2000 17:15:37 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: File Upload Script
Message-Id: <MPG.13824a0686e4cfaa98aa44@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <391761E2.FD8002C@aquanet.co.il> on Tue, 09 May 2000 02:54:58
+0200, Noam Peled <adinoam@aquanet.co.il> says...
> I am trying to develop a script which will upload files (JPG, GIF, TXT
> etc.) from a local computer to a pre-specified webserver directory.
> All through a browser, of course.
>
> However, all the methods I have taken have failed and I am really in
> need for help in this matter.
>
> Can anyone help me?
> If you can, please email me at: adinoam@aquanet.co.il
There are simple examples in the documentation for the CGI module, and
lots of discussion in this newsgroup. Don't forget to binmode() the
filehandles for binary files.
Try something simple first, then come back here if it seems not to meet
your needs.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 May 2000 15:55:36 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Help Needed - Perl Matching Operator
Message-Id: <39189768.5A5AF718@jpl.nasa.gov>
Kelvin wrote:
> sub checkemail {
> $_ = $enteredEmail;
> m/"@"//;
> }
> is that correct?
> Or how can I make sure the $enteredEmail included a "@" in it?
Did you try:
m/@/;
But if you were trying to match '@jpl.nasa.gov' or something simular,
you would want to avoid interpolating @jpl:
m/\@jpl.nasa.gov/;
See perlop/'Quote and Quote-like Operators'. See 'perldoc -q mail' for
advice on checking email addresses.
(One or more of 'perldoc -q escape', 'perldoc -q quote' and 'perldoc -q
interpolate' should have had information on this question, but they
don't. This is certainly a FAQ in my opinion.)
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: Tue, 09 May 2000 16:00:00 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Help with Perl and Mysql DBI/DBD Programming??????
Message-Id: <3918986F.A6D51BE5@My-Deja.com>
> $dbh = DBI->connect($DSN,$user,$pw) || print "Cannot connect:
> $DBI::errstr\n" unless $dbh;
call die () here, do not proceed if connect () fails.
> About to connect... Cannot connect: Unknown MySQL Server Host (stewart)
> (0) Connected...
This is due to the reason that you do not die() after connect() failure.
------------------------------
Date: 10 May 2000 00:29:52 GMT
From: abigail@foad.org (Abigail)
Subject: Re: How many times is it found?
Message-Id: <slrn8hhbc0.efl.abigail@ucan.foad.org>
On Sun, 30 Apr 2000 01:52:56 +0200,
Penpal International <ppi@searchy.net> wrote:
++ How can check how many times something is found in a string. A long time
++ ago I had a script for this, but I've lost it. Example:
++
++ $string = "This a string with the word string. So this is just a
++ string";
++ # Here must come an unknown code...
++
++ It must result in 3 for 'string'. 2 for 'this' and all others 1 if it's
++ right...
my %count;
map {$count {$_} ++} split /\s+/ => $string;
Abigail
------------------------------
Date: Tue, 9 May 2000 17:43:04 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How many times is it found?
Message-Id: <MPG.13825070d191be7f98aa46@nntp.hpl.hp.com>
In article <slrn8hhbc0.efl.abigail@ucan.foad.org> on 10 May 2000
00:29:52 GMT, Abigail <abigail@foad.org> says...
> On Sun, 30 Apr 2000 01:52:56 +0200,
> Penpal International <ppi@searchy.net> wrote:
> ++ How can check how many times something is found in a string. A long time
> ++ ago I had a script for this, but I've lost it. Example:
> ++
> ++ $string = "This a string with the word string. So this is just a
> ++ string";
> ++ # Here must come an unknown code...
> ++
> ++ It must result in 3 for 'string'. 2 for 'this' and all others 1 if it's
> ++ right...
>
>
> my %count;
> map {$count {$_} ++} split /\s+/ => $string;
my %count;
$count {$_} ++ for split /\s+/ => $string;
War, anyone?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 9 May 2000 23:28:21 GMT
From: abigail@foad.org (Abigail)
Subject: Re: If slices are so great...
Message-Id: <slrn8hh7oj.efl.abigail@ucan.foad.org>
On Fri, 28 Apr 2000 22:14:41 GMT, Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
++
++ % perl -wl
++ $string = 'a,long,string,with,some,commas';
++ @keep = (split /,/ => $string)[2 .. $string =~ tr/,//];
++ print "@keep";
++ __END__
++ string with some commas
++
++ Seems to be working to me.
Only for some inputs.
$ perl -wl
$string = 'a,long,string,with,some,commas,at,the,end,,,,,';
@keep = (split /,/ => $string)[2 .. $string =~ tr/,//];
print "@keep";
print scalar grep {!defined} @keep;
__END__
Use of uninitialized value in join at - line 3.
Use of uninitialized value in join at - line 3.
Use of uninitialized value in join at - line 3.
Use of uninitialized value in join at - line 3.
Use of uninitialized value in join at - line 3.
string with some commas at the end
5
$
Not to mention it doesn't generalize to non single char splits.
But here's a way that ought to do the trick:
@keep = grep {my $i if 0; $i ++ >= 2} split /,/ => $string;
There's an extra variable, but that will only have a limited scope.
Abigail
------------------------------
Date: Wed, 10 May 2000 00:37:57 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: Is Perl fast enough?
Message-Id: <8fa7g3$pe3$1@uranium.btinternet.com>
Yeah - you're absolutely right. I'm going to have to use a temporary SQL db
to store the info to be operated on, rather than using memory ...
Andy.
------------------------------
Date: 10 May 2000 00:45:43 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Is Perl fast enough?
Message-Id: <8fabfn$rtc$1@slb2.atl.mindspring.net>
Jeff Zucker (jeff@vpservices.com) wrote:
: out of that setup. It's not the total number of lines that matters,
: it's the total number you try to deal with simultaneously at any one
^^^^^^^^^^^^^^^^^^^^^^^^^
: point in time. Forgive me if I'm pointing out the obvious.
^^^^^^^^^^^^^
Are you certain that that figure completely swamps out the impact of
things that you try to deal with simultaneously at different points in
time? Perhaps the Department of Redundancy Department has done some
computations?
------------------------------
Date: Tue, 09 May 2000 22:50:03 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Iterating an array question?
Message-Id: <39238f9d.48818713@news.skynet.be>
aphiny6592@my-deja.com wrote:
>I have an array in perl in which I'd like to run
>an operation only on every other element. Using
>a foreach construct, how do I iterate the array
>counter to move to the next line without using
>the next command. I.e.
>
>foreach $item (@array)
>{
> # how do iterate explicitly
> $item++; # ????
>}
Don't use this construct? Seriously, for simplicity's sake, you can do
this:
for (my $i = 0; $i < @array, $i+=2) {
for my $item ($array[$i]) {
...
}
}
You can drop the inner loop, and directly access $array[$i] instead of
through $item.
If you insist on doing it you way, try a flipping flag.
my @array = ('a' .. 'z');
my $flag = 0;
foreach $item (@array) {
next unless $flag ^= 1;
print $item;
}
-->
acegikmoqsuwy
If you want the even elements instead of odd, either initialize $flag to
1, or replace "next unless" with "next if".
--
Bart.
------------------------------
Date: Tue, 09 May 2000 18:08:36 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: NetworkSolutions - example of lapse security
Message-Id: <brian-ya02408000R0905001808360001@news.panix.com>
In article <8fa0ju$810$1@uranium.btinternet.com>, "Andy Chantrill" <andy@u2me3.com> posted:
> http://www.networksolutions.com/cgi-bin/makechanges/easysteps/easysteps.pl?S
> TRING=maymun.com.pl?STRING=dmaymun.com&FILE=/../../../../../../../etc/passwd
looks like they fixed it.
> Just an example of how CGI scripts can be a major security hazard ...
of course, anything can be a major security hole. it's not limited
to CGI scripts.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Tue, 09 May 2000 15:25:58 -0800
From: "Jonathan Young" <mordecai@teleport.com>
Subject: Re: Newbie brain fade
Message-Id: <Ie0S4.4552$7B6.473572@nntp1.onemain.com>
In article <MPG.1382197244944a7698aa3a@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> wrote:
> In article <Xu_R4.7194$0L4.482357@nntp3.onemain.com> on Tue, 09 May 2000
> 13:27:05 -0800, Jonathan Young <mordecai@teleport.com> says...
>> In article <SwZR4.45049$g4.1226690@newsread2.prod.itd.earthlink.net>,
>> "rbbdsb" <rbbdsb@earthlink.net> wrote:
>> > I'm having a serious brain fade. I have some data
>> >
>> > word word word word First Second Third word word ....
>> >
>> > I need to find First , trap Second, and overwrite with at different
>> > order, removing the third word.
>> >
>> > word word word word Second First word word ....
>> >
>> > I've been working with
>> >
>> > s/(^|\s+)First \s+(\w+)\s+\w+/$1 zzz/;
>> >
>>
>> I'm no guru, but....
>>
>> s/((First)\s+(\w+)\s+(\w+))/$3 $2/
>>
>> I'm sure that could be dont better, but hell, I figured I'd give it a
>> shot at least:)
>
> Your shot's OK, except for not having a delimiter ahead of 'First' to
> prevent matching 'notFirst', for example.
>
> But don't you wonder what happened to $1 and $4 in your substitution?
> In this case, there should be no parentheses at all where they are; if
> parentheses are needed for grouping, they can be marked with (?: ... )
> to prevent unneeded captures.
Ahh.. yeah, I completely forgot about that.. my bad :( How would you
go about delimiting 'First' then? I thought about doing something like this:
s/^.*?\s(?:(First)\s+(\w+)\s+(?:\w+)).*?$/$3 $2/
(and yes, I completely forgot to add ?: for non-capturing parens.. my bad again)
but as I am about one third of the way through 'Mastering Regular Expressions'
I wasn't sure on how efficient that would be. Suggestions?
Jonathan
------------------------------
Date: Tue, 9 May 2000 15:50:22 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Newbie brain fade
Message-Id: <MPG.138236091a8eabf498aa3f@nntp.hpl.hp.com>
In article <Ie0S4.4552$7B6.473572@nntp1.onemain.com> on Tue, 09 May 2000
15:25:58 -0800, Jonathan Young <mordecai@teleport.com> says...
...
> Ahh.. yeah, I completely forgot about that.. my bad :( How would you
> go about delimiting 'First' then? I thought about doing something like this:
>
> s/^.*?\s(?:(First)\s+(\w+)\s+(?:\w+)).*?$/$3 $2/
>
> (and yes, I completely forgot to add ?: for non-capturing parens.. my bad again)
> but as I am about one third of the way through 'Mastering Regular Expressions'
> I wasn't sure on how efficient that would be. Suggestions?
I posted a solution about three hours ago. Go back, Young man!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 May 2000 23:30:07 GMT
From: "Jason Malone" <jamalone@earthlink.net>
Subject: Perl DBI
Message-Id: <3c1S4.43448$x4.1420308@newsread1.prod.itd.earthlink.net>
Can someone take a look at this code and tell me what I am missing. I am
trying to connect to a database and list the names of the tables that it
contains.
<snip>
#!/usr/bin/perl
my $dbh = DBI->connect("dbi:mysql:chamber_property","user","pass");
print "Content-type: text/html\n\n";
$tabsth = $dbh->table_info();
while ( ( $qual, $owner, $name, $type ) = $tabsth->fetchrow_array() ) {
$table = $name;
}
$sth->finish();
</snip>
Thanks
Jason Malone
------------------------------
Date: Tue, 09 May 2000 23:40:34 GMT
From: "Jason Malone" <jamalone@earthlink.net>
Subject: Re: Perl DBI
Message-Id: <Sl1S4.43488$x4.1421321@newsread1.prod.itd.earthlink.net>
Sorry,
I forgot one line it is
use DBI;
at the beginning of the script
Jason
"Jason Malone" <jamalone@earthlink.net> wrote in message
news:3c1S4.43448$x4.1420308@newsread1.prod.itd.earthlink.net...
> Can someone take a look at this code and tell me what I am missing. I am
> trying to connect to a database and list the names of the tables that it
> contains.
>
> <snip>
> #!/usr/bin/perl
> my $dbh = DBI->connect("dbi:mysql:chamber_property","user","pass");
> print "Content-type: text/html\n\n";
> $tabsth = $dbh->table_info();
>
> while ( ( $qual, $owner, $name, $type ) = $tabsth->fetchrow_array() ) {
> $table = $name;
> }
>
> $sth->finish();
> </snip>
>
> Thanks
> Jason Malone
>
>
------------------------------
Date: Tue, 09 May 2000 16:41:22 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Perl DBI
Message-Id: <3918A222.480BF18E@My-Deja.com>
Jason Malone wrote:
> Can someone take a look at this code and tell me what I am missing. I am
> trying to connect to a database and list the names of the tables that it
> contains.
>
> <snip>
> #!/usr/bin/perl
> my $dbh = DBI->connect("dbi:mysql:chamber_property","user","pass");
> print "Content-type: text/html\n\n";
> $tabsth = $dbh->table_info();
>
> while ( ( $qual, $owner, $name, $type ) = $tabsth->fetchrow_array() ) {
> $table = $name;
> }
>
> $sth->finish();
> </snip>
I don't see any print statements inside the while ()
--
------------------------------
Date: Tue, 09 May 2000 23:45:19 GMT
From: "Jason Malone" <jamalone@earthlink.net>
Subject: Re: Perl DBI
Message-Id: <jq1S4.43504$x4.1419723@newsread1.prod.itd.earthlink.net>
> I don't see any print statements inside the while ()
OK,
Now the code is
use DBI;
my $dbh = DBI->connect("dbi:mysql:chamber_property","chamber","ChambP127");
print "Content-type: text/html\n\n";
$tabsth = $dbh->table_info();
while ( ( $qual, $owner, $name, $type ) = $tabsth->fetchrow_array() ) {
print $name;
}
$sth->finish();
And it still will not work.
Thanks Jason
------------------------------
Date: Tue, 09 May 2000 17:05:13 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl DBI
Message-Id: <3918A7B9.EA1868E4@vpservices.com>
Jason Malone wrote:
>
> Can someone take a look at this code and tell me what I am missing. I am
> trying to connect to a database and list the names of the tables that it
> contains.
What error did you get or what happened or didn't happen? We can't read
your mind about what went wrong.
> #!/usr/bin/perl
No -w.
No use strict.
> my $dbh = DBI->connect("dbi:mysql:chamber_property","user","pass");
No RaiseError=1 or other error checking to see if you actually
connected.
> print "Content-type: text/html\n\n";
Are you testing this on the web, or on the command line? If from the
web, you need CGI::Carp or something to show error messages and you need
to read all of the basic CGI info about users and permissions. Best to
test on the command line first.
> $tabsth = $dbh->table_info();
No error checking.
> while ( ( $qual, $owner, $name, $type ) = $tabsth->fetchrow_array() ) {
> $table = $name;
There's no print statement so nothing would be output even if this was
successful. And are you sure there are any tables in the database
chamber_property? because if there aren't any tables there, this code
wouldn't produce anything even if it worked and you had print
statements.
But chances are the program failed somewhere up above and you never knew
it because you had no error statements in there. Best thing to do is
put {RaiseError=1} after "pass" in your connect statement, that way the
program will stop and give you an error message whenever it runs into a
problem.
--
Jeff
------------------------------
Date: Tue, 09 May 2000 17:19:05 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Perl DBI
Message-Id: <3918AAF9.93FFA8B4@My-Deja.com>
> And it still will not work.
table_info () API is experimental and new and might disappear
from the DBI in the future. Hence it is a good idea not
to use it inside programs
If you still feel that table_info() needs to work on your system
you need to check if connect (), table_info() etc are succeeding
eg:
$dbh = DBI->connect($data_source, $username, $password) || die $DBI::errstr;
--
------------------------------
Date: Tue, 09 May 2000 15:15:04 -0700
From: tilde3 <dbsk3NOdbSPAM@hotmail.com.invalid>
Subject: problem with blat
Message-Id: <01e756bc.571e1536@usw-ex0104-033.remarq.com>
Hello,
I am having problems using blat on a customers site. They are
set on NT and blat. I get no errors but the mail is never sent.
I am monitoring the mail server I have it going to and it never
gets there.
Here is the code to send.
system("blat.exe $orderfile");
I've checked my blat profile using Blat -profile and it is
correct.
Any suggestions?
Thanks in advance.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Tue, 09 May 2000 23:49:06 GMT
From: "Jason Malone" <jamalone@earthlink.net>
Subject: Re: problem with blat
Message-Id: <St1S4.43516$x4.1419970@newsread1.prod.itd.earthlink.net>
> Here is the code to send.
> system("blat.exe $orderfile");
>
> I've checked my blat profile using Blat -profile and it is
> correct.
Can you send mail directly from a comand prompt?
Jason Malone
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 2997
**************************************