[29010] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 254 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 22 16:09:50 2007

Date: Thu, 22 Mar 2007 13:09:10 -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           Thu, 22 Mar 2007     Volume: 11 Number: 254

Today's topics:
    Re: getting DBI and ODBC to work with PERL and MYSQL da <jgibson@mail.arc.nasa.gov>
    Re: getting DBI and ODBC to work with PERL and MYSQL da <sigzero@gmail.com>
    Re: I dotn understand this error <hjp-usenet2@hjp.at>
        LWP hangs yahavba@gmail.com
    Re: LWP hangs (Jamie)
    Re: LWP hangs yahavba@gmail.com
    Re: LWP hangs yahavba@gmail.com
    Re: my $session = new CGI::Session() <glex_no-spam@qwest-spam-no.invalid>
    Re: Net DNS Update problem <nobull67@gmail.com>
        parsing a tab delimited or CSV, but keep the delimiter <christian.bongiorno@gmail.com>
    Re: Problem with indirect variables <nobull67@gmail.com>
    Re: Problem with indirect variables <jurgenex@hotmail.com>
    Re: Server/Clients system <hjp-usenet2@hjp.at>
    Re: Server/Clients system <hjp-usenet2@hjp.at>
    Re: variable evaluation and printing <mritty@gmail.com>
    Re: variable evaluation and printing <nobull67@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 22 Mar 2007 12:11:58 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: getting DBI and ODBC to work with PERL and MYSQL data source
Message-Id: <220320071211583289%jgibson@mail.arc.nasa.gov>

In article <1174566506.520721.83560@y66g2000hsf.googlegroups.com>, Paul
Lalli <mritty@gmail.com> wrote:

> On Mar 22, 12:07 am, "Jack" <jack_posem...@yahoo.com> wrote:
> > Hi folks,
> >
> > On windows server 2003 I installed the Mysql ODBC driver, created a
> > dsn, and installed DBI and DBD::ODBC perl modules.  Does anyone have
> > experience issuing a SQL query through PERL to Mysql.. here is my
> > program, the uncommented pieces worked great but when I remove the
> > comments for the bottom 2 rows I get the error indicated:
> >
> > use DBD::ODBC;
> > use strict;
> > use diagnostics;
> > use DBI;
> > eval {
> >   my $dbh = DBI->connect('DBI:ODBC:mysqldsn;host=localhost;', 'root',
> > 's1ghtspr1ng7281',
> >  { 'RaiseError' => 1, 'PrintError' => 0, 'AutoCommit' => 0} );
> >  }; # eval
> > # $sth = $dbh->prepare("SELECT testcol1 FROM temptable");
> > # $sth->execute( $baz );
> >
> > ERROR:
> > E:\tmp>perl odbc_test2.pl
> > Global symbol "$sth" requires explicit package name at odbc_test2.pl
> > line 14.

[good advice from Paul snipped]

And in addition you will need to declare $sth and $baz with 'my',
although you probably don't need $baz in your execute statement as you
have no bound variables in your SQL prepare statement.

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: 22 Mar 2007 12:26:10 -0700
From: "Robert Hicks" <sigzero@gmail.com>
Subject: Re: getting DBI and ODBC to work with PERL and MYSQL data source
Message-Id: <1174591570.540964.99650@l77g2000hsb.googlegroups.com>

On Mar 22, 12:07 am, "Jack" <jack_posem...@yahoo.com> wrote:
> Hi folks,
>
> On windows server 2003 I installed the Mysql ODBC driver, created a
> dsn, and installed DBI and DBD::ODBC perl modules.  Does anyone have
> experience issuing a SQL query through PERL to Mysql.. here is my
> program, the uncommented pieces worked great but when I remove the
> comments for the bottom 2 rows I get the error indicated:
>
> use DBD::ODBC;
> use strict;
> use diagnostics;
> use DBI;
> eval {
>   my $dbh = DBI->connect('DBI:ODBC:mysqldsn;host=localhost;', 'root',
> 's1ghtspr1ng7281',
>  { 'RaiseError' => 1, 'PrintError' => 0, 'AutoCommit' => 0} );
>  }; # eval
> # $sth = $dbh->prepare("SELECT testcol1 FROM temptable");
> # $sth->execute( $baz );
>
> ERROR:
> E:\tmp>perl odbc_test2.pl
> Global symbol "$sth" requires explicit package name at odbc_test2.pl
> line 14.
> Global symbol "$dbh" requires explicit package name at odbc_test2.pl
> line 14.
> Global symbol "$sth" requires explicit package name at odbc_test2.pl
> line 15.
> Global symbol "$baz" requires explicit package name at odbc_test2.pl
> line 15.
> Execution of odbc_test2.pl aborted due to compilation errors (#1)
>     (F) You've said "use strict vars", which indicates that all
> variables
>     must either be lexically scoped (using "my"), declared beforehand
> using
>     "our", or explicitly qualified to say which package the global
> variable
>     is in (using "::").
>
> Uncaught exception from user code:
>         Global symbol "$sth" requires explicit package name at
> odbc_test2.pl lin
> e 14.
> Global symbol "$dbh" requires explicit package name at odbc_test2.pl
> line 14.
> Global symbol "$sth" requires explicit package name at odbc_test2.pl
> line 15.
> Global symbol "$baz" requires explicit package name at odbc_test2.pl
> line 15.
> Execution of odbc_test2.pl aborted due to compilation errors.
>  at odbc_test2.pl line 16

Any reason you are using ODBC and not DBD::MySQL?



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

Date: Thu, 22 Mar 2007 20:58:35 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: I dotn understand this error
Message-Id: <slrnf05nvb.v7v.hjp-usenet2@yoyo.hjp.at>

On 2007-03-21 09:42, Νίκος <hackeras@gmail.com> wrote:
> I invoke it through firefox liek http://10.0.0.2

That's the uninteresting part. There is no Perl involved between your
browser and the server (unless you have an OS written in Perl :-)). The
interesting part is how the server invokes your perl code.

	hp

-- 
   _  | Peter J. Holzer    | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR       | to write clearly is like blaming English for
| |   | hjp@hjp.at         | the circumlocutions of bureaucrats.
__/   | http://www.hjp.at/ |	-- Charlton Wilbur in clpm


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

Date: 22 Mar 2007 11:24:52 -0700
From: yahavba@gmail.com
Subject: LWP hangs
Message-Id: <1174587892.710577.274770@n59g2000hsh.googlegroups.com>

Hi,
I'm using LWP on win32. Sometimes after a period of successfull
communication, the perl process just hangs, and it seems like LWP
stopped. The debug messages are:

LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()

in this stage the script stalls and i have to stop it using task
manager.

does anyone know why this might happen?

I'd appreciate you help!

Thanks



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

Date: Thu, 22 Mar 2007 19:18:57 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: LWP hangs
Message-Id: <Lc1174570991123070x8bfe974@pong.podro.com>

In <1174587892.710577.274770@n59g2000hsh.googlegroups.com>,
yahavba@gmail.com mentions:
>Hi,
>I'm using LWP on win32. Sometimes after a period of successfull
>communication, the perl process just hangs, and it seems like LWP
>stopped. The debug messages are:
>
>LWP::UserAgent::_need_proxy: Not proxied
>LWP::Protocol::http::request: ()
>
>in this stage the script stalls and i have to stop it using task
>manager.
>
>does anyone know why this might happen?

Is it going through a proxy?

Can you tell us where/which method it's hanging on? Sometimes
I'll override the methods (get/post/etc..) and have it spit out
the URL and the parameters it's trying to use. Then I'll go in with
telnet and try to mimick what it would/should do, sort of working 
around from there. The key is in figuring out if it's LWP or if
it's something to do with the underlying network.

Course, if it's SSL, things get a little tricky..

Jamie
-- 
http://www.geniegate.com                    Custom web programming
Perl * Java * UNIX                        User Management Solutions


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

Date: 22 Mar 2007 12:38:45 -0700
From: yahavba@gmail.com
Subject: Re: LWP hangs
Message-Id: <1174592325.193879.192890@y66g2000hsf.googlegroups.com>

On Mar 22, 9:18 pm, nos...@geniegate.com (Jamie) wrote:
> In <1174587892.710577.274...@n59g2000hsh.googlegroups.com>,
> yaha...@gmail.com mentions:
>
> >Hi,
> >I'm usingLWPonwin32. Sometimes after a period of successfull
> >communication, the perl process justhangs, and it seems likeLWP
> >stopped. The debug messages are:
>
> >LWP::UserAgent::_need_proxy: Not proxied
> >LWP::Protocol::http::request: ()
>
> >in this stage the script stalls and i have to stop it using task
> >manager.
>
> >does anyone know why this might happen?
>
> Is it going through a proxy?
>
> Can you tell us where/which method it's hanging on? Sometimes
> I'll override the methods (get/post/etc..) and have it spit out
> the URL and the parameters it's trying to use. Then I'll go in with
> telnet and try to mimick what it would/should do, sort of working
> around from there. The key is in figuring out if it'sLWPor if
> it's something to do with the underlying network.
>
> Course, if it's SSL, things get a little tricky..
>
> Jamie
> --http://www.geniegate.com                   Custom web programming
> Perl * Java * UNIX                        User Management Solutions

Hi,
It's hanging on get. I'm using get on a url which is secured (https),
and it works for quite a long time untill suddenly it stops and
hangs.
When you say you override the method - how exactly is it done? how can
i verify what parameters it is trying to use?

thanks for you help!



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

Date: 22 Mar 2007 12:39:36 -0700
From: yahavba@gmail.com
Subject: Re: LWP hangs
Message-Id: <1174592376.772979.311310@n76g2000hsh.googlegroups.com>

On Mar 22, 9:18 pm, nos...@geniegate.com (Jamie) wrote:
> In <1174587892.710577.274...@n59g2000hsh.googlegroups.com>,
> yaha...@gmail.com mentions:
>
> >Hi,
> >I'm usingLWPonwin32. Sometimes after a period of successfull
> >communication, the perl process justhangs, and it seems likeLWP
> >stopped. The debug messages are:
>
> >LWP::UserAgent::_need_proxy: Not proxied
> >LWP::Protocol::http::request: ()
>
> >in this stage the script stalls and i have to stop it using task
> >manager.
>
> >does anyone know why this might happen?
>
> Is it going through a proxy?
>
> Can you tell us where/which method it's hanging on? Sometimes
> I'll override the methods (get/post/etc..) and have it spit out
> the URL and the parameters it's trying to use. Then I'll go in with
> telnet and try to mimick what it would/should do, sort of working
> around from there. The key is in figuring out if it'sLWPor if
> it's something to do with the underlying network.
>
> Course, if it's SSL, things get a little tricky..
>
> Jamie
> --http://www.geniegate.com                   Custom web programming
> Perl * Java * UNIX                        User Management Solutions

Also, it's not going through a proxy (and it is using SSL)
thanks!



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

Date: Thu, 22 Mar 2007 13:39:15 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: my $session = new CGI::Session()
Message-Id: <4602db63$0$492$815e3792@news.qwest.net>

Kevin wrote:
> When I try to initialize a CGI session with my $session = new
> CGI::Session(), my script hangs and eventually throws a CGI timeout.
> This actually occurs when trying to create a new anything, be it
> session, or CGI, or anything. Any thoughts?

What's a "CGI timeout"?  The error message it provides, should be a bit 
more descriptive.


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

Date: 22 Mar 2007 12:00:16 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Net DNS Update problem
Message-Id: <1174590016.334260.90080@b75g2000hsg.googlegroups.com>

On Mar 21, 1:58 pm, "milney_boy" <milney...@googlemail.com> wrote:

> I'm trying to write a script to update records on my BIND server.  To
> start with I am writing a simple script to add and delete A records.
>
> I want to be able to have multiple A records with the same hostname/
> alias but with different IP addresses.  When it comes to deleting
> them, I want to use the yxrrset to make sure the exact record exists
> first (so that i know if for some reason it does not exist).
>
> The problem is that whilst the value-dependant yxrrset seems to work
> correctly when there is only a single A record with the same
> hostname/ alias, it always reports nxrrset when there is more
> than one.

The behaviour of BIND that you are describing appears to be correct
according to RFC2136 section 2.4.2 which states "For this
prerequisite, a requestor adds to the section an _entire_ RRset whose
preexistence is required.". BIND is checking for set _equality_ not
checking for set inclusion.

This, of course, has nothing to do with Perl.



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

Date: 22 Mar 2007 13:04:54 -0700
From: "Sideswipe" <christian.bongiorno@gmail.com>
Subject: parsing a tab delimited or CSV, but keep the delimiter
Message-Id: <1174593894.031960.239750@b75g2000hsg.googlegroups.com>

I know this question has been asked before, and believe me I checked
the newsgroup and web extensively before asking, but I think my needs
are slightly different.

I need to parse either a CSV or a Tab delimited file, BUT I need to
keep the delimiting token -- I am parsing these files as generated
from excel and the user expects them to process EXACTLY as it appears
in the spreadsheet.


I am cross posting this in the Perl and Java groups because, my
implementation is in Java, but Perl users use regexp far more
frequently.

Here are the 3 different REGEX expressions I have found /created but
none are correct. The only certainty I can get is to get rid of all
the delimiters. I have to maintain the delimiters because the
information I am accessing is column based (and thus fixed)

private final Pattern COLUMN_PATTERN = Pattern.compile("(\"[^\"]*\",,|
[^,]+)"); // I think this close
private final Pattern COLUMN_PATTERN = Pattern.compile("([^\",]*|\"([^
\"]|\"\")+\")(,)");
private final Pattern COLUMN_PATTERN = Pattern.compile(",(?=(?:[^\\\"]*
\\\"[^\\\"]*\\\")*(?![^\\\"]*\\\"))");

So, you have the cases of:

1) continuous string or with space   -> single ',' (comma) separated
2) String has a comma in it, and is "" -> it is followed by a ",,"
double comma token. So the string in "" is a token and the  double
comma is also a token
3) blank cells are just a single comma ,

That's my understanding of the cases. The logic should be IDENTICAL
for tab delimited and simply substitute characters



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

Date: 22 Mar 2007 11:20:24 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Problem with indirect variables
Message-Id: <1174587624.439117.321410@b75g2000hsg.googlegroups.com>

On Mar 22, 5:08 pm, Marshall Dudley <mdud...@king-cart.com> wrote:
> Why can I not get the second variable to print it's value in the
> following code?

Because expanding a symbolic reference just does a single look up in
the package symbol table. It does not evaluate an arbitrary string as
Perl code.

> $test = "Test String";
> $form_data{'test'} = "form data variable";
> foreach $string (test,"form_data{'test'}") {
>         print "$string = $$string\n";

You are telling perl to look for single scalar package variable the
name of which is literally the string "form_data{'test'}". That is to
say there literally are braces and quote characters in the _name_ of
the scalar variable. I suspect you wanted to get at the value in the
hash %form_data associated with the key 'test'.

I'm now going to show you how you'd make Perl do what you thought
would happen

Do not actually do it.

To do so would be stupid**100.

Let me say that again, to actually do this would be stupid**100.

Is that clear?

OK here goes.

     print "$string = ",eval( '$' . $string), "\n"; # Don't actually
do this!

Now, what was it you really wanted to do?



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

Date: Thu, 22 Mar 2007 18:45:25 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: Problem with indirect variables
Message-Id: <99AMh.18984$Hb2.10104@trndny02>

Marshall Dudley wrote:
> Why can I not get the second variable to print it's value in the
> following code?
>
> $test = "Test String";
> $form_data{'test'} = "form data variable";
> foreach $string (test,"form_data{'test'}") {
>        print "$string = $$string\n";


Had you enabled warnings then perl would have told you:
    Use of uninitialized value in concatenation (.) or string at ....

In short: You do not have a variable that is named
    form_data{'test'}

Besides that what you are trying to do is known as symbolic references and 
it is A BAD IDEA!
See the FAQ "How can I use a variable as a variable name?" for details about 
why and what to use instead.

jue 




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

Date: Thu, 22 Mar 2007 20:54:59 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Server/Clients system
Message-Id: <slrnf05noj.v7v.hjp-usenet2@yoyo.hjp.at>

On 2007-03-21 01:21, Jamie <nospam@geniegate.com> wrote:
> One thing I would really like to do (alas, have no business model for it)
> is to marry NNTP with podcasts and RSS.
>
> So called "flooding protocol" is something I find quite amusing, and aside from
> NNTP (AFAIK) isn't widely used anymore. Seems like it's almost always a central
> master -> slave model, (mirrors, etc.. CPAN for example) 
>
> Having "NPTP" (Net Podcast Transfer Protocol? NRTP Net RSS Transfer Protocol?)
[...]
> Unlike NNTP, the enclosures and other RSS fields would have to be planned for
> (possibly with delayed transfer/referral of enclosures)

I think regular NNTP would work just fine for that. Just use appropriate
content-types (application/rss+xml, audio/*, video/* or whatever). You
may want a subscription mechanism in the protocol (NNTP for normal
newsgroup could use one, too, but subscribing whole hierarchies is
"traditional" and so far nobody has had enough incentive to push for a
more fine-grained approach).


> No money, and I have a hard time seeing how someone would want to pay for it
> (much less pay for the hardware and bandwidth) If I could find a practical
> business model for what I just described, I'd be doing it. :-)

The business model is simple: Make huge losses for a couple of years,
don't give any hint how you ever plan on making money, then sell to one
of the big players for several hundred million bucks :-).

	hp


-- 
   _  | Peter J. Holzer    | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR       | to write clearly is like blaming English for
| |   | hjp@hjp.at         | the circumlocutions of bureaucrats.
__/   | http://www.hjp.at/ |	-- Charlton Wilbur in clpm


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

Date: Thu, 22 Mar 2007 20:56:47 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Server/Clients system
Message-Id: <slrnf05nrv.v7v.hjp-usenet2@yoyo.hjp.at>

On 2007-03-21 16:38, deadpickle <deadpickle@gmail.com> wrote:
> How can I transfer large files using HTTP? where do I get started then?

Same as small ones[0]. There's no size limit in HTTP. There's also the
Range: header for partial transfers, should you need it.

	hp

[0] Well, that depends on what you call "large".

-- 
   _  | Peter J. Holzer    | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR       | to write clearly is like blaming English for
| |   | hjp@hjp.at         | the circumlocutions of bureaucrats.
__/   | http://www.hjp.at/ |	-- Charlton Wilbur in clpm


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

Date: 22 Mar 2007 11:26:10 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: variable evaluation and printing
Message-Id: <1174587970.374976.26550@y66g2000hsf.googlegroups.com>

On Mar 22, 12:56 pm, "manunderstress" <cha...@gmail.com> wrote:
> > You are trying to use symbolic references, and have demonstrated one
> > reason they are not recommended (they only work on global variables and
> > your variables are lexical).
>
> > See 'perldoc -q variable
>
> >      How can I use a variable as a variable name?
>
> > for other reasons why not to do this. Use a hash, instead.
>
> Fair enough, but now I'm at a loss how else to do what I want to do,
> that is, without using scalar variables I have previously created in
> the script as keys for the hash (%post_checks)- and their evaluation
> as the value for the hash.
>
> I have a bunch of scalar variables that will be dynamically generated
> (hostid, ifconfig, whatever) and I want to add each key->value pair  -
> if it exists- to a hash (what I thought I was doing...by adding key->values to %post_checks).

Don't dynamically generate scalar values.  Dynamically generate the
key/value pairs.

You're not showing us how you're "dynamically generating" the scalar
values, so we can't help you fix that part of your program. . .

Paul Lalli




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

Date: 22 Mar 2007 11:38:01 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: variable evaluation and printing
Message-Id: <1174588681.837591.38330@b75g2000hsg.googlegroups.com>

On Mar 22, 4:56 pm, "manunderstress" <cha...@gmail.com> wrote:
> > You are trying to use symbolic references,
> > and have demonstrated one
> > reason they are not recommended (they only work on global
> > variables and your variables are lexical).
>
> > See 'perldoc -q variable
>
> >      How can I use a variable as a variable name?
>
> > for other reasons why not to do this. Use a hash, instead.
>
> Fair enough, but now I'm at a loss how else to do what I want to do,
> that is, without using scalar variables I have previously created in
> the script as keys for the hash (%post_checks)- and their evaluation
> as the value for the hash.
>
> I have a bunch of scalar variables that will be dynamically generated
> (hostid, ifconfig, whatever) and I want to add each key->value pair  -
> if it exists- to a hash (what I thought I was doing...by adding key-
> values to %post_checks).

And therein is the problem. Why is it that you are attached to the
idea that you want "a bunch of [named] scalar variables that will be
dynamically generated"?  This is precisely what people here (and the
FAQ) are advising against (at least as a general rule). The way to
have a "bunch" of scalars in Perl is (in general) to make them into a
hash in the first place.

If you are really determined to go with "a bunch of [named] scalar
variables that will be dynamically generated" then you have no choice
but to use symrefs (or their even more evil cousin, eval()).

Can you perhaps explain what it is that you expect to gain from using
"a bunch of [named] scalar variables" rather than a hash?



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

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


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