[18729] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 897 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 14 18:06:25 2001

Date: Mon, 14 May 2001 15: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: <989877917-v10-i897@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 14 May 2001     Volume: 10 Number: 897

Today's topics:
        Array of file pointers <spam@un.u.nu>
    Re: Array of file pointers (Eric Bohlman)
    Re: Array of file pointers (Tad McClellan)
    Re: Array of file pointers <carlos@plant.student.utwente.nl>
    Re: Array of file pointers (Miguel Cruz)
        Benefits of "strict" and "-w"? <xris@dont.send.spam>
    Re: Benefits of "strict" and "-w"? (Craig Berry)
    Re: Cabal Guidelines for comp.lang.perl.misc ($Revision <godzilla@stomp.stomp.tokyo>
    Re: Cabal Guidelines for comp.lang.perl.misc ($Revision <eashton@chaos.wustl.edu>
    Re: Cabal Guidelines for comp.lang.perl.misc ($Revision (Tad McClellan)
    Re: Cabal Guidelines for comp.lang.perl.misc ($Revision <mischief@velma.motion.net>
    Re: Cabal Guidelines for comp.lang.perl.misc ($Revision <godzilla@stomp.stomp.tokyo>
    Re: Cabal Guidelines for comp.lang.perl.misc ($Revision <mischief@velma.motion.net>
    Re: DBI weirdness... <xris@dont.send.spam>
    Re: DBI weirdness... <cpryce@pryce.net>
        Finding the caller from XS <dmlloyd@tds.net>
    Re: FTP->new <a246456@fmr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 14 May 2001 20:07:00 GMT
From: Miguel Cruz <spam@un.u.nu>
Subject: Array of file pointers
Message-Id: <EVWL6.790$3n.40467@news.itd.umich.edu>


Is there any way I can create an array of file pointers in Perl?

If I do something like this:

   open (FH, ">>log.$section");
   $filepointers{$section} = *FH;

I don't get anywhere, because FH gets overwritten to point to the new file
when another open happens, taking $filepointers{$section} with it. It
appears that I can only have one file pointer per open statement, no matter
what. Is this true? Is there no way around it? I tried using sysopen (which
allows an expression as the first argument, presumably turned into a string
which then becomes the name of the filepointer, but then there doesn't
appear to be a way to turn that back into the first argument to a print.

Any ideas? Thanks.

miguel


------------------------------

Date: 14 May 2001 20:36:50 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Array of file pointers
Message-Id: <9dpfl2$gc2$3@bob.news.rcn.net>

Miguel Cruz <spam@un.u.nu> wrote:

> Is there any way I can create an array of file pointers in Perl?

> If I do something like this:

>    open (FH, ">>log.$section");
>    $filepointers{$section} = *FH;

> I don't get anywhere, because FH gets overwritten to point to the new file
> when another open happens, taking $filepointers{$section} with it. It
> appears that I can only have one file pointer per open statement, no matter
> what. Is this true? Is there no way around it? I tried using sysopen (which
> allows an expression as the first argument, presumably turned into a string
> which then becomes the name of the filepointer, but then there doesn't
> appear to be a way to turn that back into the first argument to a print.

> Any ideas? Thanks.

You might look into IO::File.



------------------------------

Date: Mon, 14 May 2001 15:56:41 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Array of file pointers
Message-Id: <slrn9g0e3p.ibc.tadmc@tadmc26.august.net>

Miguel Cruz <spam@un.u.nu> wrote:
>
>Is there any way I can create an array of file pointers in Perl?


That sounds pretty much like "How do I make an array of filehandles?".


>Any ideas? 


I would do it the way shown in the Perl FAQ:

   perldoc -q filehandle

      "How can I make a filehandle local to a subroutine?  How do
       I pass filehandles between subroutines?  How do I make an
       array of filehandles?"

You are expected to check the Perl FAQ *before* posting to the
Perl newsgroup.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Mon, 14 May 2001 23:22:38 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: Re: Array of file pointers
Message-Id: <9dpi3t$g8d$1@dinkel.civ.utwente.nl>

\*fh


"Miguel Cruz" <spam@un.u.nu> wrote in message
news:EVWL6.790$3n.40467@news.itd.umich.edu...
>
> Is there any way I can create an array of file pointers in Perl?
>
> If I do something like this:
>
>    open (FH, ">>log.$section");
>    $filepointers{$section} = *FH;
>
> I don't get anywhere, because FH gets overwritten to point to the new file
> when another open happens, taking $filepointers{$section} with it. It
> appears that I can only have one file pointer per open statement, no
matter
> what. Is this true? Is there no way around it? I tried using sysopen
(which
> allows an expression as the first argument, presumably turned into a
string
> which then becomes the name of the filepointer, but then there doesn't
> appear to be a way to turn that back into the first argument to a print.
>
> Any ideas? Thanks.
>
> miguel




------------------------------

Date: Mon, 14 May 2001 21:19:29 GMT
From: mnc@umich.edu (Miguel Cruz)
Subject: Re: Array of file pointers
Message-Id: <BZXL6.791$3n.40702@news.itd.umich.edu>

Tad McClellan <tadmc@augustmail.com> wrote:
>> Is there any way I can create an array of file pointers in Perl?
>
> That sounds pretty much like "How do I make an array of filehandles?".
>
>   perldoc -q filehandle
>
> You are expected to check the Perl FAQ *before* posting to the
> Perl newsgroup.

Thanks, that worked great. I spent a couple hours reading through perl man
pages, Google matches in the newsgroups and web, and the source code of
programs I figured might be doing the same thing. Never occurred to me to
check the FAQ, as by that time I'd determined for myself that it was an IAQ.
Live and learn.

miguel


------------------------------

Date: Mon, 14 May 2001 16:00:26 -0500
From: xris <xris@dont.send.spam>
Subject: Benefits of "strict" and "-w"?
Message-Id: <xris-689393.16002514052001@news.evergo.net>

I know this is probably in the faq somewhere, but I don't know where to 
start looking, so I'm asking here (my teachers always told me to ask 
questions, no matter how stupid they sounded).

I've been messing with perl for years, but as I've had no formal 
training, and Larry Wall's perl book doesn't stress either of these 
options (let alone give me enough info to even know what they REALLY 
do), I never bothered using them.  Since I've decided that my coding 
abilities have finally matured enough that I really should start using 
these, I'm wondering what the advantages are.  Is compilation/execution 
faster?  More reliable?

Thanks,

Chris



------------------------------

Date: Mon, 14 May 2001 21:58:12 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Benefits of "strict" and "-w"?
Message-Id: <tg0l7kjq0845d1@corp.supernews.com>

xris (xris@dont.send.spam) wrote:
: I've been messing with perl for years, but as I've had no formal 
: training, and Larry Wall's perl book doesn't stress either of these 
: options (let alone give me enough info to even know what they REALLY 
: do), I never bothered using them.  Since I've decided that my coding 
: abilities have finally matured enough that I really should start using 
: these, I'm wondering what the advantages are.  Is compilation/execution 
: faster?  More reliable?

Using warnings and strict makes a smaller subset of Perl available for
your use (without perl complaining or quitting as a result).  The paradox
is that being restricted to this smaller set can be extremely useful.
'Raw' perl has numerous do-what-I-mean (DWIM) features, which can be
extremely useful when you are writing short, one-off scripts (or even
providing code snippets on the command line with -e).  For example,

  perl -le '$lines++ for <>; print $lines' t*

is one way to count the lines in all files starting with 't'.  You don't
need to declare or initialize $lines; it springs into existence with an
undefined value when you mention it, and that undef value silently acts
like the number zero when you increment it.

But, suppose you accidentally mistype the second $lines as $liens...

  perl -le '$lines++ for <>; print $liens' t*

That produces no output at all (other than a newline), which is also what
you would expect to see if there were 0 lines to count.  You have no way
to know which happened, or even that anything went wrong, because the new
variable $liends silently sprang into existence with an undefined value
when you mentioned it, and that undef value silently became an empty
string when printed.

Now, let's turn on warnings and try it again...

  perl -wle '$lines++ for <>; print $liens' t*

Now you've given perl permission to nag you about things that are
technically valid but which may indicate a semantic problem, and perl
doesn't disappoint:

  Name "main::liens" used only once: possible typo at -e line 1.
  Name "main::lines" used only once: possible typo at -e line 1.
  Use of uninitialized value in print at -e line 1, <> line 65.

That information should be more than enough to help you spot the mismatch
between $lines and $liens.  But it's just a warning; in a production
system, execution could continue on the basis of flawed semantics, causing
untold devestation.  To protect yourself from that, you can turn on strict
as well:

  perl -Mstrict -wle '$lines++ for <>; print $liens' t*

Now perl actually refuses to run the code, with these messages:

  Global symbol "$lines" requires explicit package name at -e line 1.
  Global symbol "$liens" requires explicit package name at -e line 1.
  Execution of -e aborted due to compilation errors.

You would need to explicitly declare $lines (using 'my' or 'our' or 'use
vars') or explicitly type its package name (main::) as part of the
variable name to get rid of these.  Declaring just $lines would leave
$liens undeclared, forcing your attention to the typo.

And that's why most of us recommend that warnings and strict be enabled
for any script, and certainly any script (or code fragment) you want the
readers of clpm to help you debug.  By elminating the most common silent
DWIM errors of 'raw' perl, this practice will quite often solve your
problems before you need to ask us for help. 

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


------------------------------

Date: Mon, 14 May 2001 11:10:18 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Cabal Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <3B001F8A.69C94417@stomp.stomp.tokyo>

Chris Stith wrote:

> Godzilla! wrote:
> > Randal L. Schwartz wrote:
> > >  "Kira" == Godzilla! wrote:

 
(clearly snipped)


Your article is a crock of excuse making mule manure.
You need to polish your black jack boots, they have
lost their gloss. Some Spin Doctor, you are.

I really don't care what you petty little lying
fascist boys do. Your actions are abhorrent
but amount to less than diddly-squat.

What I do care about is my having maintained both
my dignity and my pride by speaking up for what is
true and right.

Gozilla!
--
"You Can Stand Me Up At The Gates Of Hell, But I Won't Back Down."
  http://la.znet.com/~callgirl3/backdown.mid


------------------------------

Date: Mon, 14 May 2001 19:23:06 GMT
From: Elaine Ashton <eashton@chaos.wustl.edu>
Subject: Re: Cabal Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <B725A984.869%eashton@chaos.wustl.edu>

On 5/14/01 1:31 PM, in article tg05kbqkqtmcbe@corp.supernews.com, "Chris
Stith" <mischief@velma.motion.net> wrote:
 
> I may not know Randal well, but I have had many chances to
> interact with him and have never found any of his acts to
> be "morally repugnant". I realize my standards and yours

You must have missed the episode where randal registered a
domain as was going to retroactively remove all of this persons'
postings from that domain.

> Tad is just the one willing to do the work. "Put up or
> shut up" I believe is the appropriate idiom here. Or,
> to quote Jarkko, Nick I-S, Gurusamy, Simon Cozens,
> and others, "patches welcome". I suppose that since
> Jarkko dedicates a gret many hours of his time to
> being a pumpking that he is a bad person in your eyes?
> Or I guess that Larry, since he desgined Perl, wrote
> the first versions of the system to run it, and tries
> to exert some self-limited control over how Perl
> develops is a bad, bad, bad, bad man?

The difference between those who do and those who don't
is one group does stuff and the other talks about it.
Also, if you look closely, those who do, don't spend
a lot of time putting down the new and the clueless
mostly because they are too busy doing something
constructive. The people you quote don't hang around
here as they fall into the 'do' category and don't
have much time to waste and, if they do, aren't going
to waste it here. 

> The most powerful Usenet tradition is to honor the posting
> rules set forth in the specific newsgroup in question. So,
> I guess you disapprove of trying to set forth these guidelines?
> Why not just go to an 'alt' group then?

It's a free country Perry Mason and keeping tradition with
the human spirit, the more people shove you away the more
you want to be near. Why would this person leave? They get
more attention and entertainment value than mud wrestling on
dollar beer night. It has been well over a year now...one would
think that the someone would notice that the usual methods
aren't working and there would be enlightenment somewhere.

e.



------------------------------

Date: Mon, 14 May 2001 15:40:34 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Cabal Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <slrn9g0d5i.i7a.tadmc@tadmc26.august.net>

Chris Stith <mischief@velma.motion.net> wrote:
>[sorry for the length... I left most of the original post intact
> for two reasons... I had something to which to respond at most
> every point, and I thought Tad might like to see the original
> post's abuse of logi^Whis name.]


Thank you.


>Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>> Randal L. Schwartz wrote:
>>  
>>>  "Kira" == Godzilla! wrote:
>
>>> Kira> When will you be announcing a request for comments


That happened several months ago. I guess you missed it.

Not our fault.


>>> Kira> and announcing a call for vote 


There will be no vote, other than noting which way the followups
went when we discussed it here. They were overwhelmingly in favor.


>>>to sanction this
>>> Kira> FAQ per long standing USENET guidelines?


You do not need to vote on a FAQ. References please.


>> There are both written and unwritten guidelines for USENET
>
>Indeed. Tad's just putting into writing some of the
>unwritten guidelines which have already been accepted
>by the regulars of this group.


>> This FAQ is presented as the "voice of the majority" here
>> and yet speaks only for a very select few. Those of us who
                                                       ^^
                                                       ^^
>> are in disfavor of this self-proclaimed cabal here


I don't see that the plural is justified. Got a mouse in your pocket?


>Tad will hear suggestions,
>after he asked for others to forward your suggestions to him,


Thanks for quoting it Chris. I see some glittery opalescence
amidst the, ummm, earth tones.


>> I am embarrassed to have anyone presume I am associated with
>> this document. 


This document is not psychobabble and vitriol, so there is little
danger of anyone attributing it to you. Let your mind rest easy.


>Rest assured I will periodically make this clear.


OK, but I won't see them.


>Then post your own version, so we can compare the two.


I'm waiting...


>> I have been refused any opportunity to participate in
>> the development of this newsgroup charter. 


Sorry. You make your reputation and then you live with it. I will
not feed you.


>> Your use of
>> "we" is most hypocritical. 


No, the "we" includes all the folks who participated in the
development, which you seem to have missed.

If you choose to not read the newsgroup for a while, and something
that would have been of interest to you happens, it is not the
group's fault that you missed it.


>>It is equally clear "Tad"
>> is making any and all decisions regarding this FAQ


You seem to be ignorant of the decisions and discussion that
has taken place.

You should fix that. You are looking even sillier than usual...


>> Others elect to be bootlickers. I do not.


We are all very impressed by your assertiveness. Points to you.


>Do you want to discuss your long and accomplished history of
>abusing the group and its newbie posters? 


The repeated behavior described above it the reason why your
comments, and your's alone, will not be read by me.

I do not want to feed the troll.


>> what will be and will not be in this group,


   Should anyone be allowed to post anything they want here if
   it is even remotely connected to Perl?


I would like to be clear on what your position is.



>How about this: you submit your version of the guidelines,
>and we can talk about which points work in a high-volume
>newsgroup. We can do the same with Tad's. Then we can take
>a look at finalizing something. Any takers?


Please do. I have removed the water treatment plant from my
newsfeed temporarily.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Mon, 14 May 2001 20:51:08 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Cabal Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <tg0h9s21rvepef@corp.supernews.com>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Chris Stith wrote:

>> Godzilla! wrote:
>> > Randal L. Schwartz wrote:
>> > >  "Kira" == Godzilla! wrote:

>  
> (clearly snipped)


> Your article is a crock of excuse making mule manure.

What excuse? Where's the manure? You make an all-inclusive
statement without one quote?

> You need to polish your black jack boots, they have

I don't wear jack boots, thanks. I would perhaps take
offense at being called a facist if the speaker wasn't
a self-proclaimed giant lizard.

> lost their gloss. Some Spin Doctor, you are.

Me? No, I'm no spin doctor. I just tell it the way I
see it. If I happen to agree with a party line, then
I do. If I don't, then I don't. I'm happy to say
exactly what comes to mind. I promise you that I
don't always agree with Tad, but I often do. I don't
always agree with the principals of the Perl community
as a whole, but I often do. I usually don't agree with
you, but I've been sure to point out in certain posts
points on which I do agree with your point of view. Do
a search if you doubt me.

> I really don't care what you petty little lying
> fascist boys do. Your actions are abhorrent
> but amount to less than diddly-squat.

You do much typing to complain about something which
amounts to "less thanb diddly-squat"? You really don't
care? Then why are you so vocally against it?

BTW, if you really don't care, but make such a fuss,
then who is being petty? sub pot{ kettle = black }

> What I do care about is my having maintained both
> my dignity and my pride by speaking up for what is
> true and right.

You mean what _you_ think is true and what _you_ think
is right. As sad as this may be in your eyes, you do
not make up the group.

> "You Can Stand Me Up At The Gates Of Hell, But I Won't Back Down."

Hey, I'm a Tom Petty and the Heartbreakers fan, too.


-- 
It's not the U in UBE that pisses people off. It's the B.
  -- Martien Verbruggen in clp.misc



------------------------------

Date: Mon, 14 May 2001 13:53:32 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Cabal Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <3B0045CC.E5A294FC@stomp.stomp.tokyo>

Tad McClellan wrote:
 
> Chris Stith wrote:
> > Godzilla! wrote:
> >> Randal L. Schwartz wrote:
> >>>  "Kira" == Godzilla! wrote:

(snipped a typical "Tad" tossed temper tantrum)

Don't expect me to slip on a pair of glossy black
jack boots, a tan khaki shirt accessorized with an
arm band, then march to the beat of your empty
barrel. My ethical values make no allowances for
such repugnant behavior, as is yours.

Godzilla!


------------------------------

Date: Mon, 14 May 2001 21:21:29 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Cabal Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <tg0j2pn2ph55a0@corp.supernews.com>

Elaine Ashton <eashton@chaos.wustl.edu> wrote:
> On 5/14/01 1:31 PM, in article tg05kbqkqtmcbe@corp.supernews.com, "Chris
> Stith" <mischief@velma.motion.net> wrote:
>  
>> I may not know Randal well, but I have had many chances to
>> interact with him and have never found any of his acts to
>> be "morally repugnant". I realize my standards and yours

> You must have missed the episode where randal registered a
> domain as was going to retroactively remove all of this persons'
> postings from that domain.

Oh, i must have? You presume too much. Kira was violating
an RFC by posting from an assumed but valid domain. Randal
told her that was a bad idea. When she didn't listen, he
proved it was a abad idea by example. Examples are an effective
way to teach, communicate, and learn. I think Kira learned
something from that. I don't call that "morally repugnant".
I might call it a harsh decision on Randal's part, but I
don't think it to be immoral or unethical.

>> Tad is just the one willing to do the work. "Put up or
>> shut up" I believe is the appropriate idiom here. Or,
>> to quote Jarkko, Nick I-S, Gurusamy, Simon Cozens,
>> and others, "patches welcome". I suppose that since
>> Jarkko dedicates a gret many hours of his time to
>> being a pumpking that he is a bad person in your eyes?
>> Or I guess that Larry, since he desgined Perl, wrote
>> the first versions of the system to run it, and tries
>> to exert some self-limited control over how Perl
>> develops is a bad, bad, bad, bad man?

> The difference between those who do and those who don't
> is one group does stuff and the other talks about it.

What's you point?

> Also, if you look closely, those who do, don't spend
> a lot of time putting down the new and the clueless
> mostly because they are too busy doing something
> constructive.
 [line break adjusted for rebuttal]

The people who are working on the guidelines don't
put people down. 

So, since Randal, Damian Conway, Simon Cozens,
and Graham Barr sometimes post here you think
that the Llama, the Camel, _OOP_, perl.com,
libnet, and all the other things those people
have done is not "constructive"? What exactly
would you like to use for your reference
material on Perl?

 [quote line continued here]
> The people you quote don't hang around
> here as they fall into the 'do' category and don't
> have much time to waste and, if they do, aren't going
> to waste it here. 

This is a newsgroup. Those people are free to spend time
reading it. 

>> The most powerful Usenet tradition is to honor the posting
>> rules set forth in the specific newsgroup in question. So,
>> I guess you disapprove of trying to set forth these guidelines?
>> Why not just go to an 'alt' group then?

> It's a free country Perry Mason and keeping tradition with
> the human spirit, the more people shove you away the more
> you want to be near. Why would this person leave? They get
> more attention and entertainment value than mud wrestling on
> dollar beer night. It has been well over a year now...one would
> think that the someone would notice that the usual methods
> aren't working and there would be enlightenment somewhere.

Ohhhhhhhh. Naaaaaame Caaaaalllling... That hurts almost
enough for me to notice. I've been called a lawyer that
never loses. *weep*

The more people shove _me_ away, the more _I_ want to be
near? Again, you presume to know more about me than you do.

Hmmm. Dollar beer night. Haven't been to one of those in
a while.

I'm not trying to get Kira to leave. You presume too much.
I don't really care to change her mind, either. I only
think it's right that I say something in this public forum
about her posts which might change someone else's mind.
It's called discussion. That's _why_we're_here_.

I also think it's humorous that Kira claims to be speaking
on behalf of "the people" in order to disagree with Tad's
intent to draft a document already hashed out in group
discussions by "the people". Let me repeat that in case you
plan to question whether or not I know that I said it, like
you want to question my own knowledge of my own experiences
in other ways. I think it is humorous that Kira claims to
speak for the people in showing contempt for something Tad
is doing on behalf of the people of the group.

If you have a suggestion about the damn guidlines, post them.
If you only want to make personal attacks against Tad, Randal,
or other members of the group, then that's not related to Perl.

If you want to make personal attacks against me, then feel
free to post them to a web site and mail me a link. Hell, take
out a full-page ad in the New York _Times_ about how horrible
a person I am if you like. I really don't care. Just make sure
it's clear that it's your opinion. If you want to convince
others of your version of the truth, do some research and
use some facts. Don't presume to know something about me and
say it's fact. I take great offense to that.

Now, what was it you had to say about the guidelines?

Chris
-- 
People understand instinctively that the best way for computer programs to
communicate with each other is for each of the them to be strict in what they
emit, and liberal in what they accept. The odd thing is that people themselves
are not willing to be strict in how they speak, and liberal in how they listen.
 -- Larry Wall, 2nd State of the Onion Address, August 1998



------------------------------

Date: Mon, 14 May 2001 16:20:57 -0500
From: xris <xris@dont.send.spam>
Subject: Re: DBI weirdness...
Message-Id: <xris-F2D8C9.16205714052001@news.evergo.net>

On this note, is there any way to force a variable into "string mode" 
without doing something like "$var"?


In article <xris-8E5A75.21395611052001@news.evergo.net>,
 xris <xris@dont.send.spam> wrote:

> ok, all of a sudden, some of my sql code just started doing weird stuff, 
> and it seems to be related to DBI (which is why I'm posting it here 
> instead of in an sql group)...
> 
> first of all:
> 
>    Create Table CompanyVars (
>        var             VarChar(48) Primary Key,
>        val             Text Not Null
>    );
> 
> my code is as follows (more or less:
> 
> $sh = $dbh->prepare('REPLACE INTO CompanyVars (var,val) VALUES (?,?)');
> foreach $var (keys %Company) {
>    #...  do some stuff here to clean up
>    #...  some of the vars to make them pretty
>    $sh->execute($var, $Company{$var});
>    print "'$var' -> '$Company{$var}'\n",
>          $sh->errstr, "\n";
> }
> $sh->finish;
> 
> This results in: (I added the separators to make it easier to read)
> 
> ------------------------------------------------------------------------
> 'meta-usecatdescriptions' -> '1'
> ------------------------------------------------------------------------
> 'userwords' -> 'your company name, domain.com, www.domain.com'
> You have an error in your SQL syntax near 'company name, domain.com, 
> www.domain.com)' at line 1
> ------------------------------------------------------------------------
> 'info' -> 'This information is shown to search engines as they catalog 
> your site. Please say something informative.'
> You have an error in your SQL syntax near 'information is shown to 
> search engines as they catalog your site. Please say so' at line 1
> ------------------------------------------------------------------------
> 'ignoreordinals' -> '1'
> ------------------------------------------------------------------------
> 'ignorewords' -> 'pair, sale, item, this, that, the, their, can't, don't'
> You have an error in your SQL syntax near '\'t, don\'t)' at line 1
> ------------------------------------------------------------------------
> 'maxwords' -> '100'
> ------------------------------------------------------------------------
> 
> 
> correct me if I'm wrong, but isn't DBI supposed to examine each variable 
> individually when passed in as a replacement value?  such that a word 
> like "don't" would get converted to "'don\'t'" ?  It seems that when a 
> NUMBER is the first thing sent to execute(), all following parameters 
> are also treated as numbers (the errors go away if I don't evaluate the 
> numbers), and don't get the wrapping '' characters (but internal ' still 
> get convered to \' ).  So, when I do something as simple as:
> 
>    $sh->execute($var, "$Company{$var}");
> 
> the errors go away completely.
> 
> Maybe I'm just confused, but I'm pretty sure that the first bit of code 
> is SUPPOSED to work fine, regardless of what kind of data I'm sending 
> in, in whichever order.
> 
> Thanks,
> 
> Chris



------------------------------

Date: Mon, 14 May 2001 16:57:45 -0500
From: Chris <cpryce@pryce.net>
Subject: Re: DBI weirdness...
Message-Id: <B725BF09.51EC%cpryce@pryce.net>

in article xris-F2D8C9.16205714052001@news.evergo.net, xris at
xris@dont.send.spam wrote on 05/14/2001 4:20 PM:

> On this note, is there any way to force a variable into "string mode"
> without doing something like "$var"?

[ long snip of previous post ]

Yes. See perldoc DBI.

One way (code not verified):

 use DBI qw(:sql-types);

 ... [ assume you have a valid DataBase Handle ($dbh) ]

 my $sth = $dbh->prepare('insert INTO foo (var, val) VALUES (?,?)');
 $sth->bind_param(1, $var, SQL_VARCHAR);
 $sth->bind_param(2, $val, SQL_INTEGER);
 $sth->execute($var, $val);


quotes $var correctly for an SQL char variable and $val correctly for an
SQL_INTEGER, depending on whether the database driver supports parameter
binding and sql-types. Most drivers default to SQL_VARCHAR as the type if
none is specified, so, in most cases, the above can be shortened to:

 my $sth = $dbh->prepare('insert INTO foo (var, val) VALUES (?,?)');
 $sth->bind_param(2, $val, SQL_INTEGER);
 $sth->execute($var, $val);


You can also pass the data-type as an attribute, as:

 $sth->bind_param(1, $var, { TYPE => SQL_INTEGER } );
 
or, if you have a database specific data type:
 $sth->bind_param(1, $var, { ora_type => 97} );

Which, of course, is not portable.

Finally, you can also use the DBI quote method. Again, assuming you have a
valid database handle:

 my $quoteValue = $dbh->quote($value); # or quote($value, $data_type);

This should prepare even a string like (Don't) properly, even converting
undefined values to the sql NULL value. I prefer parameter binding. YMMV
depending on the driver you use.

perldoc DBI 

Has a longer discussion of the subject, and will give you the particulars on
quote and bind_param, including a list of data_types.

cp



------------------------------

Date: Mon, 14 May 2001 22:00:16 GMT
From: "David M. Lloyd" <dmlloyd@tds.net>
Subject: Finding the caller from XS
Message-Id: <Pine.LNX.4.21.0105141652500.19409-100000@homebody.freemm.org>

Is there any easy way to discover who the caller is from an XS extension?  
Specifically I am looking for a filename (as a char *, one way or the
other) and line number.

I looked at the code for 'caller' in pp_ctl.c and my jaw just about hit
the floor... I'm hoping that it is easier than that to just get basic info
about the caller off the top of the stack.

- D

<dmlloyd@tds.net>



------------------------------

Date: Mon, 14 May 2001 15:58:52 -0400
From: a246456 <a246456@fmr.com>
Subject: Re: FTP->new
Message-Id: <3B0038FC.CBE56C70@fmr.com>

Are u using bin mode, default it should be in ASCII mode.. Try this and see..

ravikrishna@nospam.com wrote:

> Thanks. It worked.
>
> Now the next question. Some of the files I am ftping are
> huge files (80MB). Most of the time ftp fails after 35 MB or so.
> No it has nothing to do with timeout since I have set it to
> 36000 ( 10 hrs). I know we are having bandwidth problems.
> Could it be due to that?
>
> Also if I increase the blocksize (default 10K) to 40K as follows,
>
> my $ftp = Net::FTP->new($machineName,Timeout => 36000,BlockSize => 40960);
>
> will it make FTP faster and more reliable.
>
> thanks.
>
> Ravi.
>
> "Milton Road" <miltonroad@btinternet.com> wrote >
> > > I am using perl FTP.
> > >
> > >  my $ftp = Net::FTP->new($machineName,Timeout => 300) ;
> > >
> > > The timeout is in minutes right. So the default of 120 is 2 hours.
> >
> > Your timeout is in seconds, Ravi.  Therefore the default of 120 is two
> > minutes.
> >
> > Amazingly, the Net::FTP docs on the constructor don't seem to specify
> > seconds - possibly because its reasonably self-explanatory.
> >
> > Anyway, you know now.
> >
> > Milton
> >
> >
> >
> >
> >



------------------------------

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 897
**************************************


home help back first fref pref prev next nref lref last post