[23757] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5961 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 20 03:05:39 2003

Date: Sat, 20 Dec 2003 00:05: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           Sat, 20 Dec 2003     Volume: 10 Number: 5961

Today's topics:
    Re: Adding Header to a database/csv <invalid-email@rochester.rr.com>
    Re: How to apend 1 file to another? <me@privacy.net>
        how to detect broken pipe ? (funtoosh)
        Is mysql.pm part of DBI? <test@test.com>
    Re: Is mysql.pm part of DBI? <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: Is mysql.pm part of DBI? <test@test.com>
    Re: Is mysql.pm part of DBI? (Malcolm Dew-Jones)
    Re: Is mysql.pm part of DBI? <kkeller-usenet@wombat.san-francisco.ca.us>
        Is Tie::CSV_File dependable on Tie:File <test@test.com>
    Re: Is Tie::CSV_File dependable on Tie:File <tassilo.parseval@rwth-aachen.de>
    Re: Mysterious MySQL values (Martin Foster)
    Re: ODBC: Is there something called text/csv database? (Jay Tilton)
    Re: ODBC: Is there something called text/csv database? <test@test.com>
        phone number mnemonics <qjason@starhub.net.sg>
    Re: Problem with DBI MySQL (UPDATE command) (Brad)
    Re: Problem with DBI MySQL (UPDATE command) <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: redirect without meta <abigail@abigail.nl>
    Re: redirect without meta (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 20 Dec 2003 03:35:24 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Adding Header to a database/csv
Message-Id: <3FE3C05C.8000609@rochester.rr.com>

Public Interest wrote:

> i have something like:
> aaa, 11.11, 123456
> bbb, 22.22, 122432
> in a csv file
> 
> but i want it to look like
> stock symbol, price, volume,
> aaa, 11.11, 123456
> bbb, 22.22, 122432
> 
> can i access to the csv file without reading the first line?

Well, one could use the seek() function to skip over the first line, but 
then one would have to know how long the first line is -- and that in 
general can only be determined by reading the first line.  You can of 
course simply read the first line and discard it.  Given that you will 
be reading all the rest of the lines in the file, what is one more line?

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sat, 20 Dec 2003 12:31:53 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: How to apend 1 file to another?
Message-Id: <bs01r0$8b09u$1@ID-172104.news.uni-berlin.de>


"Wow" <test@test.com> wrote in message
news:hTnEb.485841$0v4.21460202@bgtnsc04-news.ops.worldnet.att.net...
> Do I have to read file1 and do a >> to file2? Any easiler way? Perl or
Shell
> scripts are both OK.

I'd use a shell script for this (if you can call a one line command a shell
script)

cat file1 >>file2




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

Date: 19 Dec 2003 22:11:38 -0800
From: a_gilotra@yahoo.com (funtoosh)
Subject: how to detect broken pipe ?
Message-Id: <5fe73253.0312192211.6a9c02b4@posting.google.com>

Hi

Scenario:

I have a shell script e.g. a.bash
This script wraps a program called "generate" like this:

generate > /tmp/y.txt 2>&1 # both stdout and stderr r redirected to
y.txt

Now , I have perl script e.g. myPerl.pl and I modify a.bash such that:

generate | perl myPerl.pl # pipe output from "generate" to the perl
script.

And in myPerl.pl, I wrote this :

sub whatSignal { print "caught ",shift, "\n" };
$SIG($_}=\ &whatSignal for keys %SIG

And now I run a.bash in one xterm:
Following happens:
When press ctrl-C, it is caught.

But when I kill pid of program "generate" from a different xterm, my
script doesnt detect "broken pipe" ?

Comments ?


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

Date: Sat, 20 Dec 2003 03:59:33 GMT
From: "Social Liberal-Fiscal Conservative" <test@test.com>
Subject: Is mysql.pm part of DBI?
Message-Id: <FOPEb.495111$0v4.21609442@bgtnsc04-news.ops.worldnet.att.net>

I don't understand if I can use
DBI:mysql
why I have to add mysql.pm again?


-- 
I am Social Liberal-Fiscal Conservative
Social Liberal: Forgiveness, Acceptance of Difference, Universal Healthcare,
Free College Education for Everyone
Fiscal Conservative: Small Government, No Tax for Low Income




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

Date: Fri, 19 Dec 2003 21:42:18 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Is mysql.pm part of DBI?
Message-Id: <qfn0sb.sdg.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On 2003-12-20, Social Liberal-Fiscal Conservative <test@test.com> wrote:
> I don't understand if I can use
> DBI:mysql
> why I have to add mysql.pm again?

I don't understand how you can use DBI::mysql; it's DBD::mysql.  You
should never have to use DBD::mysql anyway, since DBI takes care of
loading the appropriate DBD:: module for you.

- --keith

- -- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/4+E4hVcNCxZ5ID8RAvf+AJ9ccSS59o544ru6FvzG7ixWk4DxRACaAlSB
6CC8d0I/n0uq1GI8UpnPajg=
=xZl3
-----END PGP SIGNATURE-----


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

Date: Sat, 20 Dec 2003 05:58:25 GMT
From: "Social Liberal-Fiscal Conservative" <test@test.com>
Subject: Re: Is mysql.pm part of DBI?
Message-Id: <5yREb.218214$Ec1.7812169@bgtnsc05-news.ops.worldnet.att.net>


> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2003-12-20, Social Liberal-Fiscal Conservative <test@test.com> wrote:
> > I don't understand if I can use
> > DBI:mysql
> > why I have to add mysql.pm again?
>
> I don't understand how you can use DBI::mysql; it's DBD::mysql.  You
> should never have to use DBD::mysql anyway, since DBI takes care of
> loading the appropriate DBD:: module for you.
>
> - --keith
>

How do I know I have DBD::mysql installed? If I have DBI, do I have to
install DBD::mysql?




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

Date: 19 Dec 2003 22:11:17 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Is mysql.pm part of DBI?
Message-Id: <3fe3e805@news.victoria.tc.ca>

Social Liberal-Fiscal Conservative (test@test.com) wrote:
: I don't understand if I can use
: DBI:mysql
: why I have to add mysql.pm again?

As far as I know, I have never used the file mysql.pm when accessing mysql
using DBI (or at any other time fro that matter).

But, it is possible that it is one of the files installed when you install
the mysql driver.

Why do you think you need this file?



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

Date: Fri, 19 Dec 2003 23:26:13 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Is mysql.pm part of DBI?
Message-Id: <lit0sb.hqg.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On 2003-12-20, Social Liberal-Fiscal Conservative <test@test.com> wrote:
>
> How do I know I have DBD::mysql installed?

perl -e 'use DBD::mysql'

> If I have DBI, do I have to install DBD::mysql?

Only if you want to connect to a MySQL server.  ;-)

It really sounds like you need to go to http://dbi.perl.org and read up
on using DBI before going too much further.

- --keith

- -- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/4/mThVcNCxZ5ID8RAsS8AJ4lYp0GlAfr9wj5q2NvdExPIwmx4gCgmeHj
jRVst2N2s2Zy4kC+ZFSAEmg=
=a2UK
-----END PGP SIGNATURE-----


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

Date: Sat, 20 Dec 2003 05:09:48 GMT
From: "Social Liberal-Fiscal Conservative" <test@test.com>
Subject: Is Tie::CSV_File dependable on Tie:File
Message-Id: <wQQEb.495463$0v4.21615965@bgtnsc04-news.ops.worldnet.att.net>

http://search.cpan.org/~bigj/Tie-CSV_File-0.21/CSV_File.pm
says
There's only a small part of the whole file in memory, so this module will
work also for large files. Please look the Tie::File module for any details,
as I use it to read the lines of the file.

Does that mean if I do a
use lib ...
use Tie::CSV_File
then I must also include
use lib ...
use Tie::File
in CSV_File?


-- 
I am Social Liberal-Fiscal Conservative
Social Liberal: Forgiveness, Acceptance of Difference, Universal Healthcare,
Free College Education for Everyone
Fiscal Conservative: Small Government, No Tax for Low Income




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

Date: 20 Dec 2003 08:01:54 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Is Tie::CSV_File dependable on Tie:File
Message-Id: <bs0vli$ra3$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Social Liberal-Fiscal Conservative:

> http://search.cpan.org/~bigj/Tie-CSV_File-0.21/CSV_File.pm
> says
> There's only a small part of the whole file in memory, so this module will
> work also for large files. Please look the Tie::File module for any details,
> as I use it to read the lines of the file.
> 
> Does that mean if I do a
> use lib ...
> use Tie::CSV_File
> then I must also include
> use lib ...
> use Tie::File
> in CSV_File?

No, you don't that. You only have to explicitely use() Tie::File when
you want to access its functionality in your script. If you have a
module that makes use of it then it's the module's responsibility to
include it.

This is true not just for Tie::CSV_File but for any module. Include the
module you want to use and don't care about how this module does its
work.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 19 Dec 2003 16:06:34 -0800
From: mdfoster44@netscape.net (Martin Foster)
Subject: Re: Mysterious MySQL values
Message-Id: <6a20f90a.0312191606.1ad5e5eb@posting.google.com>

Duh!

I changed float to double in create table and then re-ran...

5:01pm : titan : martin  79> perl testing_bug.plx test_data.cif 
/home/martin/DATABASE/test_data.cif
Found GULP Energy = -128.515711 For str_id number 1
1       225_2_11        2       -128.51571100000001024455

Great!  Thanks!  I'm embarrassed I didn't see that... 

Cheers,

Martin.


Sherm Pendley <spamfilter@dot-app.org> wrote in message news:<5QFEb.366$zC4.559842@news2.news.adelphia.net>...
> Martin Foster wrote:
> 
> > So the bug is here, the value for the energy that I am entering is
> > -128.515711
> > but MySQL is returning -128.515716552734375 !
> > 
> > Why is the value wrong to the sixth decimal place which should be a 1
> > not a 6 and why all these extra digits.
> 
> Short answer: Not all values that can be expressed in decimal notation 
> can be exactly represented with a float.
> 
> A longer explanation can be found here:
> 
> <http://www.scit.wlv.ac.uk/cbook/chap4.fp.accuracy.html>
> 
> sherm--


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

Date: Sat, 20 Dec 2003 02:26:15 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: ODBC: Is there something called text/csv database?
Message-Id: <3fe3b12c.362664@news.erols.com>

"Public Interest" <test@test.com> wrote:

: As I open "driver" for ODBC, there is something called "Microsoft Text
: Driver (*.txt; *.csv)"
: 
: Ok, I understand that a .csv is, but I don't understand how ODBC will run
: SQL on a .csv.

You shouldn't care.  It's the ODBC server's problem.

: Perl has something called DBI which means it is database independent. Can I
: assume that ODBC/DBI is an interface to MySQL, Access, and CSV?

Close.  Mentioning "ODBC/DBI" in one breath like that suggests that the two
are related.  They are not.  Perl's DBI class and the ODBC server are two
separate layers between your Perl program and the physical data, and are in
no way interchangeable.

You will need to obtain the DBD::ODBC module from CPAN before the DBI class
can do anything with the ODBC server.

: Then will DBI act the same regardless what it connects to (Text, CSV,  
: MySQL). If so then there is no difference between any database systems.

As much as Perl is concerned, there are no differences.  The point of DBI
is to remove the burden of worrying about how all the underlying layers of
machinery accomplish the task.  You tell the appropriate DBI object what to
do, it tells ODBC, and the rest is left for the server to worry about.

: If not so, if I
: use the driver for text database, what limitations will I have?

It will be very much slower than the other choices.

: Such as can I specify "integer, string, binary" etc for each field.

The format of the text file is determined by using a schema.ini file.
Details of its creation and contents are squirrelled away in one of the
ODBC help files.

: Can I get a reference for all commands I can use for each database driver
: under ODBC/PerlDBI?

ODBC help files are included with the ODBC installation.
Documentation for Perl's DBI class is included in the DBI.pm module:
type "perldoc DBI" at a command prompt.



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

Date: Sat, 20 Dec 2003 03:15:26 GMT
From: "Social Liberal-Fiscal Conservative" <test@test.com>
Subject: Re: ODBC: Is there something called text/csv database?
Message-Id: <i9PEb.494877$0v4.21605097@bgtnsc04-news.ops.worldnet.att.net>

How to check what module I have installed? I did perldoc dbi, but nothing
found.




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

Date: Sat, 20 Dec 2003 14:01:48 +0800
From: Jason Quek <qjason@starhub.net.sg>
Subject: phone number mnemonics
Message-Id: <ucp7uv4ml3vhljj1mvju381ov0rrmhbouv@4ax.com>

Hi,

What I need to do is to find all possible combinations of words which
will map to a phone number.

An online example can be found at http://www.phonespell.com. Enter
'4382227' to get a list of mnemonics.



What the code does below is:

1. translate each word into its corresponding keypad number,
2. for all number which can be found in $phone_number, store in
@confirmed _matches.

# -------------------------------------------------------------
$phone_number = '4382227';
undef @confirmed_matches;

my %num_to_words;
@ARGV = "dict/words" unless @ARGV;
while (<>)
	{
	chomp;
	next unless
	my $translate = translate($_);

	if ($phone_number =~ /$translate/)
		{
		push @confirmed_matches, "$translate	$_";
		}
	}

sub translate
	{
	local $_ = lc shift;
	return unless
	tr[abcdefghijklmnoprstuvwxyz] [2223334445556667778889999] ==
length;
	$_;
	}
# -------------------------------------------------------------

My problem now is how do I write the code which will find all possible
combinations of words which will give the same results as
http://www.phonespell.com.

Any help would be appreciated.

Regards,




Jason Q.


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

Date: 19 Dec 2003 17:12:57 -0800
From: pj_sammie@hotmail.com (Brad)
Subject: Re: Problem with DBI MySQL (UPDATE command)
Message-Id: <2abd2946.0312191712.677454b5@posting.google.com>

I thought I solved the problem with 'key', but I actually found the
major problem in that process. MySQL would not let me use 'WHERE
key=xx' in the UPDATE command. I had to change that column to 'id',
and now it works.

Thanks,
Brad


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

Date: Fri, 19 Dec 2003 21:40:44 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Problem with DBI MySQL (UPDATE command)
Message-Id: <scn0sb.sdg.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On 2003-12-19, Brad <pj_sammie@hotmail.com> wrote:

> As far as moving to a hash, it would be ideal to ramin in arrays (even
> if not as affective). The next problem I am having, is getting the
> MySQL into an array without having to go through a bunch of steps.
> When I grab the line via DBI:
>
>          while( my @row = $sth->fetchrow_array ) {
>                 @updaterow = join("\t", @row), "\n";
>          }

Why are you assigning a scalar to an array?  Off the top of my head, it
looks like $updaterow[0] will contain your result row tab-delimited, and
$updaterow[1] will contain "\n".  That can't possibly be what you
want, can it?

> I then have to go and split into another array via:
>
>          foreach my $updaterow (@updaterow ) {
>                  @sqlsession = (split /\t/, $oldsession);
>                  ...
>
> Is there a way to grab a row into an array where each column is its
> own param (i.e. array[0] = column 1, array[1] = coulmn2, etc.)? I am
> only grabbing 1 row when opening the MySQL.

Of course:
          while( my @row = $sth->fetchrow_array ) {
	  	# $row[0] is already column 1, $row[1] is already
		# column 2, etc.
          }

perldoc DBI is pretty clear on this point.  Did you read the docs?

- --keith

- -- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/4+DZhVcNCxZ5ID8RAm4wAJ47knUZUJk7jmZh5JMgWniifv3T7wCaAubA
vJDVwgLFR9owHAJ6aYsCWjQ=
=sfXv
-----END PGP SIGNATURE-----


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

Date: 20 Dec 2003 02:37:15 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: redirect without meta
Message-Id: <slrnbu7der.les.abigail@alexandra.abigail.nl>

Robin (robin@csf.edu) wrote on MMMDCCLXII September MCMXCIII in
<URL:news:brvee7$o6r$1@reader2.nmix.net>:
<>  I've been trying to redirect to an html page in a cgi script...how would one
<>  do this wihout using a META tag in the script...?


Why do you ask here? 



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: Fri, 19 Dec 2003 21:11:21 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: redirect without meta
Message-Id: <slrnbu7fep.lt2.tadmc@magna.augustmail.com>

Robin <robin@csf.edu> wrote:

> I've been trying to redirect to an html page in a cgi script...how would one
> do this wihout using a META tag in the script...?


The same way you would if you were writing your CGI program in Python.

(you do not have a Perl question)


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


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

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


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