[29578] in Perl-Users-Digest
Perl-Users Digest, Issue: 822 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 5 14:09:48 2007
Date: Wed, 5 Sep 2007 11:09:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 5 Sep 2007 Volume: 11 Number: 822
Today's topics:
Calling a VB component <TonyP@blahblah.co.uk>
Re: Calling a VB component <invalid@invalid.org>
Re: FAQ 1.13 Is it a Perl program or a Perl script? <brian.d.foy@gmail.com>
Re: Fresh Programmers Required Urgently Visual Foxpro / <tadmc@seesig.invalid>
Re: How to generate http error in script <hjp-usenet2@hjp.at>
Re: implementation of system() <markhn@rpi.edu>
Re: implementation of system() <josef.moellers@fujitsu-siemens.com>
Re: Perl variable to shell command...? <benoit.lefebvre@gmail.com>
Re: Problem with reg expression <spamtrap@dot-app.org>
Re: Problem with reg expression <spamtrap@dot-app.org>
Problem with sending mail using perl <shafa.fahad@gmail.com>
Re: Problem with sending mail using perl <benoit.lefebvre@gmail.com>
Re: Problem with sending mail using perl <shafa.fahad@gmail.com>
Re: Problem with sending mail using perl <veatchla@yahoo.com>
Re: Problem with sending mail using perl <ben@morrow.me.uk>
Re: Reverse engineering OO perl code <allergic-to-spam@no-spam-allowed.org>
Re: Searching in a line <benoit.lefebvre@gmail.com>
Re: To find size of an attachment in a POP3 server <dummy@example.com>
Trying to access DB <webmaster@valleywebnet.com>
Re: Trying to access DB <jluis@agujeronegro.escomposlinux.org>
Re: Trying to access DB <Peter@PSDT.com>
Re: Trying to access DB <webmaster@valleywebnet.com>
Re: Warning about unused lexical variables <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 05 Sep 2007 12:23:33 +0100
From: Tony Phillips <TonyP@blahblah.co.uk>
Subject: Calling a VB component
Message-Id: <46DE91B5.1060803@blahblah.co.uk>
I'm used to writing fairly simple perl code to carry out database
administration functions and reporting functions. However, I'd like to
be able to call a windows VB component from a perl script. I've spent a
couple of hours looking on the perl FAQs and newsgroups without finding
anything. Is this possible ? If so I'd appreciate a few pointers and
even an example.
TIA
Laurence
------------------------------
Date: Wed, 05 Sep 2007 15:06:29 +0200
From: David Sudlow <invalid@invalid.org>
Subject: Re: Calling a VB component
Message-Id: <46dea9d9$0$25931$ba4acef3@news.orange.fr>
Tony Phillips wrote:
> I'm used to writing fairly simple perl code to carry out database
> administration functions and reporting functions. However, I'd like to
> be able to call a windows VB component from a perl script. I've spent a
> couple of hours looking on the perl FAQs and newsgroups without finding
> anything. Is this possible ? If so I'd appreciate a few pointers and
> even an example.
>
> TIA
>
> Laurence
>
There is quite a lot of info around about automating Word/Excel/IE from
Perl using Win32::OLE. Basically the same principles apply for any COM
object. (i.e. OLE automation on the COM object interface...).
Also Win32::ODBC may be useful to you depending on the kind of database
you are administering...
------------------------------
Date: Wed, 05 Sep 2007 12:35:56 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 1.13 Is it a Perl program or a Perl script?
Message-Id: <050920071235569602%brian.d.foy@gmail.com>
In article <ol4rd31kdre6e4i5v443upp9uvpq7upc74@4ax.com>, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
> On Mon, 3 Sep 2007 12:03:02 -0700, PerlFAQ Server
> <brian@stonehenge.com> wrote:
>
> >1.13: Is it a Perl program or a Perl script?
> >
> > Larry doesn't really care. He says (half in jest) that "a script is what
> > you give the actors. A program is what you give the audience."
>
> Also see the next to last (hope this is the correct English way to say
> that) entry at <http://perlmonks.org/?node_id=635444>. (In fact, I
> suggested it.)
Larry said in his State of the Onion at this year's OSCON that he still
likes to think of some of his Perl as "scripts",and specificly reacted
against Andy's agenda to strike that word from our vocabulary.
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Wed, 05 Sep 2007 11:13:25 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Fresh Programmers Required Urgently Visual Foxpro / VB / .NET
Message-Id: <slrnfdt3o0.mdb.tadmc@tadmc30.sbcglobal.net>
HR Head <msmanu78@yahoo.com> wrote:
> Fresh Programmers Required
Us Stale Programmers just don't taste right?
> Qulification ;- Any Graduate / Under Graduate
^^^
^^^
> Effective communication skill in English prefered
^^^
^^^
Yes, it does look like you could use some help in that area...
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 5 Sep 2007 14:15:30 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: How to generate http error in script
Message-Id: <slrnfdt7f2.m6p.hjp-usenet2@zeno.hjp.at>
On 2007-09-04 13:25, Petr Vileta <stoupa@practisoft.cz> wrote:
> Sherm Pendley wrote:
>> "Petr Vileta" <stoupa@practisoft.cz> writes:
>>
>>> Peter J. Holzer wrote:
>>>> On 2007-09-03 03:48, Petr Vileta <stoupa@practisoft.cz> wrote:
>>>>> Because I do not use Apache authentication but by parameters on GET
>>>>> method only. If all parameters are passed right then script return
>>>>> XML file, in other case must return http 401 error.
>>>>
>>>> In this case 401 is probably wrong. 401 is intended to be used with
>>>> the WWW-Authenticate and Authorization headers:
>>
>>> Yes, right. But what other http error you suggest?
>>
>> I think "403 Forbidden" would be appropriate. The W3C's description
>> of it says "authorization will not help", but that simply means that
>> the browser shouldn't bother prompting for standard HTTP auth info,
>> like it would for a 401 response.
>>
> I'm used to see this error when I can go to directory (mean URL) where
> nobody can to go. Maybe by some RFC this is right response but by human
> logic not :-)
Judging from the replies you are the only human in this group then.
> My script is in directory where users can to go but must pass
> a right parameters or call other scripts.
"Script" and "directory" are concepts which have little meaning in HTTP.
You send a request and you get a reply. Whether there are such things as
scripts or files or directories or whatever on the server is in general
unknowable to the client and mostly irrelevant (the characters '/' and
'?' do have some meaning in the interpretation of relative URLs,
though).
> For example
> http://www.domain.com/test/ is allowed and return some html code and status
> 200
> http://www.domain.com/test/mytest.cgi is the same, but return xml code
> http://www.domain.com/test/othertest.cgi?user=John&pwd=mypwd is good script
> calling with right parameters and return status 200 and html code
> http://www.domain.com/test/othertest.cgi?user=Joe&pwd=mypwd
http://www.domain.com/test/othertest.cgi?user=Joe&pwd=mypwd is a
different URL than
http://www.domain.com/test/othertest.cgi?user=John&pwd=mypwd. It is
possible to argue that
http://www.domain.com/test/othertest.cgi?user=Joe&pwd=mypwd doesn't exist
(404 error), or that you aren't allowed to access
http://www.domain.com/test/othertest.cgi?user=Joe&pwd=mypwd (403 error).
But a 401 error makes no sense: No authentication will make the URL
http://www.domain.com/test/othertest.cgi?user=Joe&pwd=mypwd accessible.
You *must* change the URL to either
http://www.domain.com/test/othertest.cgi?user=John&pwd=mypwd or
http://www.domain.com/test/othertest.cgi?user=Joe&pwd=otherpwd.
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
------------------------------
Date: Wed, 05 Sep 2007 09:19:37 -0400
From: "Nicholas R. Markham" <markhn@rpi.edu>
Subject: Re: implementation of system()
Message-Id: <46deacf3$0$32524$4c368faf@roadrunner.com>
Alan Curry wrote:
> In article <46ddb3bb$0$18964$4c368faf@roadrunner.com>,
> Nicholas R. Markham <markhn@rpi.edu> wrote:
>> While working on a souped-up replacement for system(), I realized that
>> it's significantly more magical than I originally thought.
>> Specifically, I can't explain how it's able to set $! and return -1 when
>> exec() fails, since the exec() happens after a fork(), in the child process.
>
> It creates a pipe before forking and the child writes errno to the pipe after
> exec failure. This makes it more magical and friendly than C's system(). It
> has been this way since perl 5.6
Interesting - this is precisely the solution I came up with on my own.
Scary...
------------------------------
Date: Wed, 05 Sep 2007 16:03:07 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: implementation of system()
Message-Id: <fbmcuv$rf7$1@nntp.fujitsu-siemens.com>
Nicholas R. Markham wrote:
> Alan Curry wrote:
>> It creates a pipe before forking and the child writes errno to the=20
>> pipe after
>> exec failure. This makes it more magical and friendly than C's=20
>> system(). It
>> has been this way since perl 5.6
>=20
>=20
> Interesting - this is precisely the solution I came up with on my own. =
> Scary...
Why is that "scary"? Developers often think alike and often=20
independently find similar solutions to the same problem. It's one of=20
the reasons why software patents would be the death blow to a lot of=20
software developers.
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
------------------------------
Date: Wed, 05 Sep 2007 08:23:36 -0700
From: Benoit Lefebvre <benoit.lefebvre@gmail.com>
Subject: Re: Perl variable to shell command...?
Message-Id: <1189005816.502639.88540@g4g2000hsf.googlegroups.com>
On Sep 4, 5:55 pm, Rohit <rohit.makas...@gmail.com> wrote:
> Hi, I am trying to use perl local variable with shell command call.
>
> Example:
>
> $filename=myFile.txt
>
> @fileRec=`cat $filename`;
>
> Here shell is not able to identify $filename variable. Any idea or
> suggestions?
> I am using array of filename so it is necessary for me to use cat with
> variable.
>
> Thanks in advance.
>
> ~Rohit
I like to do it that way
$filename = "myfile.txt";
$cmd = "cat ". $filename;
@fileRec = `$cmd`;
------------------------------
Date: Wed, 05 Sep 2007 12:50:13 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Problem with reg expression
Message-Id: <m2fy1t83ay.fsf@dot-app.org>
Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> Lars Eighner wrote:
>
>> The assignment ($d,$e,$f) = /TrackCond(.*)<\/TD>/g; is nonsense whether
>> you are parsing html or a grocery list.
>
> Why?
In list context, m// returns the captured subexpressions. There are three
elements in the list being assigned to, but only one captured subexpression
in the regex.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Wed, 05 Sep 2007 14:03:58 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Problem with reg expression
Message-Id: <m23axt7zw1.fsf@dot-app.org>
Sherm Pendley <spamtrap@dot-app.org> writes:
> Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
>
>> Lars Eighner wrote:
>>
>>> The assignment ($d,$e,$f) = /TrackCond(.*)<\/TD>/g; is nonsense whether
>>> you are parsing html or a grocery list.
>>
>> Why?
>
> In list context, m// returns the captured subexpressions. There are three
> elements in the list being assigned to, but only one captured subexpression
> in the regex.
Sorry, my bad - I didn't notice the 'g' modifier. That will allow multiple
matches of the subexpression to be captured, and returned as a list.
Note to self: Never post before coffee.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Wed, 05 Sep 2007 15:12:43 -0000
From: Kimi <shafa.fahad@gmail.com>
Subject: Problem with sending mail using perl
Message-Id: <1189005163.102621.24100@o80g2000hse.googlegroups.com>
While trying to use this simple unix command to send mail using perl
#!/usr/bin/perl
my $output =`echo Mailbody | mail afahad@VSNL.com`;
I am facing a strange issue where "afahad@VSNL.com" gets converted to
"afahad.com@LocalHost.Local" and the mail is sent to it. Could some
one throw pointers to get rid of the issue.
The above unix code works perfectly well when executed separately and
send mail to afahad@VSNL.com
Thanks in Advance,
Fahad
------------------------------
Date: Wed, 05 Sep 2007 08:14:44 -0700
From: Benoit Lefebvre <benoit.lefebvre@gmail.com>
Subject: Re: Problem with sending mail using perl
Message-Id: <1189005284.217736.60560@k79g2000hse.googlegroups.com>
On Sep 5, 11:12 am, Kimi <shafa.fa...@gmail.com> wrote:
> While trying to use this simple unix command to send mail using perl
>
> #!/usr/bin/perl
> my $output =`echo Mailbody | mail afa...@VSNL.com`;
>
> I am facing a strange issue where "afa...@VSNL.com" gets converted to
> "afahad....@LocalHost.Local" and the mail is sent to it. Could some
> one throw pointers to get rid of the issue.
>
> The above unix code works perfectly well when executed separately and
> send mail to afa...@VSNL.com
>
> Thanks in Advance,
> Fahad
Put a "\" in front of the "@"
#!/usr/bin/perl
my $output =`echo Mailbody | mail afa...\@VSNL.com`;
------------------------------
Date: Wed, 05 Sep 2007 15:27:01 -0000
From: Kimi <shafa.fahad@gmail.com>
Subject: Re: Problem with sending mail using perl
Message-Id: <1189006021.637605.67610@57g2000hsv.googlegroups.com>
On Sep 5, 8:14 pm, Benoit Lefebvre <benoit.lefeb...@gmail.com> wrote:
> On Sep 5, 11:12 am, Kimi <shafa.fa...@gmail.com> wrote:
>
> > While trying to use this simple unix command to send mail using perl
>
> > #!/usr/bin/perl
> > my $output =`echo Mailbody | mail afa...@VSNL.com`;
>
> > I am facing a strange issue where "afa...@VSNL.com" gets converted to
> > "afahad....@LocalHost.Local" and the mail is sent to it. Could some
> > one throw pointers to get rid of the issue.
>
> > The above unix code works perfectly well when executed separately and
> > send mail to afa...@VSNL.com
>
> > Thanks in Advance,
> > Fahad
>
> Put a "\" in front of the "@"
>
> #!/usr/bin/perl
> my $output =`echo Mailbody | mail afa...\@VSNL.com`;
Thanks Benoit, That was helpful. But Is it how mail ids are supposed
to be used in perl in general. Suppose I am assigning the mail id to a
variable and want to use it,
Should it be again like,
#!/usr/bin/perl
$mail_id="afahad\@VSNL.com";
my $output =`echo Mailbody | mail $mail_id`;
Or is there a better way?
Thanks in Advance,
Kimi
------------------------------
Date: Wed, 05 Sep 2007 11:14:17 -0500
From: l v <veatchla@yahoo.com>
Subject: Re: Problem with sending mail using perl
Message-Id: <13dtldertu60q9e@news.supernews.com>
Kimi wrote:
> On Sep 5, 8:14 pm, Benoit Lefebvre <benoit.lefeb...@gmail.com> wrote:
>> On Sep 5, 11:12 am, Kimi <shafa.fa...@gmail.com> wrote:
>>
>>> While trying to use this simple unix command to send mail using perl
>>> #!/usr/bin/perl
>>> my $output =`echo Mailbody | mail afa...@VSNL.com`;
>>> I am facing a strange issue where "afa...@VSNL.com" gets converted to
>>> "afahad....@LocalHost.Local" and the mail is sent to it. Could some
>>> one throw pointers to get rid of the issue.
>>> The above unix code works perfectly well when executed separately and
>>> send mail to afa...@VSNL.com
>>> Thanks in Advance,
>>> Fahad
>> Put a "\" in front of the "@"
>>
>> #!/usr/bin/perl
>> my $output =`echo Mailbody | mail afa...\@VSNL.com`;
>
>
> Thanks Benoit, That was helpful. But Is it how mail ids are supposed
> to be used in perl in general. Suppose I am assigning the mail id to a
> variable and want to use it,
>
> Should it be again like,
>
> #!/usr/bin/perl
> $mail_id="afahad\@VSNL.com";
> my $output =`echo Mailbody | mail $mail_id`;
>
> Or is there a better way?
>
> Thanks in Advance,
> Kimi
>
>
I generally use Mail::Sender for my Perl emailing needs.
--
Len
------------------------------
Date: Wed, 5 Sep 2007 17:48:46 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Problem with sending mail using perl
Message-Id: <e833r4-de1.ln1@osiris.mauzo.dyndns.org>
Quoth Kimi <shafa.fahad@gmail.com>:
> On Sep 5, 8:14 pm, Benoit Lefebvre <benoit.lefeb...@gmail.com> wrote:
> > On Sep 5, 11:12 am, Kimi <shafa.fa...@gmail.com> wrote:
> >
> > > While trying to use this simple unix command to send mail using perl
> >
> > > #!/usr/bin/perl
> > > my $output =`echo Mailbody | mail afa...@VSNL.com`;
> >
> > > I am facing a strange issue where "afa...@VSNL.com" gets converted to
> > > "afahad....@LocalHost.Local" and the mail is sent to it. Could some
> > > one throw pointers to get rid of the issue.
> >
> > > The above unix code works perfectly well when executed separately and
> > > send mail to afa...@VSNL.com
> >
> > Put a "\" in front of the "@"
> >
> > #!/usr/bin/perl
> > my $output =`echo Mailbody | mail afa...\@VSNL.com`;
>
> Thanks Benoit, That was helpful. But Is it how mail ids are supposed
> to be used in perl in general. Suppose I am assigning the mail id to a
> variable and want to use it,
@VSNL is a variable. Variables interpolate in "" strings. If you had put
use strict;
use warnings;
at the top of your script, Perl would have told you what was wrong.
> Should it be again like,
>
> #!/usr/bin/perl
> $mail_id="afahad\@VSNL.com";
> my $output =`echo Mailbody | mail $mail_id`;
>
> Or is there a better way?
This is a perfectly good way, yes. Slightly clearer might be
$mail_id = 'afahad@VSNL.com';
note that I no longer have to use \@ as single quotes don't expand
variables.
Ben
------------------------------
Date: Wed, 5 Sep 2007 19:20:14 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
Subject: Re: Reverse engineering OO perl code
Message-Id: <slrnfdtpad.7o4.allergic-to-spam@no-spam-allowed.org>
On 2007-08-29, Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr> wrote:
> Jim Cochrane wrote:
>> I suspect this question has been asked before, and I suspect the answer
>> may be "It's not practical.", but from a couple quick searches in
>> google groups I could not find anything. (Maybe I picked the wrong
>> search words.)
>>
>> My question is Are there any tools available to effectively reverse
>> engineer existing, relatively well-constructed OO Perl code to produce
>> (or aid in producing) design artifacts/documentation, such as UML
>> diagrams/code or diagrams in other notations? (Free, FOSS, or not-free)
>>
>> It seems that this would be very valuable in some situations, but I've
>> not seen any evidence of such tools. Perhaps this is because the task
>> is too complex to be done for real code.
>
> There are a number out there, but the only one with which I am familiar
> is Autodia.
>
> Mark
Thanks much for the recommendation.
I installed autodia and tried it out a bit and it looks like it will
probably provide what I need.
Thanks also to Ben Morrow on his suggestion to check out modules on
cpan. I checked that out and found UML::Class::Simple, with
umlclass.pl.
--
------------------------------
Date: Wed, 05 Sep 2007 08:17:52 -0700
From: Benoit Lefebvre <benoit.lefebvre@gmail.com>
Subject: Re: Searching in a line
Message-Id: <1189005472.997790.305270@r29g2000hsg.googlegroups.com>
On Sep 2, 11:48 am, RedGrittyBrick <RedGrittyBr...@SpamWeary.foo>
wrote:
> xhos...@gmail.com wrote:
> > "J=FCrgen Exner" <jurge...@hotmail.com> wrote:
> >>BenoitLefebvrewrote:
> >>> Here is how I'd do it..
>
> >>> #!/usr/bin/perl
> >>> @list =3D `cat file.txt | grep beth`;
> >> Useless use of cat
>
> > It isn't useless. By doing it that way, it becomes trivially easy
> > change cat into gzcat if you want to. Making things trivially easy
> > for me in the future is quite useful.
>
> If you start with
> `cat file.txt | sed -e'' | awk '' | perl -p -e '' | tr a a |grep beth`
> it becomes trivially easy to insert a sed/awk/perl/tr command if you
> want to.
>
> I'm not sure I like the direction you're headed. :-)
Well.. do it however you like it..
I personally use a lot of @var =3D `cat bleh` for basic scripts
At least someone gave him a working example ;-)
--Ben
------------------------------
Date: Wed, 05 Sep 2007 11:54:11 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: To find size of an attachment in a POP3 server
Message-Id: <DNwDi.15202$bO6.9332@edtnps89>
satyakm79@gmail.com wrote:
>
> I am trying to retrieve all the attachments from a POP3 server. But
> before retrieving I would like to get the size of the attachment and
> compare it with the available disk space in my local station and then
> retrieve.
It can't be done. You can get the size of the email message before retrieving it:
perldoc Net::POP3
[ snip ]
list ( [ MSGNUM ] )
If called with an argument the "list" returns the size of the message
in octets.
If called without arguments a reference to a hash is returned. The
keys will be the "MSGNUM"’s of all undeleted messages and the values
will be their size in octets.
But attachments can be encoded/compressed/encrypted which can change the size
of the original file.
> Can anyone suggest me how to find the size of an attachment?
Download it, unencode it, uncompress it and then you will have its size.
Or there may be headers with the attachment that describe the file size so you
have to at least read enough of the message to get all of the headers (if you
trust that the file sizes in the headers are correct.) [Think DOS attack.]
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Wed, 05 Sep 2007 04:34:57 -0700
From: JimJx <webmaster@valleywebnet.com>
Subject: Trying to access DB
Message-Id: <1188992097.892868.179390@k79g2000hse.googlegroups.com>
Hi all,
I am trying to access a DB using a select statement and am having a
little problem.....
I connect fine, but I just can't seem to pull any data out. The
script I am using is below...
I know it is running the script because it is printing out the ToEdit:
$ToEdit
Any suggestions greatly appreciated.
Jim
if ($Enter) {
my $dbh = DBI->connect('DBI:mysql:farthing_valleyweb',$DBuser,
$DBpass)
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare('SELECT * FROM valley WHERE Name LIKE "%$ToEdit
%"') or die "Cannot prepare: " . $dbh->errstr();
$sth->execute()
or die "Couldn't execute statement: " . $sth->errstr;
while ($thisvalue = $sth->fetchrow()) {
push @thisarray, $thisvalue;
};
$dbh->disconnect;
foreach (@thisarray) {
print @thisarray . "<br />";
}
print "ToEdit: $ToEdit\n";
exit;
}
------------------------------
Date: Wed, 05 Sep 2007 14:01:18 +0100
From: José Luis Pérez Diez <jluis@agujeronegro.escomposlinux.org>
Subject: Re: Trying to access DB
Message-Id: <VA.00000bd9.4b08293e@agujeronegro.escomposlinux.org>
In article <1188992097.892868.179390@k79g2000hse.googlegroups.com>, JimJx
wrote:
> my $sth = $dbh->prepare('SELECT * FROM valley WHERE Name LIKE "%$ToEdit
> %"') or die "Cannot prepare: " . $dbh->errstr();
>
my $sth = $dbh->prepare
('SELECT * FROM valley WHERE Name LIKE "%'.$ToEdit.'%"') Or die
'Cannot prepare: ' . $dbh->errstr();
------------------------------
Date: Wed, 05 Sep 2007 13:39:44 GMT
From: Peter Scott <Peter@PSDT.com>
Subject: Re: Trying to access DB
Message-Id: <pan.2007.09.05.13.39.39.134413@PSDT.com>
On Wed, 05 Sep 2007 04:34:57 -0700, JimJx wrote:
> my $dbh = DBI->connect('DBI:mysql:farthing_valleyweb',$DBuser,
> $DBpass)
> or die "Couldn't connect to database: " . DBI->errstr;
>
> my $sth = $dbh->prepare('SELECT * FROM valley WHERE Name LIKE "%$ToEdit
> %"') or die "Cannot prepare: " . $dbh->errstr();
>
> $sth->execute()
> or die "Couldn't execute statement: " . $sth->errstr;
my $dbh = DBI->connect( 'DBI:mysql:farthing_valleyweb', $DBuser, $DBpass,
{ PrintError => 0, RaiseError => 1 } )
or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare( 'SELECT * FROM valley WHERE Name LIKE ?' );
$sth->execute( "%$ToEdit%" );
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
------------------------------
Date: Wed, 05 Sep 2007 08:26:49 -0700
From: JimJx <webmaster@valleywebnet.com>
Subject: Re: Trying to access DB
Message-Id: <1189006009.457673.103820@g4g2000hsf.googlegroups.com>
Thanks for the replies!
Jose, for some reason, your gave me errors when I executed it.....
Peter, works like a charm!
Thanks again to both for taking the time to reply,
Jim
------------------------------
Date: Wed, 05 Sep 2007 18:53:28 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Warning about unused lexical variables
Message-Id: <rfmtd31peg1el199svltlm8rfmk4lrsg7n@4ax.com>
On Tue, 04 Sep 2007 19:48:05 +0200, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
>I don't have the slightest idea about how to answer your question, but
>I duplicated at <http://perlmonks.org/?node_id=636990>. I'll update
>this thread as replies get posted there.
Here is what has been said:
Re: Warning about unused lexical variables
by toolic on Sep 04, 2007 at 20:11 GMT-2
I also find this useful.
A few weeks ago, something prompted me to run a Super Search on
"unused variable". I did not find the answer to this question, but the
most relevant node seemed to be "Devel::GC::Helper and unused
variables" (http://perlmonks.org/?node_id=602205).
Hopefully, a much wiser monk can enlighten us.
----------------------------------------------------------------------
Re: Warning about unused lexical variables
by sgt on Sep 04, 2007 at 20:27 GMT-2
B::Xref o B::Lint (with some plugin) can help I guess
----------------------------------------------------------------------
Re: Warning about unused lexical variables
by kyle on Sep 04, 2007 at 21:19 GMT-2
My (small) problem with this would be that the "unused" variable might
still serve some purpose. Consider a compute_some_value() like one of
these:
sub pay_attention {
die 'void context' if ! defined wantarray;
return rand;
}
sub side_effect {
print "I am happy.\n";
return;
}
sub wait_for_destruction {
return OnDestroyDo->new( \&side_effect );
}
In case that last one is not clear, the idea is that it returns an
object that will perform some action when it is destroyed.
Arguably a warning is still warranted in even these cases, but it
might not be easy to tell when an assigned value is really
superfluous.
----------------------------------------------------------------------
Re^2: Warning about unused lexical variables
by xdg on Sep 04, 2007 at 22:52 GMT-2
> the "unused" variable might still serve some purpose
Another example would be "anonymous" scalar references.
my $scalar_ref = \(my $s);
Or would taking a reference count as "using" it?
----------------------------------------------------------------------
Re^2: Warning about unused lexical variables
by bart on Sep 05, 2007 at 13:06 GMT-2
That's right. Check this article on perl.com on what this could be
used for: "Better Code Through Destruction"
(http://www.perl.com/pub/a/2007/06/07/better-code-through-destruction.html).
----------------------------------------------------------------------
Re: Warning about unused lexical variables
by Rhandom on Sep 04, 2007 at 22:20 GMT-2
At first glance it sounds like a great idea. And it is to a certain
extent. But there is an existing system in Perl that does that very
thing, although only with global variables.
[paul@paul-laptop nqp]$ perl -we '$x = 1'
Name "main::x" used only once: possible typo at -e line 1.
Speaking from experience, this warning has never helped me. It has
done the opposite. It has always been a hinderance. It has forced me
to write things similar to the following:
my $value = $SOME_PKG::SOME_VAL
|| $SOME_PKG::SOME_VAL; # warn clean
Arguably, I should have a function in SOME_PKG that returns the value
of $SOME_VAL. But there are many existing modules that don't provide
accessors.
Use strict catches all of my typos. A warning of this sort never has.
Still - I could see a use for it, but I think I'd want it as an
extra-extra pragma:
use warnings qw(single_use_vars);
----------------------------------------------------------------------
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 822
**************************************