[28921] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 165 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 23 03:10:09 2007

Date: Fri, 23 Feb 2007 00:09:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 23 Feb 2007     Volume: 11 Number: 165

Today's topics:
    Re: Any 3270 emulation for perl yet? <uri@stemsystems.com>
    Re: behavior of my print function call <evad.notyals@liamg.moc>
    Re: Cant connect to mysql from perl interface <rpallapotu@gmail.com>
        Direct standard output to printer. <laidlaws@dougshost.invalid>
    Re: Direct standard output to printer. <spamtrap@dot-app.org>
    Re: fork()-ing questions <tadmc@augustmail.com>
    Re: fork()-ing questions <kevin@vaildc.net>
    Re: net::mysql holds onto my query <glex_no-spam@qwest-spam-no.invalid>
    Re: net::mysql holds onto my query <tadmc@augustmail.com>
        new CPAN modules on Fri Feb 23 2007 (Randal Schwartz)
    Re: Regex: Why is overreaching necessary? <Shannon.Jacobs.nospam@gmail.com>
        Text::CSV and Mysql - invalid number of columns azzi.george@gmail.com
    Re: Text::CSV and Mysql - invalid number of columns <1usa@llenroc.ude.invalid>
    Re: Text::CSV and Mysql - invalid number of columns <paduille.4060.mumia.w+nospam@earthlink.net>
    Re: ucfirst() with "_" separator <rvtol+news@isolution.nl>
    Re: ucfirst() with "_" separator <stoupa@practisoft.cz>
    Re: Unable to install Math::BigInt::GMP on Solaris 10 <sisyphus1@nomail.afraid.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 22 Feb 2007 21:11:15 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Any 3270 emulation for perl yet?
Message-Id: <x7d5411v3w.fsf@mail.sysarch.com>

>>>>> "R" == RedGrittyBrick  <RedGrittyBrick@SpamWeary.foo> writes:

  R> Fred wrote:
  >> I searched for a perl 3270 emulator several years ago, and could
  >> find none.  I wound up using the s3270 emulator wrapped
  >> in a perl script.  I've been searching again, and still do
  >> not see a perl based 3270 emulator.  Since a perl 3270
  >> emulator apparently still does not exist, I guess the
  >> question is why?

  R> Maybe because the 3270 is so complex, weird and little-used nowadays?

it is still a major i/o style for many legacy mainframes. that is why
there are many software emulators around. not much in the way of
physical terminals may exist anymore but i don't know for sure.

  R> The original 3270 was connected by Coax cable, not serial cable, not
  R> by Ethernet (nor even Token Ring originally).

well it was used way before those were invented. hell, the simple ascii
terminal wasn't in use then too. and they did use serial lines when used
over a modem (at least the modem part did).

  R> The original 3270 used a proprietary block-mode communications
  R> protocol. I think it was synchronous rather than asynchronous.

bisync. it used a 2 byte sync char and was half duplex/polled.

  R> The 3270 uses the EBCDIC character set.

the least of its craziness. :)

  R> Perhaps Uri is busy scrutinizing RFC1576 :-)

nope. i actually used a 3270 emulator package from DEC on RT-11 way
before most of you were born. i even found a bug in it which proved that
we were the first real world users of it (it started an ack0/ack1
pattern on the wrong foot). so i know about the protocol (bisync) and
polling and such. this last fall i even helped someone i know with using
some 3270 emulation package under perl. but i won't be writing a module
for this as no itch could possibly make me care about the 3270.

a cluster of 3270s would share a single controller/modem which would
connect over a phone line to the mainframe. so it used some form of
serial line at that level. there might have been some form of coax
between the terminals and the controller. i didn't ever get into
physical use of 3270's so i may be wrong on the wiring but the protocol
i did know some way back when.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 22 Feb 2007 20:49:02 -0700
From: "Dave Slayton" <evad.notyals@liamg.moc>
Subject: Re: behavior of my print function call
Message-Id: <Z6Gdneqkn7zR-UPYnZ2dnUVZ_vKunZ2d@comcast.com>

<xhoster@gmail.com> wrote in message 
news:20070219121906.713$wl@newsreader.com...
> What kind of answer to "why" are you looking for?
>      ........
>      ........
> print $fh_hash{$key} ($line);
> Now, is $fh_hash{$key} a simple scalar variable?  No.  So then we 
> interpret
> the print as taking a list, not a filehandle followed by a list.  What
> would the degenerate list $fh_hash{$key}($line) be interpreted as?  A call
> to a subroutine via a code-ref, of course.
>

Ok, there, THAT kind of answer to "why" is the kind I was looking for. 
Thank you. 




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

Date: 22 Feb 2007 21:23:26 -0800
From: "Ramesh" <rpallapotu@gmail.com>
Subject: Re: Cant connect to mysql from perl interface
Message-Id: <1172208206.604029.305170@j27g2000cwj.googlegroups.com>

On Feb 22, 8:24 am, "Ramesh" <rpallap...@gmail.com> wrote:
> On Feb 21, 11:24 pm, Tintin <tin...@invalid.invalid> wrote:
>
>
>
> > Ramesh wrote:
> > > On Feb 21, 4:27 pm, use...@DavidFilmer.com wrote:
> > >> On Feb 21, 4:07 pm, "Ramesh" <rpallap...@gmail.com> wrote:
>
> > >>> I see my perl crashing.
> > >> You should never let Perl drive your car.
>
> > >>> Can someone please give me some suggestions on how to fix this?
> > >> Why are you asking us what the problem is when you haven't even asked
> > >> Perl what the problem is?
>
> > >>> $dbh = DBI->connect("DBI:mysql:database=test", 'xxx', 'xxx');
> > >> Try:
>
> > >> $dbh = DBI->connect("DBI:mysql:database=test", 'xxx', 'xxx')
> > >>        or die $DBI::errstr;
>
> > >> --
> > >> The best way to get a good answer is to ask a good question.
> > >> David Filmer (http://DavidFilmer.com)
>
> > > Thanks for the tip. I added the die $DBI::errstr; as you suggested but
> > > I still dont see any output. Cant figure out why perl crashes even
> > > though I put this statement.
>
> > Proper diagnosis of a problem requires exact error messages or
> > description of how it's not behaving as expected.
>
> > Perl crashes is as useless a description as "does not work".
>
> > --
> > Posted via a free Usenet account fromhttp://www.teranews.com-Hide quoted text -
>
> > - Show quoted text -
>
> I get the followin popup - "Perl Command Line Interpreter has
> encountered a problem and needs to close. We are sorry for the
> inconvenience". I clicked on Debug and I get - An exception 'Unhandled
> Win32 Exception' has occured in perl.exe.


Problem got resolved by upgrading to following versions
DBI 1.53
DBD-mysql 4.001
from http://theoryx5.uwinnipeg.ca/ppmpackages




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

Date: Fri, 23 Feb 2007 14:00:04 +1100
From: Doug Laidlaw <laidlaws@dougshost.invalid>
Subject: Direct standard output to printer.
Message-Id: <ku12b4-er7.ln1@dougshost.douglaidlaw.net>

I have a Perl script (pcal) which prints to standard output.  I didn't write
it. 

The relevant line is $THECAL=`....'; print $THECAL;

I want to modify this line to print to the default (local) printer on lpr. 
How do I go about this?

TIA,

Doug.
-- 
Books are good enough in their own way; but they are
a mighty bloodless substitute for life.
-R.L. Stevenson.



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

Date: Fri, 23 Feb 2007 00:36:37 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Direct standard output to printer.
Message-Id: <m2odnlwi3e.fsf@local.wv-www.com>

Doug Laidlaw <laidlaws@dougshost.invalid> writes:

> I have a Perl script (pcal) which prints to standard output.  I didn't write
> it. 
>
> The relevant line is $THECAL=`....'; print $THECAL;
>
> I want to modify this line to print to the default (local) printer on lpr. 
> How do I go about this?

Open a pipe to lpr and select it:

    my $THECAL = '....';
    open my $lpr, '|-', '/usr/bin/lpr'
        or die "Could not open lpr pipe: $!";
    select $lpr;
    print $THECAL;

For details:

    perldoc -f select
    perldoc -f open

If you want to make only one or two prints go to lpr, instead of all of
them, you can specify the filehandle in the print:

    print $lpr $THECAL;

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Thu, 22 Feb 2007 18:25:18 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: fork()-ing questions
Message-Id: <slrnetsd3e.jgp.tadmc@tadmc30.august.net>

Monty <dale.schmitz@offutt.af.mil> wrote:
> I see the error in my thinking.  Somewhere along the lines, between
> teaching myself Perl, C++, Tcl/Tk, Ada, and various flavors of shells,
> I ran across a piece of knowledge that said executable statements
> could be put in place of conditional tests and the truth/falseness
> would be based on the success of that executable statement.  I was
> erroneous in thinking that Perl did this and that's behind my
> confusion over the 'unless' statement.  I found this out by running a
> bit of test code:
>
> 'if ($pid = 0)' evaluates to false and 'if ($pid = 1)' evaluates to
> true


No, no, no. Rather:

   'if ($pid = 0)' does not execute its block, and 'if ($pid = 1)'
   does execute its block. 

(an if statement does not "evaluate" to anything, because it 
 is not an expression.)

or

   '$pid = 0' evaluates to false and '$pid = 1 evaluates to true

(because assignment in scalar context evaluates to whatever is
 on the RHS of the assignment.)

> 'if ({$pid = 0})' evaluates to true, as does 'if ({$pid = 1})'


The curlys return a reference to a hash, and references
are always a true value.


> That clears things up considerably.


But it doesn't.


> I'm going to end this discussion right here.


Don't stop yet, unless you got the part of Uri's and Michele's
posts about the value of an assignment statement in scalar context.


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


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

Date: Fri, 23 Feb 2007 05:41:51 GMT
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: fork()-ing questions
Message-Id: <kevin-F8554B.00415123022007@news.verizon.net>

In article <8OjDh.1958$aM.1775@trndny03>,
 "Jürgen Exner" <jurgenex@hotmail.com> wrote:

> Therefore first the fork() is executed (only once), now all of a sudden you 
> got two individual processes, and in both processes the return value of 
> fork() is assigned to their respective $pid variable, and then both 
> processes continue execution.

The way it was explained to me way back when I was learning Unix was 
that fork() is called once, but returns twice, once in each process (and 
then I found out that exec() is called once, and doesn't return at all, 
so there is balance in the world).
-- 
Kevin Michael Vail  | "This is so cool I have to go to the bathroom!"
kevin@vaildc.net    |                   -- Calvin



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

Date: Thu, 22 Feb 2007 18:11:08 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: net::mysql holds onto my query
Message-Id: <45de3112$0$10302$815e3792@news.qwest.net>

Lee wrote:
>> [...]
>> How would that help anyone???...
> No clue!
> 
>> Try using DBI.
> 
> So... what is the consensus on what to use?  DBD::mysql?  or the class
> for DBI?

ahhh.. you'd use/install both. DBI is the interface, DBD is the driver.

You'd 'use' DBI, and when it calls its 'connect' method, you
specify what driver it should use.  That way you could write
all of your code to use the DBI methods, then, if your
database changes, you might simply have to change only
the driver you specify and that's it.

Really though, since other queries seem to work, it's
likely that it's running and sending back the results.
Maybe it's waiting until the results are all
sent back.  Try doing an EXPLAIN on your SQL, or
maybe add "limit 1" to your SQL.  In addition,
you could watch your process, as it's running, to
see if it's using more and more memory (storing
the results) or if it's just sitting there
(waiting for results).  And check to see what
the database is doing (show processlist).

As a quick test, you could save your SQL in a
file (file.sql) , and use the mysql client to
run your query.

% mysql -u someuser -psomepassword -h some.host.com some_database < 
file.sql > output

If that runs within some expected time, then try DBI,
if the above exhibits the same problem, then your
SQL is at fault and the EXPLAIN should help
figure that out.


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

Date: Thu, 22 Feb 2007 18:03:53 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: net::mysql holds onto my query
Message-Id: <slrnetsbr9.jgp.tadmc@tadmc30.august.net>

Lee <lskatz@gmail.com> wrote:
>> [...]
>> How would that help anyone???...
> No clue!
>
>>
>> Try using DBI.
>
> So... what is the consensus on what to use?  DBD::mysql?  or the class
> for DBI?


I am quite sure the consensus is to use DBI.pm.


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


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

Date: Fri, 23 Feb 2007 05:42:08 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Feb 23 2007
Message-Id: <JDwII8.1GIo@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Acme-Lambda-0.01
http://search.cpan.org/~nelhage/Acme-Lambda-0.01/
Perl with lambdas!
----
Astro-SIMBAD-Client-0.004
http://search.cpan.org/~wyant/Astro-SIMBAD-Client-0.004/
Fetch astronomical data from SIMBAD 4.
----
Bio-Das-Lite-1.48
http://search.cpan.org/~rpettett/Bio-Das-Lite-1.48/
Perl extension for the DAS (HTTP+XML) Protocol (http://biodas.org/)
----
Blikistan-0.01
http://search.cpan.org/~lukec/Blikistan-0.01/
Create a blog from content in a wiki
----
Catalyst-Plugin-FormValidator-Simple-Auto-0.12
http://search.cpan.org/~typester/Catalyst-Plugin-FormValidator-Simple-Auto-0.12/
Smart validation with FormValidator::Simple
----
Class-Trigger-0.10_01
http://search.cpan.org/~miyagawa/Class-Trigger-0.10_01/
Mixin to add / call inheritable triggers
----
Config-Any-0.06
http://search.cpan.org/~rataxis/Config-Any-0.06/
Load configuration from different file formats, transparently
----
Crypt-Rijndael-1.03
http://search.cpan.org/~bdfoy/Crypt-Rijndael-1.03/
Crypt::CBC compliant Rijndael encryption module
----
Data-Phrasebook-0.27
http://search.cpan.org/~barbie/Data-Phrasebook-0.27/
Abstract your queries!
----
Data-Phrasebook-Loader-DBI-0.09
http://search.cpan.org/~barbie/Data-Phrasebook-Loader-DBI-0.09/
Absract your phrases with a DBI driver.
----
Data-Phrasebook-Loader-DBI-0.10
http://search.cpan.org/~barbie/Data-Phrasebook-Loader-DBI-0.10/
Absract your phrases with a DBI driver.
----
Data-Phrasebook-Loader-Ini-0.09
http://search.cpan.org/~barbie/Data-Phrasebook-Loader-Ini-0.09/
Absract your phrases with ini files.
----
Data-Phrasebook-Loader-XML-0.11
http://search.cpan.org/~barbie/Data-Phrasebook-Loader-XML-0.11/
Absract your phrases with XML.
----
Data-Phrasebook-Loader-YAML-0.07
http://search.cpan.org/~barbie/Data-Phrasebook-Loader-YAML-0.07/
Absract your phrases with YAML.
----
Data-Phrasebook-Loader-YAML-0.08
http://search.cpan.org/~barbie/Data-Phrasebook-Loader-YAML-0.08/
Absract your phrases with YAML.
----
Date-Holidays-0.10
http://search.cpan.org/~jonasbn/Date-Holidays-0.10/
a Date::Holidays::* OOP Adapter aggregator
----
Email-LocalDelivery-0.214
http://search.cpan.org/~rjbs/Email-LocalDelivery-0.214/
Deliver a piece of email - simply
----
Finance-YahooQuote-0.22
http://search.cpan.org/~edd/Finance-YahooQuote-0.22/
Get stock quotes from Yahoo! Finance
----
Games-Bowling-Scorecard-0.101
http://search.cpan.org/~rjbs/Games-Bowling-Scorecard-0.101/
score your bowling game easily
----
Games-Maze-1.03
http://search.cpan.org/~jgamble/Games-Maze-1.03/
Create Mazes as Objects.
----
Games-Tournament-Swiss-0.03
http://search.cpan.org/~drbean/Games-Tournament-Swiss-0.03/
FIDE Swiss Same-Rank Contestant Pairing
----
Google-Data-JSON-v0.0.2
http://search.cpan.org/~takeru/Google-Data-JSON-v0.0.2/
XML-JSON converter based on Google Data APIs
----
HTML-Copy-1.12
http://search.cpan.org/~tkurita/HTML-Copy-1.12/
copy a HTML file without breaking links.
----
HTML-Template-Associate-FormField-0.10
http://search.cpan.org/~lushe/HTML-Template-Associate-FormField-0.10/
----
HTML-Template-Ex-0.05
http://search.cpan.org/~lushe/HTML-Template-Ex-0.05/
The Perl code is operated in the template for HTML::Template.
----
HTML-Template-Ex-0.06
http://search.cpan.org/~lushe/HTML-Template-Ex-0.06/
The Perl code is operated in the template for HTML::Template.
----
HTML-WikiConverter-XWiki-0.01
http://search.cpan.org/~packi/HTML-WikiConverter-XWiki-0.01/
Convert HTML to XWiki markup
----
HTTP-BrowserDetect-0.99
http://search.cpan.org/~walsham/HTTP-BrowserDetect-0.99/
Determine the Web browser, version, and platform from an HTTP user agent string
----
InSilicoSpectro-1.0.8
http://search.cpan.org/~alexmass/InSilicoSpectro-1.0.8/
Open source Perl library for proteomics
----
Math-Polynom-0.07
http://search.cpan.org/~erwan/Math-Polynom-0.07/
Operations on polynomials
----
Module-Release-1.13
http://search.cpan.org/~bdfoy/Module-Release-1.13/
Automate software releases
----
Net-Z3950-ZOOM-1.17
http://search.cpan.org/~mirk/Net-Z3950-ZOOM-1.17/
Perl extension for invoking the ZOOM-C API.
----
POE-Component-AI-MegaHAL-1.06
http://search.cpan.org/~bingos/POE-Component-AI-MegaHAL-1.06/
A non-blocking wrapper around AI::MegaHAL.
----
Pod-InComments-0.9
http://search.cpan.org/~narked/Pod-InComments-0.9/
Perl extension for extracting POD documentation from comments in config file
----
SigFigs-1.05
http://search.cpan.org/~sbeck/SigFigs-1.05/
do math with correct handling of significant figures
----
Sys-Statistics-Linux-0.09_01
http://search.cpan.org/~bloonix/Sys-Statistics-Linux-0.09_01/
Collect linux system statistics.
----
Test-Manifest-1.17
http://search.cpan.org/~bdfoy/Test-Manifest-1.17/
interact with a t/test_manifest file
----
Text-Restructured-0.003023
http://search.cpan.org/~nodine/Text-Restructured-0.003023/
Perl implementation of reStructuredText parser
----
WWW-Monitor-0.123
http://search.cpan.org/~yaron/WWW-Monitor-0.123/
Monitor websites for updates and changes
----
WWW-Monitor-0.124
http://search.cpan.org/~yaron/WWW-Monitor-0.124/
Monitor websites for updates and changes
----
XML-Comma-1.94
http://search.cpan.org/~brianski/XML-Comma-1.94/
A framework for structured document manipulation
----
mocked-0.01
http://search.cpan.org/~lukec/mocked-0.01/
use mocked libraries in unit tests
----
mocked-0.02
http://search.cpan.org/~lukec/mocked-0.02/
use mocked libraries in unit tests
----
parrot-0.4.9
http://search.cpan.org/~pmic/parrot-0.4.9/
----
sapnwrfc-0.03
http://search.cpan.org/~piers/sapnwrfc-0.03/
SAP Netweaver RFC support for Perl
----
vptk_w_2_38b
http://search.cpan.org/~felixl/vptk_w_2_38b/
Perl/Tk Visual resource editor (widget edition)


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 22 Feb 2007 18:08:36 -0800
From: "Shannon Jacobs" <Shannon.Jacobs.nospam@gmail.com>
Subject: Re: Regex: Why is overreaching necessary?
Message-Id: <1172196516.875062.189660@h3g2000cwc.googlegroups.com>

I'm not sure how to take your curiosity, but as I noted, here is a
minimal example of a test case for the latest (but not greatest)
problem.

http://shanenj.tripod.com/cgi-bin/procbook0.cgi?a_SEARCH_VALUE=2471%7C2396&searchfields=authornums&sensecase=nocase&sorttype=none&datetype=comp&numorname=authnums

http://shanenj.tripod.com/cgi-bin/procbook0.cgi?a_SEARCH_VALUE=2396%7C2471&searchfields=authornums&sensecase=nocase&sorttype=none&datetype=comp&numorname=authnums

The first one properly returns exactly two books, and the second one
somehow returns a third book. These two queries came out of a webpage
that uses a fair amount of JavaScript, but I feel like that's not
related to the problem, since as near as I can see, the resulting
queries are identical except that the two numbers are reversed.

For comparison, the following query produces the same three hits as
the second query, but that is the correct result given the code branch
it follows...

http://shanenj.tripod.com/cgi-bin/procbook0.cgi?a_SEARCH_VALUE=2471%7C2396&searchfields=all&sensecase=nocase&sorttype=none&datetype=comp&numorname=authnums

The code where the regex is used has already been posted (and another
tip of the hat to anno4), but I can't really figure out how to snip it
down more than that in line with your suggestion. It is obvious that
something slightly odd is going on. However, I'm pretty sure Perl is
doing exactly what I told it to do, and the problem is that what I
told it is not quite what I wanted...

Obviously my original hypothesis about the leading space is wrong...
(Unless I'm also wrong about it being a single problem. It certainly
could be two...) Right now I'm classifying it as a problem I don't
understand well enough to even ask about, though I will probably have
an opportunity to discuss it with some heavy Perlers at the next Linux
meeting.

On Feb 23, 6:27 am, Jim Gibson <jgib...@mail.arc.nasa.gov> wrote:
> In article <1172125167.083189.135...@k78g2000cwa.googlegroups.com>,
>
> Shannon Jacobs <Shannon.Jacobs.nos...@gmail.com> wrote:
> > Having fixed one problem, my latest testing discovered yet another
> > peculiarity which could easily consume much more time than it's
> > worth... I'm only going to mention it as an example of the peculiarity
> > of my code... I have discovered that using the search target 2471|2396
> > returns different results from the search target 2396|2471. I don't
> > think this can really be Perl's fault. However and fortuitously, every
> > problem that I've discovered (so far) is in the direction of false
> > positives, and that is not very troublesome for this application...
>
> > My current belief is that this newly discovered flaw is somewhere on
> > the HTML side, possibly in my JavaScript. However if I can't find it
> > there, and if it seems to be in the Perl, I may be back. Thanks again.
>
> Can you post an example demonstrating this remarkable discovery?
> Something along the lines of the following:
>
> #!/usr/local/bin/perl
> use strict;
> use warnings;
> my $target1 = '2471|2396';
> my $target2 = '2396|2471';
> while(<DATA>) {
>   chomp;
>   if( /$target1/ ) {
>     print "$_ matches $target1\n";
>   }else{
>     print "$_ doesn't match $target1\n";
>   }
>   if( /$target2/ ) {
>     print "$_ matches $target2\n";
>   }else{
>     print "$_ doesn't match $target2\n";
>   }}
>
> __DATA__
> 2471
> 2396
> 247
> 239
>
> ... which produces...
>
> 2471 matches 2471|2396
> 2471 matches 2396|2471
> 2396 matches 2471|2396
> 2396 matches 2396|2471
> 247 doesn't match 2471|2396
> 247 doesn't match 2396|2471
> 239 doesn't match 2471|2396
> 239 doesn't match 2396|2471
>
> Thanks.
>
>  Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
>                http://www.usenet.com



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

Date: 22 Feb 2007 17:59:08 -0800
From: azzi.george@gmail.com
Subject: Text::CSV and Mysql - invalid number of columns
Message-Id: <1172195948.601530.116650@p10g2000cwp.googlegroups.com>

Dear Perl and MySQL/Perl Gurus,

Good evening. Am having a problem loading data from a CSV file into a
test database. Below should be all of the information to duplicate my
error. Please let me know what I am doing wrong! Thanks, and await for
your resolution to my overly simple problem.

Pierre


PERL SCRIPT
---------------------------------------------------------------------------
#!/usr/local/bin/perl

use strict;
use warnings;

use Text::CSV;
use IO::File;
use Data::Dumper;
use DBI;

#========
# Globals
#========
my $csv = Text::CSV->new;

my $db_host = "x.x.x.x";
my $db_name = "test_db";
my $db_user = "user";
my $db_pass = "";
my $dbh = DBI->connect("dbi:mysql:$db_name:$db_host","$db_user");
                        ; #or die "Cannot connect to the Mysql
database $db_name: $DBI:errstr\n";

my $sql_start = "INSERT INTO Start VALUES (?);";
my $sql_stop = "INSERT INTO Stop VALUES (?);";
my $sql_attempt = "INSERT INTO Attempt VALUES (?);";

my $sth_attempt = $dbh->prepare($sql_attempt);
my $sth_stop = $dbh->prepare($sql_stop);
my $sth_start = $dbh->prepare($sql_start);

my $fh = new IO::File "<file_csv.txt";

#===================
# Loads file into DB
#===================
while (<$fh>) {

my $line = $_;
my $stts = $csv->parse($_);
my @data = Dumper([$csv->fields()]);


if ($line =~ /^START/) {
  #$sth_start->execute(Dumper([$csv->fields()]));
  $sth_start->execute(@data);
}

elsif ($line =~ /^STOP/) {
  #$sth_stop->execute(Dumper([$csv->fields()]));
  #$sth_stop->execute(Dumper(@data));
}
elsif ($line =~ /^ATTEMPT/) {
  #$sth_attempt->execute(Dumper([$csv->fields()]));
  #$sth_attempt->execute(Dumper(@data));
}

} #end of while loop



FILE CONTENTS BEING IMPORTED
----------------------------------------------------------
START,intent,jobs.,"testing,,can..this,be,a,fieldbyitself,",testing,end,
0,
START,tent,job,"can..this,be,a,field-by-itself,",testing,end,0,1
STOP,,tent,,,job,"can..this,be,a,field-by-itself,",,0,1



MySQL Database Structure
-------------------------------------------------------------------------------

mysql> desc Start;
+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| field1 | varchar(50) | YES  |     | NULL    |       |
| field2 | varchar(50) | YES  |     | NULL    |       |
| field3 | varchar(50) | YES  |     | NULL    |       |
| field4 | varchar(50) | YES  |     | NULL    |       |
| field5 | varchar(50) | YES  |     | NULL    |       |
| field6 | varchar(50) | YES  |     | NULL    |       |
| field7 | varchar(50) | YES  |     | NULL    |       |
| field8 | varchar(50) | YES  |     | NULL    |       |
+--------+-------------+------+-----+---------+-------+


mysql> desc Stop;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| field1  | varchar(50) | YES  |     | NULL    |       |
| field2  | varchar(50) | YES  |     | NULL    |       |
| field3  | varchar(50) | YES  |     | NULL    |       |
| field4  | varchar(50) | YES  |     | NULL    |       |
| field5  | varchar(50) | YES  |     | NULL    |       |
| field6  | varchar(50) | YES  |     | NULL    |       |
| field7  | varchar(50) | YES  |     | NULL    |       |
| field8  | varchar(50) | YES  |     | NULL    |       |
| field9  | varchar(50) | YES  |     | NULL    |       |
| field10 | varchar(50) | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+



PERL ERROR
----------------------------------------------------------------------------
DBD::mysql::st execute failed: Column count doesn't match value count
at row 1 at ./dbi_file.pl line 45, <GEN0> line 1.
DBD::mysql::st execute failed: Column count doesn't match value count
at row 1 at ./dbi_file.pl line 45, <GEN0> line 2.



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

Date: Fri, 23 Feb 2007 04:13:21 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Text::CSV and Mysql - invalid number of columns
Message-Id: <Xns98DFEC3927B2asu1cornelledu@127.0.0.1>

azzi.george@gmail.com wrote in
news:1172195948.601530.116650@p10g2000cwp.googlegroups.com: 

> Dear Perl and MySQL/Perl Gurus,

This is a Perl group.

 ...

> my $sql_start = "INSERT INTO Start VALUES (?);";
> my $sql_stop = "INSERT INTO Stop VALUES (?);";
> my $sql_attempt = "INSERT INTO Attempt VALUES (?);";

All these statements have exactly one placeholder. That is, you are 
promising to insert one value for each row.

> my $sth_attempt = $dbh->prepare($sql_attempt);
> my $sth_stop = $dbh->prepare($sql_stop);
> my $sth_start = $dbh->prepare($sql_start);

You don't like error checking?

> my $fh = new IO::File "<file_csv.txt";

open my $fh, '<', 'file_csv.txt'
   or die "Cannot open 'file_csv.txt': $!";


> if ($line =~ /^START/) {
>   #$sth_start->execute(Dumper([$csv->fields()]));
>   $sth_start->execute(@data);
> }

Don't include commented out sections in posted code.

You are trying to insert more than one value when you promised to insert 
only one value.

> PERL ERROR
> ----------------------------------------------------------------------
-
> ----- DBD::mysql::st execute failed: Column count doesn't match value
> count at row 1 at ./dbi_file.pl line 45, <GEN0> line 1.
> DBD::mysql::st execute failed: Column count doesn't match value count
> at row 1 at ./dbi_file.pl line 45, <GEN0> line 2.
> 

And you are being told exactly what you did.

Sinan


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

Date: Fri, 23 Feb 2007 05:46:13 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Text::CSV and Mysql - invalid number of columns
Message-Id: <FcvDh.5491$tD2.4780@newsread1.news.pas.earthlink.net>

On 02/22/2007 07:59 PM, azzi.george@gmail.com wrote:
> Dear Perl and MySQL/Perl Gurus,
> 
> Good evening. Am having a problem loading data from a CSV file into a
> test database. [...]
> 
> my $sql_start = "INSERT INTO Start VALUES (?);";

You need as many question marks as you have values to insert. If you 
have three values to insert, you need three question marks:

 ... VALUES (?, ?, ?);


HTH


> [...]
> DBD::mysql::st execute failed: Column count doesn't match value count
> at row 1 at ./dbi_file.pl line 45, <GEN0> line 1.
> [...]


-- 
Windows Vista and your freedom in conflict:
http://www.regdeveloper.co.uk/2006/10/29/microsoft_vista_eula_analysis/


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

Date: Fri, 23 Feb 2007 01:05:08 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: ucfirst() with "_" separator
Message-Id: <erleqr.1hg.1@news.isolution.nl>

Michele Dondi schreef:

>    s|(?<=\s)(\w+)(?=\s)|join '_', map ucfirst, split /_/, lc $1|e;


Shorter:

     s|(?<=\s)(\w+)|join '_', map ucfirst, split /_/, lc $1|e;

     s|(?<= )(\w+)|join _=>map ucfirst,split _=>lc$1|e;

Alternative approach:

     local $";
     s|(?<=\s)(\w+)|@{[map ucfirst, split /(_)/, lc $1]}|; 

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Fri, 23 Feb 2007 04:53:49 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: ucfirst() with "_" separator
Message-Id: <erloqd$lds$1@ns.felk.cvut.cz>

"gors" <gors@invalid.no1> píse v diskusním príspevku 
news:erio4r$f5f$1@aioe.org...
> We have big file has lines as:
>
> ITEM1 PRODUCT PRICE 3.47
> ITEM2 PRODUCT_DETAILS PRICE 4.47
> ITEM3 PRODUCT_DETAILS_AGAIN PRICE 5.47
>
> Trouble is make 2nd word each line capital letter first, then lower case 
> for
> every "_". Some 2nd word have "_" one or more time, other not. So we like
> make line each lokk like:
>
> ITEM1 Product PRICE 3.47
> ITEM2 Product_Details PRICE 4.47
> ITEM3 Product_Details_Again PRICE 5.47
>

What this?

$t = 'ITEM1 Product PRICE 3.47';
$t =~ s/_([^_\s]+)/'_' . ucfirst(lc($1))/eg;
$t =~ s/\s(\w+)\s/ ucfirst($2) /eg;

-- 

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail 
from another non-spammer site please.)





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

Date: Fri, 23 Feb 2007 16:19:36 +1100
From: "Sisyphus" <sisyphus1@nomail.afraid.com>
Subject: Re: Unable to install Math::BigInt::GMP on Solaris 10
Message-Id: <45de796d$0$5745$afc38c87@news.optusnet.com.au>


<sumitbee@gmail.com> wrote in message 
news:1172178117.033755.326430@s48g2000cws.googlegroups.com...
 .
 .
>
> JP, thanks for the update.  I installed gmp-4.1.2, changed the
> LD_LIBRARY_PATH_64 and made sure the libgmp files were in /usr/local/
> lib/sparcv9, but same problem.....
>

Try hacking at the XS file. Where it says:

#include "gmp.h"

Change that to:

#include "/usr/local/include/sparcv9/gmp.h" // if that's where gmp.h is 
located

That should at least allow gmp.h to get found. Then it's just a matter of 
making libgmp.a (or the gmp .so) findable.

Probably the simplest way to build it is to do it manually. Download the 
M:::BI::GMP-1.19 source from CPAN, extract to some location, cd to that 
location and run:

perl Makefile.PL INC="-I/usr/local/include/sparcv9" 
LIBS="-L/usr/local/lib/sparcv9 -lgmp"
make test
make install

If you don't have a  'libgmp.a' then you should be able to link directly to 
the libgmp-3.so (or whatever it's called) but you would need to change the 
above command to properly reflect the name of the gmp .so file. Something 
like:

perl Makefile.PL INC="-I/usr/local/include/sparcv9" 
LIBS="-L/usr/local/lib/sparcv9 -lgmp-3"

All of this is, of course, untested.

Is there something there that works for you ? (You should at least be able 
to eradicate the error about gmp.h being not found - assuming it really is 
in /usr/local/include/sparcv9.)

Cheers,
Rob 




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

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


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