Re: Sending Mail

2005-03-25 Thread Gav....
Thanks Michael,

I have taken on board and implemented your changes re:error checking etc.

Actually, my code did work apart from this one line :-

my $sth = $dbh-prepare(SELECT email_address FROM users)

The above is what I quoted you, which now works, but for testing I did not 
want to send out to all users so amended it to

my $sth = $dbh-prepare(SELECT email_address FROM users WHERE 
email_address='[EMAIL PROTECTED]')

The above line did not work, so the address was not found, guess who forgot 
to escape the @ !!

my $sth = $dbh-prepare(SELECT email_address FROM users WHERE 
email_address='[EMAIL PROTECTED]')

Now this worked fine, so did the rest of the script. Error checking did not 
help in this case though, it simply could not
find it in the database beacuse it wasnt sending the full email address to 
look for without the \.

Thanks for your help

Gav... 



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 23/03/2005



A good Perl Book

2005-03-25 Thread Gav....
Hi Guys,

Considering the other thread re: Sending Mail is about my level of expertise 
in Perl,
what would you recomend as a good book to become an expert of sorts.?

I have looked at getting Programming the Perl DBI
by Alligator Descartes, Tim Bunce

more on this web page 
http://www.amazon.com/exec/obidos/ASIN/1565926994/webmasterresou05/102-9550958-5588144


I guess there may be a bit of bias coming up from certain quarters :)

Will any of the above site do me, is there a 2004 or 2005 edition of any 
Perl Books around?
I dont really want to concentrate on the DBI, a good all round book that 
delves quite deep
will do me :)

Gav...(Hope the list doesn't mind this type of question in here!) 



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 23/03/2005



Re: Sending Mail

2005-03-25 Thread Adriano Ferreira
my $sth = $dbh-prepare(SELECT email_address FROM users WHERE
email_address='[EMAIL PROTECTED]')

The above line did not work, so the address was not found, guess who forgot
to escape the @ !!

If you were using the recommended pragma
   use warnings;
at the beginning of the script (or running perl -w), you would have
found earlier that @myisp was being misinterpreted, with a warning
message like this:
   Possible unintended interpolation of @myisp in string at ...
   Name main::myisp used only once: possible typo at ...

Regards,
Adriano.


RE: A good Perl Book

2005-03-25 Thread Reidy, Ron
1.  Programming Perl
2.  Perl Cookbook
3.  Object Oriented Perl
4.  Extending and Embedding Perl
5.  Writing CGI Applications with Perl


-
Ron Reidy
Lead DBA
Array BioPharma, Inc.


-Original Message-
From: Gav [mailto:[EMAIL PROTECTED]
Sent: Friday, March 25, 2005 6:37 AM
To: dbi-users@perl.org
Subject: A good Perl Book


Hi Guys,

Considering the other thread re: Sending Mail is about my level of expertise 
in Perl,
what would you recomend as a good book to become an expert of sorts.?

I have looked at getting Programming the Perl DBI
by Alligator Descartes, Tim Bunce

more on this web page 
http://www.amazon.com/exec/obidos/ASIN/1565926994/webmasterresou05/102-9550958-5588144


I guess there may be a bit of bias coming up from certain quarters :)

Will any of the above site do me, is there a 2004 or 2005 edition of any 
Perl Books around?
I dont really want to concentrate on the DBI, a good all round book that 
delves quite deep
will do me :)

Gav...(Hope the list doesn't mind this type of question in here!) 



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 23/03/2005


This electronic message transmission is a PRIVATE communication which contains
information which may be confidential or privileged. The information is 
intended 
to be for the use of the individual or entity named above. If you are not the 
intended recipient, please be aware that any disclosure, copying, distribution 
or use of the contents of this information is prohibited. Please notify the
sender  of the delivery error by replying to this message, or notify us by
telephone (877-633-2436, ext. 0), and then delete it from your system.



Re: A good Perl Book

2005-03-25 Thread Michal Kurowski
Gav [EMAIL PROTECTED] wrote:
 
 Considering the other thread re: Sending Mail is about my level of expertise 
 in Perl,
 what would you recomend as a good book to become an expert of sorts.?
 
 I have looked at getting Programming the Perl DBI
 by Alligator Descartes, Tim Bunce
 
 more on this web page 
 http://www.amazon.com/exec/obidos/ASIN/1565926994/webmasterresou05/102-9550958-5588144
 

Perl Cookbook by Tom Christiansen and Nat Torkington is what I
recommend you reading.

See: 

http://safari.oreilly.com/?x=1mode=sectionsortKey=titlesortOrder=ascview=xmlid=0-596-00313-7g=catid=itbooks.prog.perls=1b=1f=1t=1c=1u=1r=o=1n=1d=1p=1a=0page=2

Cheers,

-- 
Michal Kurowski
perl -e '$_=q#: 13_2: 12/o{: 8_4) (_4: 6/2^-2; 3;-2^\2: 5/7\_/\7: 12m m::#;
y#:#\n#;s#(\D)(\d+)#$1x$2#ge;print'



Re: Sending Mail

2005-03-25 Thread Ian Harisay
Also, I would recommend you consider using placeholders for all values
passed to your prepare statement. 
 
eg.  my $sth = $dbh-prepare('SELECT email_address FROM users WHERE
email_address = ?') || die $dbh-errstr(); 
 $sth-execute($email) || die $dbh-errstr(); 
but looking at your query I think you would be better off doing: 
my $rec = $dbh-selectrow_hashref(EOS,{}, $email) || die
$dbh-errstr(); 
  SELECT email_address FROM email_address WHERE email_address = ? 
EOS 
print $rec-{email_address},$/; 
 
Adriano Ferreira [EMAIL PROTECTED] 03/25 7:24 am  
 
my $sth = $dbh-prepare(SELECT email_address FROM users WHERE 
 
email_address='[EMAIL PROTECTED]') 
 
 
The above line did not work, so the address was not found, guess who
forgot 
 
to escape the @ !! 
 
 
If you were using the recommended pragma 
 
  use warnings; 
 
at the beginning of the script (or running perl -w), you would have 
 
found earlier that @myisp was being misinterpreted, with a warning 
 
message like this: 
 
  Possible unintended interpolation of @myisp in string at ... 
 
  Name main::myisp used only once: possible typo at ... 
 
 
Regards, 
 
Adriano. 


Re: Sending Mail

2005-03-25 Thread Ian Harisay
Also, I would recommend you consider using placeholders for all values
passed to your prepare statement. 
  
eg.  my $sth = $dbh-prepare('SELECT email_address FROM users WHERE
email_address = ?') || die $dbh-errstr(); 
 $sth-execute($email) || die $dbh-errstr(); 
 
but looking at your query I think you would be better off doing: 
 
my $rec = $dbh-selectrow_hashref(EOS,{}, $email) || die
$dbh-errstr(); 
  SELECT email_address FROM email_address WHERE email_address = ? 
EOS 
 
print $rec-{email_address},$/; 
  
Adriano Ferreira [EMAIL PROTECTED] 03/25 7:24 am  
  
my $sth = $dbh-prepare(SELECT email_address FROM users WHERE 
  
email_address='[EMAIL PROTECTED]') 
  
  
The above line did not work, so the address was not found, guess who
forgot 
  
to escape the @ !! 
  
  
If you were using the recommended pragma 
  
  use warnings; 
  
at the beginning of the script (or running perl -w), you would have 
  
found earlier that @myisp was being misinterpreted, with a warning 
  
message like this: 
  
  Possible unintended interpolation of @myisp in string at ... 
  
  Name main::myisp used only once: possible typo at ... 
  
  
Regards, 
  
Adriano. 



Re: A good Perl Book

2005-03-25 Thread Richard . Rice





A good reference book that I use is:

  Teach Yourself Perl 5 in 21Days
by Dave Till

This book is for someone who wants to learn how to use Perl on a UNIX
machine and does not include any DBI information. The copy that I have is
from 1995. I checked Amazon and there is a new edition but this version is
by Laura Lemay. I discovered that the edition that I have can be found
on-line athttp://docs.rinet.ru/P7/

*
Richard Rice
Continental Tire North America, Inc.
(704) 583-8668
*


   
 Gav 
 brightoncomputer 
 [EMAIL PROTECTED]  To 
 m.au dbi-users@perl.org
cc 
 03/25/2005 08:36  
 AMSubject 
   A good Perl Book
   
   
   
   
   
   




Hi Guys,

Considering the other thread re: Sending Mail is about my level of
expertise
in Perl,
what would you recomend as a good book to become an expert of sorts.?

I have looked at getting Programming the Perl DBI
by Alligator Descartes, Tim Bunce

more on this web page
http://www.amazon.com/exec/obidos/ASIN/1565926994/webmasterresou05/102-9550958-5588144



I guess there may be a bit of bias coming up from certain quarters :)

Will any of the above site do me, is there a 2004 or 2005 edition of any
Perl Books around?
I dont really want to concentrate on the DBI, a good all round book that
delves quite deep
will do me :)

Gav...(Hope the list doesn't mind this type of question in here!)



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 23/03/2005





Re: A good Perl Book

2005-03-25 Thread Kevin Carothers
Hi-

On Fri, 25 Mar 2005 21:36:40 +0800, Gav
[EMAIL PROTECTED] wrote:
 Hi Guys,
 
[---]
 I have looked at getting Programming the Perl DBI
 by Alligator Descartes, Tim Bunce
 
[---]

Are you looking at getting a general Perl book, or a DBI Perl book? 
For about six years, I've had the Perl 5 Pocket reference (v. 3) and
Programming Perl.  Both by O' Reilly.  I guess I use the pocket ref
more;  I use the Programming Perl book for ideas;   I didn't like the
Perl Cookbook because, well, I don't know- I guess because I found the
examples to be of more depth than breadth for my taste.  I DID have
CGI programming with Perl but I don't use the CGI pm anymore.

But... If you're looking for what is probably the best reference in
the world for Perl?   You're already reading it-  yes the mail and
newsgroups!   I have found that whatever programming problem I have,
if I Google the right keywords, I can find code that helps - or at
worst, something I can at least try.

This is slightly off-topic, but I think with all the bad news in the
world, it's so great that Perl skills are in such demand now-  I did a
search on hotjobs for database and Perl and got 712... database and
VB got 411 (!!)   As they say... who'da thunk it :-)

K.C


(Fwd) DBI support for executing SQL scripts

2005-03-25 Thread Tim Bunce
- Forwarded message from Qaseem Shaikh [EMAIL PROTECTED] -

Delivered-To: [EMAIL PROTECTED]
X-SPF-Guess: pass (seems reasonable for [EMAIL PROTECTED] to mail through 
206.190.38.248)
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Date: Thu, 24 Mar 2005 16:59:09 -0800 (PST)
From: Qaseem Shaikh [EMAIL PROTECTED]
Subject: DBI support for executing SQL scripts
To: [EMAIL PROTECTED]

Hi

I have been looking for ways to run .sql files on a
MySQl database via DBI. And I guess I've hit the wall.
I believe that do(), prepare()+execute() would only
execute pure sql. I don't want to parse the sql files
and run each statement separately because those files
would contain:

a. statements such as use DatabaseX
b. various other characters such as --(are
autogenerated by some tool)

These files could be easily run by doing
a. source on the mysql promt
b. mysql DatabaseX  file.sql on the command prompt

Would you pls suggest something here? Your help would
be greatly appreciated.

Thanks,
Qaseem



__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

- End forwarded message -


RE: (Fwd) DBI support for executing SQL scripts

2005-03-25 Thread Reidy, Ron
use Expect;

-
Ron Reidy
Lead DBA
Array BioPharma, Inc.


-Original Message-
From: Tim Bunce [mailto:[EMAIL PROTECTED]
Sent: Friday, March 25, 2005 1:47 PM
To: dbi-users@perl.org
Cc: [EMAIL PROTECTED]
Subject: (Fwd) DBI support for executing SQL scripts


- Forwarded message from Qaseem Shaikh [EMAIL PROTECTED] -

Delivered-To: [EMAIL PROTECTED]
X-SPF-Guess: pass (seems reasonable for [EMAIL PROTECTED] to mail through 
206.190.38.248)
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Date: Thu, 24 Mar 2005 16:59:09 -0800 (PST)
From: Qaseem Shaikh [EMAIL PROTECTED]
Subject: DBI support for executing SQL scripts
To: [EMAIL PROTECTED]

Hi

I have been looking for ways to run .sql files on a
MySQl database via DBI. And I guess I've hit the wall.
I believe that do(), prepare()+execute() would only
execute pure sql. I don't want to parse the sql files
and run each statement separately because those files
would contain:

a. statements such as use DatabaseX
b. various other characters such as --(are
autogenerated by some tool)

These files could be easily run by doing
a. source on the mysql promt
b. mysql DatabaseX  file.sql on the command prompt

Would you pls suggest something here? Your help would
be greatly appreciated.

Thanks,
Qaseem



__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

- End forwarded message -

This electronic message transmission is a PRIVATE communication which contains
information which may be confidential or privileged. The information is 
intended 
to be for the use of the individual or entity named above. If you are not the 
intended recipient, please be aware that any disclosure, copying, distribution 
or use of the contents of this information is prohibited. Please notify the
sender  of the delivery error by replying to this message, or notify us by
telephone (877-633-2436, ext. 0), and then delete it from your system.



Misunderstood use of Getopt::long

2005-03-25 Thread Vergara, Michael \(TEM\)
Hi All:

I have this code...
#!/opt/perl64/bin/perl -w
# v5.8.4 built for PA-RISC2.0-LP64
use Getopt::Long;
my %optctl = ();
Getopt::Long::GetOptions( \%optctl, x!, z!)
or die \nOption Error\n\n;
my( $headerFlag, $duplexFlag );
if ( $optctl{z} ) { $headerFlag = $optctl{z}; }
  else { $headerFlag = 1 };
if ( $optctl{x} ) { $duplexFlag = $optctl{x}; }
  else { $duplexFlag = 0 };
print header   = $headerFlag\n;
print duplex   = $duplexFlag\n;

When I run it, I get this:
$ ./p
header   = 1
duplex   = 0
$ ./p -x
header   = 1
duplex   = 1
$ ./p -x -noz
header   = 1
duplex   = 1
$ ./p -nox -noz
header   = 1
duplex   = 0

My problem is that header is always 1 and I don't think it should be
when I specify -noz.   If I can toggle the value of the 'x' option,
why not the 'z' option?

What am I not seeing?

Thanks,
Mike

---
==
Michael P. Vergara
Oracle DBA
Guidant Corporation
www.guidant.com




RE: Misunderstood use of Getopt::long

2005-03-25 Thread Ronald J Kimball


Vergara, Michael (TEM) [mailto:[EMAIL PROTECTED] wrote:

 use Getopt::Long;
 my %optctl = ();
 Getopt::Long::GetOptions( \%optctl, x!, z!)
 or die \nOption Error\n\n;
 my( $headerFlag, $duplexFlag );
 if ( $optctl{z} ) { $headerFlag = $optctl{z}; }
   else { $headerFlag = 1 };
 if ( $optctl{x} ) { $duplexFlag = $optctl{x}; }
   else { $duplexFlag = 0 };
 print header   = $headerFlag\n;
 print duplex   = $duplexFlag\n;

 My problem is that header is always 1 and I don't think it should be
 when I specify -noz.   If I can toggle the value of the 'x' option,
 why not the 'z' option?
 
 What am I not seeing?

This is not a DBI question.  Please ask your questions in the appropriate
forum.

Since I'm feeling helpful at the moment, I will point out that you are
checking whether the option is true; you should be checking whether it
exists.

if ( exists $optctl{z} ) {

HTH,
Ronald




Re: (Fwd) DBI support for executing SQL scripts

2005-03-25 Thread Jeff Zucker
- Forwarded message from Qaseem Shaikh [EMAIL PROTECTED] -
I have been looking for ways to run .sql files on a
MySQl database via DBI.
The DBI::Shell distribution includes dbish, a program which can run SQL 
against any DBI accessible database either interactively or in batch mode.

And I guess I've hit the wall.
I believe that do(), prepare()+execute() would only
execute pure sql.
a. statements such as use DatabaseX
 

If that's a valid statement in MySQL, DBI do() will happily pass it 
along and MySQL won't object.

b. various other characters such as --(are
autogenerated by some tool)
 

If those are valid comment markers in MySQL, DBI do(), prepare(), and 
execute() will happily pass them along and MySQL won't object.

--
Jeff


Re: Misunderstood use of Getopt::long

2005-03-25 Thread Ian Harisay
This is the wrong forum for this kind of question.  But try this instead
it will give you a much clearer picture. 
 
use Getopt::Long; 
use Data::Dumper; 
my %optctl; 
Getopt::Long::GetOptions(\%optctl, 'x!', 'z!') or die \nOption
Error\n\n; 
 
print Dumper(\%optctl),$/; 
 
Vergara, Michael (TEM) [EMAIL PROTECTED] 03/25 2:59 pm  
 
Hi All: 
 
 
I have this code... 
 
#!/opt/perl64/bin/perl -w 
 
# v5.8.4 built for PA-RISC2.0-LP64 
 
use Getopt::Long; 
 
my %optctl = (); 
 
Getopt::Long::GetOptions( \%optctl, x!, z!) 
 
or die \nOption Error\n\n; 
 
my( $headerFlag, $duplexFlag ); 
 
if ( $optctl{z} ) { $headerFlag = $optctl{z}; } 
 
 else { $headerFlag = 1 }; 
 
if ( $optctl{x} ) { $duplexFlag = $optctl{x}; } 
 
 else { $duplexFlag = 0 }; 
 
print header   = $headerFlag\n; 
 
print duplex   = $duplexFlag\n; 
 
 
When I run it, I get this: 
 
$ ./p 
 
header   = 1 
 
duplex   = 0 
 
$ ./p -x 
 
header   = 1 
 
duplex   = 1 
 
$ ./p -x -noz 
 
header   = 1 
 
duplex   = 1 
 
$ ./p -nox -noz 
 
header   = 1 
 
duplex   = 0 
 
 
My problem is that header is always 1 and I don't think it should be 
 
when I specify -noz.   If I can toggle the value of the 'x' option, 
 
why not the 'z' option? 
 
 
What am I not seeing? 
 
 
Thanks, 
 
Mike 
 
 
--- 
 
== 
 
Michael P. Vergara 
 
Oracle DBA 
 
Guidant Corporation 
 
www.guidant.com 
 
 



Re: Misunderstood use of Getopt::long

2005-03-25 Thread Tim Bunce
On Fri, Mar 25, 2005 at 01:59:05PM -0800, Vergara, Michael (TEM) wrote:
 
 What am I not seeing?

That this list is for DBI related issues. Sorry, but discussing other topics
is an abuse of the list and the time of its thousands of subscribers.

This'll help explain why that's important:
http://www.catb.org/~esr/faqs/smart-questions.html

Tim.