[31578] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2837 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 26 18:09:23 2010

Date: Fri, 26 Feb 2010 15:09:06 -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, 26 Feb 2010     Volume: 11 Number: 2837

Today's topics:
        FEAR::API <sopan.shewale@gmail.com>
    Re: FEAR::API <thepoet_nospam@arcor.de>
        Help with Hashs/Arrays and XML::Simple <helius@gmail.com>
    Re: Help with Hashs/Arrays and XML::Simple <jurgenex@hotmail.com>
    Re: Help with Hashs/Arrays and XML::Simple <helius@gmail.com>
    Re: OT, blowing off steam <cartercc@gmail.com>
    Re: OT, blowing off steam <sreservoir@gmail.com>
        Requesting regular expression help <dgnuff@gmail.com>
        Unable to run sample code from DBD::DBM on Strawberry P <jl_post@hotmail.com>
    Re: Unable to run sample code from DBD::DBM on Strawber <smallpond@juno.com>
    Re: Unable to run sample code from DBD::DBM on Strawber sln@netherlands.com
    Re: Unable to run sample code from DBD::DBM on Strawber <jl_post@hotmail.com>
    Re: Unable to run sample code from DBD::DBM on Strawber <smallpond@juno.com>
    Re: Would like some words of wisdom - convert text file <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 26 Feb 2010 08:29:44 -0800 (PST)
From: "sopan.shewale@gmail.com" <sopan.shewale@gmail.com>
Subject: FEAR::API
Message-Id: <293e446f-9041-40e4-86c8-7b96102f0747@s25g2000prd.googlegroups.com>

Does any one know abotu FEAR::API? i saw nice article at
http://www.perl.com/lpt/a/980 but the module does not exist in CPAN.

Tried searching on google -but did not get hold of the  code.




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

Date: Fri, 26 Feb 2010 18:58:59 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: FEAR::API
Message-Id: <4b880be5$0$6584$9b4e6d93@newsspool3.arcor-online.net>

sopan.shewale@gmail.com schrieb:
> Does any one know abotu FEAR::API? i saw nice article at
> http://www.perl.com/lpt/a/980 but the module does not exist in CPAN.
> 
> Tried searching on google -but did not get hold of the  code.

Looks like it has been removed from CPAN, but from the looks of
it, the "Scrapar" dist might be its successor.

-Chris


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

Date: Fri, 26 Feb 2010 09:27:28 -0800 (PST)
From: Jasper2000 <helius@gmail.com>
Subject: Help with Hashs/Arrays and XML::Simple
Message-Id: <2f1fb7db-0a09-46d3-b349-c25bcd1c44cb@v25g2000yqk.googlegroups.com>

Hi,

I'm trying to write a little script that does a query and which
returns XML data. That part is fine, and I thought I'd be okay with
XML::Simple, since I used it a day or two ago, with XML returned from
a different service, and I seemed to understand it fine, and it was
working. However, the XML in this new script is a bit more complex,
and I don't seem to be able to get it working.

Here is the top snippet and first complete "Item" from the XML file:

<SearchSuggestion version="2.0">
<Query xml:space="preserve">Clothes</Query>
<Section>
<Item>
<Text xml:space="preserve">Clothing</Text>
<Description xml:space="preserve">A feature of all modern human
societies....</Description>
<Url xml:space="preserve">http://someurl....</Url>
<Image source="http://someimageurl" width="50" height="33"/>
</Item>
<Item>
<Text xml:space="preserve">Clothes dryer</Text>
<Description xml:space="preserve">
 ...
 ...

My snippet of Perl script looks like this:

my $xml = new XML::Simple;			# create object

my $data = $xml->XMLin("data.xml");

foreach my $record (@{$data->{Section}->{Item}})
{
print $record->{Text}, "<br />";
}


My output, however, looks like this:

HASH(0x1e35128)<br />HASH(0x1e35374)<br />HASH(0x1e35584)<br /
HASH(0x1e35788)
<br />HASH(0x1e4cfe0)<br />HASH(0x1e4d1e4)<br />HASH(0x1e4d3e8)<br />
HASH(0x1e4d5ec)<br />HASH(0x1e4d748)<br />HASH(0x1e4d8ec)<br />

I've tried various arrangements with the loop, but always seem to end
up with either nothing or something similar to the above.

Any help which can be provided would be most appreciated!

Thanks!




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

Date: Fri, 26 Feb 2010 09:39:35 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Help with Hashs/Arrays and XML::Simple
Message-Id: <je1go5dhlq9p05ns527d4ob5i399002f3a@4ax.com>

Jasper2000 <helius@gmail.com> wrote:
>Here is the top snippet and first complete "Item" from the XML file:
[...]
><Text xml:space="preserve">Clothes dryer</Text>
[...]
>print $record->{Text}, "<br />";

>My output, however, looks like this:
>
>HASH(0x1e35128)<br />HASH(0x1e35374)<br />HASH(0x1e35584)<br /

Obviously $record->{Text} is a reference, in this case a reference to
HASH(0x1e35128). And this is very reasonable because the <Text> tag has
an attribute as well as a body. So you will need to dereference that
hash reference in order to get to its components.

To find out how the keys are named you could 
- check the doc of XML::Simple (hopefully it is described there)
- print the keys of that hash
- use Data::Dumper do print that whole hash

jue


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

Date: Fri, 26 Feb 2010 09:50:09 -0800 (PST)
From: Jasper2000 <helius@gmail.com>
Subject: Re: Help with Hashs/Arrays and XML::Simple
Message-Id: <31141ac2-0af9-49ca-be2e-68db0b5d3246@g11g2000yqe.googlegroups.com>

> >My output, however, looks like this:
>
> >HASH(0x1e35128)<br />HASH(0x1e35374)<br />HASH(0x1e35584)<br /
>
> Obviously $record->{Text} is a reference, in this case a reference to
> HASH(0x1e35128). And this is very reasonable because the <Text> tag has
> an attribute as well as a body. So you will need to dereference that
> hash reference in order to get to its components.
>
> To find out how the keys are named you could
> - check the doc of XML::Simple (hopefully it is described there)
> - print the keys of that hash
> - use Data::Dumper do print that whole hash
>
> jue


Yeah, okay ... I understand what you're saying, and will try and
figure out how the attributes are being stored ... In fact, just as a
test, I deleted all the attribute tags and tested it, and it worked
fine, so, as you pointed out, it obviously is to do with that. Thanks
for the help!



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

Date: Fri, 26 Feb 2010 09:29:42 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: OT, blowing off steam
Message-Id: <a9edd4b1-12ce-4dfa-9d2e-7279ada4d2ef@a18g2000yqc.googlegroups.com>

On Feb 25, 3:33=A0pm, Keith Thompson <ks...@mib.org> wrote:
> ^@ is the null character, not form feed.

Typing control-k, LF in vim inserts ^@. Typing control-k, NU inserts
^U.

Look at the symbols using the :digraphs command.

CC.


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

Date: Fri, 26 Feb 2010 13:54:44 -0500
From: sreservoir <sreservoir@gmail.com>
Subject: Re: OT, blowing off steam
Message-Id: <hm95e0$ns5$1@speranza.aioe.org>

On 2/26/2010 12:29 PM, ccc31807 wrote:
> On Feb 25, 3:33 pm, Keith Thompson<ks...@mib.org>  wrote:
>> ^@ is the null character, not form feed.
>
> Typing control-k, LF in vim inserts ^@. Typing control-k, NU inserts
> ^U.
>
> Look at the symbols using the :digraphs command.

NU ^@

?

-- 

   "Six by nine. Forty two."
   "That's it. That's all there is."
   "I always thought something was fundamentally wrong with the universe"


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

Date: Fri, 26 Feb 2010 14:39:49 -0800 (PST)
From: David G <dgnuff@gmail.com>
Subject: Requesting regular expression help
Message-Id: <86109fe4-3e34-4a48-ae98-18c4c84633a6@t9g2000prh.googlegroups.com>

I'm not any kind or perl expert, but have still managed to inherit a
number of perl scripts in a project.  The original author is long
gone, and we don't have any perl expertise in house.

The problem is that one of the scripts reads in a text file, and
performs a translation operation on strings it finds enclosed in
double quotes.  The perl in question is as follows:

{
	open(INPUT, "$infile") or die "Can't open $infile: $!\n";
	local $/ = undef;
	$inputText = <INPUT>;
	close(INPUT);
}

$inputText =~ s/"([^"]*)"/Translate(*TRANS, $1, "Generic String")/ieg;

OpenMakeDir(*OUTPUT, "$outfile") or die "Can't write $outfile \n";
print OUTPUT $inputText;
close(OUTPUT);

As far as I can tell, the entire operation is done in one go by the
line that starts "$input =~ ..."

The problem is that we need to have the operation not be performed if
the quoted string is itself enclosed in double angle brackets.

"This string is translated"
<<..."This string isn't"...>>

shows what is needed.  If it makes any difference, angle bracket
enclosed sequences will never cross a line boundary.

For what it's worth I got the job because I'd mentioned that I do know
awk reasonably well.  Ironically, this would be trivial for me to
craft in awk, but that doesn't help here.

So, is there any way to get the behavior we want?  If it means
processing each line of the file in isolation, I'm 100% on board with
that, I just need to find a working solution.

TIA
     David G.


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

Date: Fri, 26 Feb 2010 09:12:23 -0800 (PST)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Unable to run sample code from DBD::DBM on Strawberry Perl
Message-Id: <502cdf9b-6e60-454f-8b6b-bed594ca19bd@c34g2000pri.googlegroups.com>

Dear Perl community,

   Recently I installed DBD::DBM on my platform (Strawberry Perl on
Windows Vista).  However, when I type "del user*" and run the
following program (that I found in "perldoc DBD::DBM):

use DBI;
my $dbh = DBI->connect('dbi:DBM:');
$dbh->{RaiseError} = 1;
for my $sql( split /;\n+/,"
    CREATE TABLE user ( user_name TEXT, phone TEXT );
    INSERT INTO user VALUES ('Fred Bloggs','233-7777');
    INSERT INTO user VALUES ('Sanjay Patel','777-3333');
    INSERT INTO user VALUES ('Junk','xxx-xxxx');
    DELETE FROM user WHERE user_name = 'Junk';
    UPDATE user SET phone = '999-4444' WHERE user_name = 'Sanjay
Patel';
    SELECT * FROM user
"){
    my $sth = $dbh->prepare($sql);
    $sth->execute;
    $sth->dump_results if $sth->{NUM_OF_FIELDS};
}
$dbh->disconnect;

I see:

Execution ERROR: Table 'user' already exists..
DBD::DBM::st execute failed:
Execution ERROR: Table 'user' already exists..
 [for Statement "
    CREATE TABLE user ( user_name TEXT, phone TEXT )"] at dbi_dbm.pl
line 14.
DBD::DBM::st execute failed:
Execution ERROR: Table 'user' already exists..
 [for Statement "
    CREATE TABLE user ( user_name TEXT, phone TEXT )"] at dbi_dbm.pl
line 14.

and I see three new zero-length files named "user.lck", "user.pag",
and "user.dir".

I decided to rerun the script (after "del user*") with the "$dbh-
>{RaiseError} = 1;" line commented out, and I still get error
messages:

Execution ERROR: Cannot CREATE 'user.pag' because it already exists at
C:/strawb
erry/perl/site/lib/DBD/DBM.pm line 338.
DBD::DBM::st execute failed: Can't call method "column" on an
undefined value at
 C:/strawberry/perl/site/lib/SQL/Statement/Term.pm line 190.
 [for Statement "    DELETE FROM user WHERE user_name = 'Junk'"] at
dbi_dbm.pl line 14.
Execution ERROR: Column 'phone' not known in any table called from C:/
strawberry
/perl/site/lib/DBD/File.pm at 446.
Execution ERROR:
Execution ERROR: Column 'phone' not known in any table called from C:/
strawberry/perl/site/lib/DBD/File.pm at 446.
 called from dbi_dbm.pl at 14.
Execution ERROR:
Execution ERROR:
Execution ERROR: Column 'phone' not known in any table called from C:/
strawberry/perl/site/lib/DBD/File.pm at 446.
 called from dbi_dbm.pl at 14.
undef, undef
undef, undef
undef, undef
3 rows

This time, the "user.pag" file has 1,024 bytes in it, and when I view
it in a hex editor, I see that it ends with this text:  xxx-
xxxxJunk777-3333Sanjay Patel233-7777Fred Bloggs

   So it looks like the "INSERT INTO" commands worked, but the
"UPDATE" and "SELECT" commands didn't work.

   (For the record, I am deleting the user* files before I run the
script.)

   I tried running this script on a Linux platform, and it worked fine
(with no errors).  I'm only getting this error running this script on
my Windows platform (Strawberry Perl 5.10 on Windows Vista), and so
I'm wondering if anyone else on a similar platform is seeing the same
error I'm seeing.

   For anyone who wants it, here are the first two lines of "perl -v":

>perl -v
This is perl, v5.10.0 built for MSWin32-x86-multi-thread
Copyright 1987-2007, Larry Wall

   Is anyone else having trouble using DBD::DBM ?

   Thanks.

   -- Jean-Luc


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

Date: Fri, 26 Feb 2010 13:25:02 -0500
From: Steve C <smallpond@juno.com>
Subject: Re: Unable to run sample code from DBD::DBM on Strawberry Perl
Message-Id: <hm93mc$ph8$1@news.eternal-september.org>

jl_post@hotmail.com wrote:
> Dear Perl community,
> 
>    Recently I installed DBD::DBM on my platform (Strawberry Perl on
> Windows Vista).  However, when I type "del user*" and run the
> following program (that I found in "perldoc DBD::DBM):
> 
> use DBI;
> my $dbh = DBI->connect('dbi:DBM:');
> $dbh->{RaiseError} = 1;
> for my $sql( split /;\n+/,"
>     CREATE TABLE user ( user_name TEXT, phone TEXT );
>     INSERT INTO user VALUES ('Fred Bloggs','233-7777');
>     INSERT INTO user VALUES ('Sanjay Patel','777-3333');
>     INSERT INTO user VALUES ('Junk','xxx-xxxx');
>     DELETE FROM user WHERE user_name = 'Junk';
>     UPDATE user SET phone = '999-4444' WHERE user_name = 'Sanjay
> Patel';
>     SELECT * FROM user
> "){
>     my $sth = $dbh->prepare($sql);
>     $sth->execute;
>     $sth->dump_results if $sth->{NUM_OF_FIELDS};
> }
> $dbh->disconnect;
> 
> I see:
> 
> Execution ERROR: Table 'user' already exists..
> DBD::DBM::st execute failed:
> Execution ERROR: Table 'user' already exists..
>  [for Statement "
>     CREATE TABLE user ( user_name TEXT, phone TEXT )"] at dbi_dbm.pl
> line 14.
> DBD::DBM::st execute failed:
> Execution ERROR: Table 'user' already exists..
>  [for Statement "
>     CREATE TABLE user ( user_name TEXT, phone TEXT )"] at dbi_dbm.pl
> line 14.
> 
> and I see three new zero-length files named "user.lck", "user.pag",
> and "user.dir".

These are not perl errors, they are errors in your understanding of how a
database works.  You can't create a new table if a table already exists with
that name.  If you don't want the old one, you need to DROP it first.


> 
> I decided to rerun the script (after "del user*") with the "$dbh-
>> {RaiseError} = 1;" line commented out, and I still get error
> messages:
> 
> Execution ERROR: Cannot CREATE 'user.pag' because it already exists at
> C:/strawb
> erry/perl/site/lib/DBD/DBM.pm line 338.
> DBD::DBM::st execute failed: Can't call method "column" on an
> undefined value at
>  C:/strawberry/perl/site/lib/SQL/Statement/Term.pm line 190.
>  [for Statement "    DELETE FROM user WHERE user_name = 'Junk'"] at
> dbi_dbm.pl line 14.
> Execution ERROR: Column 'phone' not known in any table called from C:/
> strawberry
> /perl/site/lib/DBD/File.pm at 446.
> Execution ERROR:
> Execution ERROR: Column 'phone' not known in any table called from C:/
> strawberry/perl/site/lib/DBD/File.pm at 446.
>  called from dbi_dbm.pl at 14.
> Execution ERROR:
> Execution ERROR:
> Execution ERROR: Column 'phone' not known in any table called from C:/
> strawberry/perl/site/lib/DBD/File.pm at 446.
>  called from dbi_dbm.pl at 14.
> undef, undef
> undef, undef
> undef, undef
> 3 rows
> 
> This time, the "user.pag" file has 1,024 bytes in it, and when I view
> it in a hex editor, I see that it ends with this text:  xxx-
> xxxxJunk777-3333Sanjay Patel233-7777Fred Bloggs
> 
>    So it looks like the "INSERT INTO" commands worked, but the
> "UPDATE" and "SELECT" commands didn't work.
> 
>    (For the record, I am deleting the user* files before I run the
> script.)


Why do you think deleting the files is the right thing to do?
If you want to use a database, learn how first. Don't just guess.


> 
>    I tried running this script on a Linux platform, and it worked fine
> (with no errors).  I'm only getting this error running this script on
> my Windows platform (Strawberry Perl 5.10 on Windows Vista), and so
> I'm wondering if anyone else on a similar platform is seeing the same
> error I'm seeing.
> 
>    For anyone who wants it, here are the first two lines of "perl -v":
> 
>> perl -v
> This is perl, v5.10.0 built for MSWin32-x86-multi-thread
> Copyright 1987-2007, Larry Wall
> 
>    Is anyone else having trouble using DBD::DBM ?
> 
>    Thanks.
> 
>    -- Jean-Luc


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

Date: Fri, 26 Feb 2010 10:36:54 -0800
From: sln@netherlands.com
Subject: Re: Unable to run sample code from DBD::DBM on Strawberry Perl
Message-Id: <6q3go51hividb0ghnc21g9hu2rl61glr5g@4ax.com>

On Fri, 26 Feb 2010 09:12:23 -0800 (PST), "jl_post@hotmail.com" <jl_post@hotmail.com> wrote:

>Dear Perl community,
>
>   Recently I installed DBD::DBM on my platform (Strawberry Perl on
>Windows Vista).  However, when I type "del user*" and run the
>following program (that I found in "perldoc DBD::DBM):
>
[snip]
>   I tried running this script on a Linux platform, and it worked fine
>(with no errors).  I'm only getting this error running this script on
>my Windows platform (Strawberry Perl 5.10 on Windows Vista), and so
>I'm wondering if anyone else on a similar platform is seeing the same
>error I'm seeing.
>
>   For anyone who wants it, here are the first two lines of "perl -v":
>
>>perl -v
>This is perl, v5.10.0 built for MSWin32-x86-multi-thread
>Copyright 1987-2007, Larry Wall
>
>   Is anyone else having trouble using DBD::DBM ?
>
>   Thanks.
>
>   -- Jean-Luc

I suspect its either a version problem, bundle problem,
Perl distribution problem, etc..

It works as expected on my AS Perl 5.10.0, XP os.
Below is run info, as well as info from installed
packages -DBI, from ppm (graphic interface).

-sln
-------------------------
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\temp>perl kk.pl
'Fred Bloggs', '233-7777'
'Sanjay Patel', '777-3333'
2 rows

c:\temp>perl kk.pl

Execution ERROR: Cannot CREATE '.\user.pag' because it already exists at C:/Perl
/lib/DBD/DBM.pm line 338.
 .

DBD::DBM::st execute failed:
Execution ERROR: Cannot CREATE '.\user.pag' because it already exists at C:/Perl
/lib/DBD/DBM.pm line 338.
 .

 [for Statement "
    CREATE TABLE user ( user_name TEXT, phone TEXT )"] at kk.pl line 15.
DBD::DBM::st execute failed:
Execution ERROR: Cannot CREATE '.\user.pag' because it already exists at C:/Perl
/lib/DBD/DBM.pm line 338.
 .

 [for Statement "
    CREATE TABLE user ( user_name TEXT, phone TEXT )"] at kk.pl line 15.

c:\temp>del user*

c:\temp>perl kk.pl
'Fred Bloggs', '233-7777'
'Sanjay Patel', '777-3333'
2 rows

c:\temp>del user*

c:\temp>perl kk.pl
'Fred Bloggs', '233-7777'
'Sanjay Patel', '777-3333'
2 rows

c:\temp>

-----------------------------------------
DBI
Database independent interface for Perl
	Version:	1.607
	Released:	2008-07-30
	Author:	Tim Bunce <dbi-users@perl.org>
	CPAN:	http://search.cpan.org/dist/DBI-1.607/

Installed files:
	C:/Perl/bin/dbilogstrip
	C:/Perl/bin/dbilogstrip.bat
	C:/Perl/bin/dbiprof
	C:/Perl/bin/dbiprof.bat
	C:/Perl/bin/dbiproxy
	C:/Perl/bin/dbiproxy.bat
	C:/Perl/lib/Bundle/DBI.pm
	C:/Perl/lib/DBD/DBM.pm
	C:/Perl/lib/DBD/ExampleP.pm
	C:/Perl/lib/DBD/File.pm
	C:/Perl/lib/DBD/Gofer.pm
	C:/Perl/lib/DBD/Gofer/Policy/Base.pm
	C:/Perl/lib/DBD/Gofer/Policy/classic.pm
	C:/Perl/lib/DBD/Gofer/Policy/pedantic.pm
	C:/Perl/lib/DBD/Gofer/Policy/rush.pm
	C:/Perl/lib/DBD/Gofer/Transport/Base.pm
	C:/Perl/lib/DBD/Gofer/Transport/null.pm
	C:/Perl/lib/DBD/Gofer/Transport/pipeone.pm
	C:/Perl/lib/DBD/Gofer/Transport/stream.pm
	C:/Perl/lib/DBD/NullP.pm
	C:/Perl/lib/DBD/Proxy.pm
	C:/Perl/lib/DBD/Sponge.pm
	C:/Perl/lib/DBI.pm
	C:/Perl/lib/DBI/Changes.pm
	C:/Perl/lib/DBI/Const/GetInfo/ANSI.pm
	C:/Perl/lib/DBI/Const/GetInfo/ODBC.pm
	C:/Perl/lib/DBI/Const/GetInfoReturn.pm
	C:/Perl/lib/DBI/Const/GetInfoType.pm
	C:/Perl/lib/DBI/DBD.pm
	C:/Perl/lib/DBI/DBD/Metadata.pm
	C:/Perl/lib/DBI/FAQ.pm
	C:/Perl/lib/DBI/Gofer/Execute.pm
	C:/Perl/lib/DBI/Gofer/Request.pm
	C:/Perl/lib/DBI/Gofer/Response.pm
	C:/Perl/lib/DBI/Gofer/Serializer/Base.pm
	C:/Perl/lib/DBI/Gofer/Serializer/DataDumper.pm
	C:/Perl/lib/DBI/Gofer/Serializer/Storable.pm
	C:/Perl/lib/DBI/Gofer/Transport/Base.pm
	C:/Perl/lib/DBI/Gofer/Transport/pipeone.pm
	C:/Perl/lib/DBI/Gofer/Transport/stream.pm
	C:/Perl/lib/DBI/Profile.pm
	C:/Perl/lib/DBI/ProfileData.pm
	C:/Perl/lib/DBI/ProfileDumper.pm
	C:/Perl/lib/DBI/ProfileDumper/Apache.pm
	C:/Perl/lib/DBI/ProfileSubs.pm
	C:/Perl/lib/DBI/ProxyServer.pm
	C:/Perl/lib/DBI/PurePerl.pm
	C:/Perl/lib/DBI/Roadmap.pm
	C:/Perl/lib/DBI/SQL/Nano.pm
	C:/Perl/lib/DBI/Util/CacheMemory.pm
	C:/Perl/lib/DBI/Util/_accessor.pm
	C:/Perl/lib/DBI/W32ODBC.pm
	C:/Perl/lib/Roadmap.pod
	C:/Perl/lib/TASKS.pod
	C:/Perl/lib/Win32/DBIODBC.pm
	C:/Perl/lib/auto/DBI/.packlist
	C:/Perl/lib/auto/DBI/DBI.bs
	C:/Perl/lib/auto/DBI/DBI.dll
	C:/Perl/lib/auto/DBI/DBI.exp
	C:/Perl/lib/auto/DBI/DBI.lib
	C:/Perl/lib/auto/DBI/DBIXS.h
	C:/Perl/lib/auto/DBI/Driver.xst
	C:/Perl/lib/auto/DBI/Driver_xst.h
	C:/Perl/lib/auto/DBI/dbd_xsh.h
	C:/Perl/lib/auto/DBI/dbi_sql.h
	C:/Perl/lib/auto/DBI/dbipport.h
	C:/Perl/lib/auto/DBI/dbivport.h
	C:/Perl/lib/auto/DBI/dbixs_rev.h
	C:/Perl/lib/dbixs_rev.pl



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

Date: Fri, 26 Feb 2010 12:08:55 -0800 (PST)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Unable to run sample code from DBD::DBM on Strawberry Perl
Message-Id: <f3f997f1-dddf-4cd1-8516-07bca6598006@u5g2000prd.googlegroups.com>

On Feb 26, 11:25=A0am, Steve C <smallp...@juno.com> wrote:
>
> These are not perl errors, they are errors in your
> understanding of how a database works. =A0You can't
> create a new table if a table already exists with
> that name. =A0If you don't want the old one, you need
> to DROP it first.


   I understand that.  But the first time I run the script, there is
no database by the name 'user'.  Therefore, it shouldn't be
complaining that the 'user' table already exists.

   In fact, just to make sure, I went ahead and added "DROP TABLE
user;" to my script, just like you said (I also commented out the
'RaiseError' line), making it look like this:

use DBI;
my $dbh =3D DBI->connect('dbi:DBM:');
# $dbh->{RaiseError} =3D 1;
for my $sql( split /;\n+/,"
    DROP TABLE user;
    CREATE TABLE user ( user_name TEXT, phone TEXT );
    INSERT INTO user VALUES ('Fred Bloggs','233-7777');
    INSERT INTO user VALUES ('Sanjay Patel','777-3333');
    INSERT INTO user VALUES ('Junk','xxx-xxxx');
    DELETE FROM user WHERE user_name =3D 'Junk';
    UPDATE user SET phone =3D '999-4444' WHERE user_name =3D 'Sanjay
Patel';
    SELECT * FROM user
"){
    my $sth =3D $dbh->prepare($sql);
    $sth->execute;
    $sth->dump_results if $sth->{NUM_OF_FIELDS};
}
$dbh->disconnect;

   Now when I run the script, I see:

Execution ERROR: Table 'user' already exists..
DBD::DBM::st execute failed: Can't call method "column" on an
undefined value at C:/strawberry/perl/site/lib/SQL/Statement/Term.pm
line 190.
 [for Statement "    DELETE FROM user WHERE user_name =3D 'Junk'"] at
dbi_dbm.pl line 15.
Execution ERROR: Column 'phone' not known in any table called from C:/
strawberry/perl/site/lib/DBD/File.pm at 446.
Execution ERROR:
Execution ERROR: Column 'phone' not known in any table called from C:/
strawberry/perl/site/lib/DBD/File.pm at 446.
 called from dbi_dbm.pl at 15.
Execution ERROR:
Execution ERROR:
Execution ERROR: Column 'phone' not known in any table called from C:/
strawberry/perl/site/lib/DBD/File.pm at 446.
 called from dbi_dbm.pl at 15.
 .
undef, undef
undef, undef
undef, undef
3 rows

   Notice that the Execution ERROR stating that table 'user' already
exists is still reported.  I don't think it's my understanding that's
in error here.  (Especially since the example script (as shown in
"perldoc DBD::DBM") worked just fine for time the first time I ran it
in Linux.)

   (What I'm trying to say is, if "DROP TABLE user;" was required to
run the example the first time, then the perldocs would have given a
faulty script by not including that line.)


> Why do you think deleting the files is the right thing to do?
> If you want to use a database, learn how first. Don't just guess.

   Because when I ran the script it created those three new files,
each beginning with "user".  That's consistent with what I know of DBM
databases, in that the DBM data is stored in files beginning with the
database name.  (At least, that's the behavior I've seen with all the
DBM databases I've tinkered with.)

   But if you have a concrete example that contradicts mine, please
show it to me.  I mentioned that I deleted the "user*" files to
indicate that I shouldn't have any DBM files hanging around that begin
with "user".  But if the table already exists because it's stored in
some other file (thus proving my assumption false), I'd definitely
like to know.

   The fact that I could see the inserted data (with a hex editor) in
the "user.pag" file seems to reinforce my assumption.

   But if you can prove my assumption wrong (which is that the
database data is held in the "user*" files), please do so!  I would
appreciate having that false assumption corrected (if it is indeed
false).

   Cheers,

   -- Jean-Luc


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

Date: Fri, 26 Feb 2010 16:40:24 -0500
From: Steve C <smallpond@juno.com>
Subject: Re: Unable to run sample code from DBD::DBM on Strawberry Perl
Message-Id: <hm9f4q$6bh$1@news.eternal-september.org>

jl_post@hotmail.com wrote:
> On Feb 26, 11:25 am, Steve C <smallp...@juno.com> wrote:
>> These are not perl errors, they are errors in your
>> understanding of how a database works.  You can't
>> create a new table if a table already exists with
>> that name.  If you don't want the old one, you need
>> to DROP it first.
> 
> 
>    I understand that.  But the first time I run the script, there is
> no database by the name 'user'.  Therefore, it shouldn't be
> complaining that the 'user' table already exists.
> 
>    In fact, just to make sure, I went ahead and added "DROP TABLE
> user;" to my script, just like you said (I also commented out the
> 'RaiseError' line), making it look like this:
> 
> use DBI;
> my $dbh = DBI->connect('dbi:DBM:');
> # $dbh->{RaiseError} = 1;
> for my $sql( split /;\n+/,"
>     DROP TABLE user;
>     CREATE TABLE user ( user_name TEXT, phone TEXT );
>     INSERT INTO user VALUES ('Fred Bloggs','233-7777');
>     INSERT INTO user VALUES ('Sanjay Patel','777-3333');
>     INSERT INTO user VALUES ('Junk','xxx-xxxx');
>     DELETE FROM user WHERE user_name = 'Junk';
>     UPDATE user SET phone = '999-4444' WHERE user_name = 'Sanjay
> Patel';
>     SELECT * FROM user
> "){
>     my $sth = $dbh->prepare($sql);
>     $sth->execute;
>     $sth->dump_results if $sth->{NUM_OF_FIELDS};
> }
> $dbh->disconnect;
> 
>    Now when I run the script, I see:
> 
> Execution ERROR: Table 'user' already exists..
> DBD::DBM::st execute failed: Can't call method "column" on an
> undefined value at C:/strawberry/perl/site/lib/SQL/Statement/Term.pm
> line 190.
>  [for Statement "    DELETE FROM user WHERE user_name = 'Junk'"] at
> dbi_dbm.pl line 15.
> Execution ERROR: Column 'phone' not known in any table called from C:/
> strawberry/perl/site/lib/DBD/File.pm at 446.
> Execution ERROR:
> Execution ERROR: Column 'phone' not known in any table called from C:/
> strawberry/perl/site/lib/DBD/File.pm at 446.
>  called from dbi_dbm.pl at 15.
> Execution ERROR:
> Execution ERROR:
> Execution ERROR: Column 'phone' not known in any table called from C:/
> strawberry/perl/site/lib/DBD/File.pm at 446.
>  called from dbi_dbm.pl at 15.
> .
> undef, undef
> undef, undef
> undef, undef
> 3 rows
> 
>    Notice that the Execution ERROR stating that table 'user' already
> exists is still reported.  I don't think it's my understanding that's
> in error here.  (Especially since the example script (as shown in
> "perldoc DBD::DBM") worked just fine for time the first time I ran it
> in Linux.)
> 
>    (What I'm trying to say is, if "DROP TABLE user;" was required to
> run the example the first time, then the perldocs would have given a
> faulty script by not including that line.)
> 
> 
>> Why do you think deleting the files is the right thing to do?
>> If you want to use a database, learn how first. Don't just guess.
> 
>    Because when I ran the script it created those three new files,
> each beginning with "user".  That's consistent with what I know of DBM
> databases, in that the DBM data is stored in files beginning with the
> database name.  (At least, that's the behavior I've seen with all the
> DBM databases I've tinkered with.)
> 
>    But if you have a concrete example that contradicts mine, please
> show it to me.  I mentioned that I deleted the "user*" files to
> indicate that I shouldn't have any DBM files hanging around that begin
> with "user".  But if the table already exists because it's stored in
> some other file (thus proving my assumption false), I'd definitely
> like to know.
> 
>    The fact that I could see the inserted data (with a hex editor) in
> the "user.pag" file seems to reinforce my assumption.
> 
>    But if you can prove my assumption wrong (which is that the
> database data is held in the "user*" files), please do so!  I would
> appreciate having that false assumption corrected (if it is indeed
> false).
> 

I didn't say the table wasn't stored in those files, I said that
deleting the files is not the appropriate way to manipulate a
database.

dbm refers to a number of different database methods depending
on the libraries installed on your system, so you can't expect
different system to behave the same way when you do something outside
of the normal methods.

You should be checking the return values from both connect and from
execute at each step, regardless of what the example code says.


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

Date: Fri, 26 Feb 2010 16:42:47 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Would like some words of wisdom - convert text files to CSV
Message-Id: <slrnhofqvn.3ci.hjp-usenet2@hrunkner.hjp.at>

On 2010-02-25 23:40, GlenM <glenmillard@gmail.com> wrote:
> Perhaps you would be able to provide me with some module examples that
> will extract email messages. The reason being is that I need to have
> these emails in a spread sheet for a presentation that I am providing
> to a government official - makes it easier for them to read.

I can think of a few reasons why you might want to represent an email
message in a single line, but "easy to read" is definitely not one of
them - how would a single line, thousands to millions of characters
long, be easy to read? 

	hp



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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2837
***************************************


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