[24374] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6563 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 14 14:05:49 2004

Date: Fri, 14 May 2004 11:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 14 May 2004     Volume: 10 Number: 6563

Today's topics:
    Re: Datetime overflow with DBI ODBC setting 19th centur <jwillmore@remove.adelphia.net>
        eMailing with an extracted eMail address (Zaphod)
    Re: eMailing with an extracted eMail address <ittyspam@yahoo.com>
        Favorite Editor for Perl programming <ewijaya@singnet.com.sg>
    Re: Favorite Editor for Perl programming <postmaster@castleamber.com>
    Re: get values from the textbox in perl TK <notvalid@email.com>
    Re: get values from the textbox in perl TK <jwillmore@remove.adelphia.net>
    Re: get values from the textbox in perl TK (Steve The Geek)
    Re: get values from the textbox in perl TK <notvalid@email.com>
        IO::Socket problem <someone@somewhere.com>
    Re: IO::Socket problem <ThomasKratz@REMOVEwebCAPS.de>
        IO::socket question <mysympatico001@sympatico.ca>
    Re: Password scheme/Persistent session... (krakle)
    Re: Password scheme/Persistent session... (Anno Siegel)
    Re: Password scheme/Persistent session... <jwillmore@remove.adelphia.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 14 May 2004 11:18:25 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Datetime overflow with DBI ODBC setting 19th century dates with placeholders
Message-Id: <pan.2004.05.14.15.18.23.72592@remove.adelphia.net>

On Fri, 14 May 2004 08:29:41 +0100, iain wrote:

> 
> "James Willmore" <jwillmore@remove.adelphia.net> wrote in message
> news:pan.2004.05.14.04.44.19.763862@remove.adelphia.net...
>> > $sth->execute('1900-01-01');  # works OK
>> > $sth->execute('1799-12-31');  # gives error
>>
>> First ... try to insert the date using the command line utility for the
>> RDBMS.  If it works, then it *should* work in the script.  If it doesn't,
>> then the issue lies with the RDBMS.
>>
>> Next, you could use the 'debug' function in the DBI module to see what the
>> "conversation" is between the script and the database.  That will shed
>> some light on why it's not working as expected.
>>
>> There are more ideas, but give these a try first :-)

> 
> Thanks for the suggestion, but I've tried both those - $dbh->trace(5) shows
> the date is passed to SQL Server ODBC driver in the same way for both 1901
> and 1799.
> BTW - I meant to show 1899 not 1799 in my original post - neither work
> anyway.
> The command line utility (SQL Query) only allows you to use complete SQL DML
> statements, not placeholders with parameters (as far as I know).  And the
> former works fine for 1899 with perl DBI anyway.
> 
> It seems to be something to do with ODBC not binding the date parameter
> correctly when it would be held as a negative number on the database.
> 
> I've also tried the SQL Server profiler on the server side, but haven't got
> it to show sufficient detail for
> this kind of update.

One more thing to try - you could tell the server what kind of data you're
using.  After reading Brian's post and the issue he had, it occured to me
that you could try using the 'bind_param' function to set the type of data
being used.  Not quite as easy as the sample you posted, but may fix the
issue.

For example (untested and off top of head):

use DBI qw(:sql_types);

$sth = $dbh->prepare(<<SQL);
insert into table (date, ...) values(?, ...)
SQL

$sth->bind_param(1, $date, SQL_DATE);
 ...

$sth->execute();

In this way, you're defining what the data type is for the database, not
letting it try and figure it out for itself (which may be what it's trying
to do).

Again, just something to try and may not work.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
 The 80's -- when you can't tell hairstyles from chemotherapy. 
 
 


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

Date: 14 May 2004 08:36:11 -0700
From: zaphod@earthling.net (Zaphod)
Subject: eMailing with an extracted eMail address
Message-Id: <fabcf423.0405140736.78f2e239@posting.google.com>

I have customers uploading info to a web site via a cgi script 
which has been eMailing me whenever there is an error during
the process of inserting the data in the uploaded file in to the
data base.

The uploaded file is a CSV file and always contains the senders 
email address as the last entry on the second line of the file.

I am trying to make the script eMail the sender when these
errors happen also. However I can't seem to get the script
to send the eMail with the address I extract from the CSV 
file into a variable. If I explicitly assign an address to the
same variable the eMail will send fine.

Here is my very simplified testing file as an example, and a 
bit more explanation;

#!/usr/bin/perl

$| = 1;

use CGI qw/:all/;
use CGI::Pretty qw( :html3 );
use CGI::Carp qw/fatalsToBrowser/;
$CGI::Pretty::INDENT = "  ";
require "./Library/mail-lib.pl";

open("INDATA","<./Data_files/emailtest.lds.txt");

# read in the CSV file
@templines = <INDATA>;

# isolate second line of the file
$tempdata = $templines[1];
close (INDATA);

# find last \t in isolated line
$lasttab=rindex $tempdata, "\t";

# extract address from end of line
$emailaddress=substr($tempdata,$lasttab);

# escape the @
$emailaddress=~s/@/\\@/g; 

# remove leading spaces
$emailaddress=~s/^\s+//;   

# remove trailing spaces
$emailaddress=~s/\s+$//;   

# print message to browser to ensure address has
# been cleaned up properly
$messagetext .= "The Email address is: |$emailaddress|";
print header,start_html(-title=>$title),basefont({-size=>4}),$messagetext;

# attempt to send eMail titled "Test # 1"  to extracted address
&send_mail("TEST\@truckload2000.com","$emailaddress","Test # 1","$messagetext");

# explicitly assign very same address to the very same variable
$emailaddress= "zaphod\@truckload2000.com";

# attempt to send eMail titled "Test # 2" to very same address
&send_mail("TEST\@truckload2000.com","$emailaddress","Test # 2","$messagetext");


Ok, when this script is run from a browser, it produces the
Following output to the browser;

The Email address is: |zaphod\@truckload2000.com|

The first attempted eMail  named  "Test # 1" never arrives.

The second attempted eMail  named  "Test # 2" arrives just fine.




Thank you for any light you might be able to shed on My mistake!
Zaphod


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

Date: Fri, 14 May 2004 11:57:35 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: eMailing with an extracted eMail address
Message-Id: <20040514115253.K15402@dishwasher.cs.rpi.edu>

On Fri, 14 May 2004, Zaphod wrote:

> I am trying to make the script eMail the sender when these
> errors happen also. However I can't seem to get the script
> to send the eMail with the address I extract from the CSV
> file into a variable. If I explicitly assign an address to the
> same variable the eMail will send fine.
>
> Here is my very simplified testing file as an example, and a
> bit more explanation;
>
> #!/usr/bin/perl

<snip>
> # escape the @
> $emailaddress=~s/@/\\@/g;

Don't do this.  This is (most likely) the source of your problem.  You are
not supposed to escape @ contained in existing strings.  @ are to be
escaped ONLY in double-quoted string literals.  That is, strings that are
actually typed into the source code.  This is to prevent the
double-quoting interpolation from thinking of @ as the beginning of an
array.  A string that already contains a real @ should *not* be modified.

> # explicitly assign very same address to the very same variable
> $emailaddress= "zaphod\@truckload2000.com";

*This* is correct.  Although it would be better/easier to write:
$emailaddress = 'zaphod@truckload2000.com';
That way, you see there is no reason to backslash the @ here either, as it
is only necessary in double quoted string literals.

> # attempt to send eMail titled "Test # 2" to very same address
> &send_mail("TEST\@truckload2000.com","$emailaddress","Test # 2","$messagetext");

Again, if you replaced the " with ', you wouldn't need to escape the @.
(unrelated, why are you calling send_mail with an &?  And why the useless
quotes around $emailaddress and $messagetext?)

>
>
> Ok, when this script is run from a browser, it produces the
> Following output to the browser;
>
> The Email address is: |zaphod\@truckload2000.com|
>
> The first attempted eMail  named  "Test # 1" never arrives.
>
> The second attempted eMail  named  "Test # 2" arrives just fine.

If you printed out the email address for the last two, you'd see the
difference.


Paul Lalli


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

Date: Sat, 15 May 2004 00:48:14 -0000
From: Edward Wijaya <ewijaya@singnet.com.sg>
Subject: Favorite Editor for Perl programming
Message-Id: <opr70m6oxluj0cst@news.singnet.com.sg>


In unix/linux environment.

Is X(Emacs) better than vi(M)?
How does one fare to another?
Or there is other better choice?

Regards
Edward WIJAYA
SINGAPORE



-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/


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

Date: Fri, 14 May 2004 12:19:53 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Favorite Editor for Perl programming
Message-Id: <40a4ffbc$0$207$58c7af7e@news.kabelfoon.nl>

Edward Wijaya wrote:

> 
> In unix/linux environment.
> 
> Is X(Emacs) better than vi(M)?

Editor war?

> How does one fare to another?
> Or there is other better choice?

I used NEdit a lot (IRIX and Linux).
http://www.nedit.org/

besides vi(m). I think you should at least learn either Emacs or vi(m), 
without X :-D.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                            personal page:       http://johnbokma.com/
    Experienced Perl programmer available:     http://castleamber.com/


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

Date: Fri, 14 May 2004 14:52:39 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: get values from the textbox in perl TK
Message-Id: <X25pc.8288$Wr3.911@newssvr27.news.prodigy.com>

maami wrote:
> Hai
>   I want  to  get the values from the text box when u typed it in the  
> run time.
> how to get the values and how to put the same in the another same text.

The get() and insert() methods are described in the Tk::Text pods.

--Ala



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

Date: Fri, 14 May 2004 11:24:10 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: get values from the textbox in perl TK
Message-Id: <pan.2004.05.14.15.24.08.634240@remove.adelphia.net>

On Fri, 14 May 2004 04:53:45 -0400, maami wrote:

>   I want  to  get the values from the text box when u typed it in the  
> run time.
> how to get the values and how to put the same in the another same text.

In a web form or Tk interface or Curses interface or ....
"textbox" could mean almost anything.

And why have you not used Google to search for the answer?  I bet this
trivial task has been done before and the answer is waiting for you - out
there - on ye olde Internet :-)

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
 If God didn't mean for us to juggle, tennis balls wouldn't come 
 three to a can. 
 


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

Date: 14 May 2004 08:30:22 -0700
From: slkleine@hotmail.com (Steve The Geek)
Subject: Re: get values from the textbox in perl TK
Message-Id: <863f122c.0405140730.7a0656f@posting.google.com>

"maami" <velu_jayashree@yahoo.com> wrote in message news:<4f4ee4efdf43ef4b0f0cf89ada21416f@localhost.talkaboutprogramming.com>...
> Hai
>   I want  to  get the values from the text box when u typed it in the  
> run time.
> how to get the values and how to put the same in the another same text.
> 
> regards,
> Jayashree

Pasted from working code, where the userID of a client needs to be entered:

my $entryUserName = $mw->Entry(
  -textvariable=>\my $UserName,
  -font => "Arial12")
  ->pack(-anchor=>'n',-fill=>'x');

Steve the (Perl/tk n00b) Geek


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

Date: Fri, 14 May 2004 17:42:15 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: get values from the textbox in perl TK
Message-Id: <Xx7pc.67199$P35.66271@newssvr25.news.prodigy.com>

Steve The Geek wrote:

> "maami" <velu_jayashree@yahoo.com> wrote in message news:<4f4ee4efdf43ef4b0f0cf89ada21416f@localhost.talkaboutprogramming.com>...
> 
>>Hai
>>  I want  to  get the values from the text box when u typed it in the  
>>run time.
>>how to get the values and how to put the same in the another same text.
>>
>>regards,
>>Jayashree
> 
> 
> Pasted from working code, where the userID of a client needs to be entered:
> 
> my $entryUserName = $mw->Entry(
>   -textvariable=>\my $UserName,
>   -font => "Arial12")
>   ->pack(-anchor=>'n',-fill=>'x');

That's an Entry widget. The OP's question wasn't specific enough, but I 
think he meant a Text wiget instead, although I have heard "textbox" 
being used to refer to either of them.

--Ala


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

Date: Fri, 14 May 2004 16:21:27 +0100
From: "Bigus" <someone@somewhere.com>
Subject: IO::Socket problem
Message-Id: <c82o5o$sk2@newton.cc.rl.ac.uk>

I have a script that connects to a mailing list server to execute commands.
The code is:

====================
use strict;
use warnings;
my $email = "blah\@blah.com";
my $cmd = "some command";

# Connect to Listserv
use IO::Socket;
my $lsv = new IO::Socket::INET( PeerAddr => 'localhost',
    PeerPort => 2306,
    Proto => 'tcp');
$lsv or die "Connection problem :$!";

# Send command header & check return code
my $len = length($email)+length($cmd)+1;
my $bin =
pack("a*CCCa*","\r\n",int($len/256),$len-(int($len/256)*256),length($email),
$email);
$lsv->print("1B".$bin);
my $msg = $lsv->getline;
exit if $msg !~ /^250/;

# Send command
$lsv->print("$cmd\n");
my @lines = $lsv->getlines;
print "@lines";

# Close socket
close $lsv;
====================

The "send command" block is the bit I'm having problems with. The response
from the server, to the command I'm issuing, results in multiple lines so
I'm trying to catch it with the $lsv->getlines method into an array.
However, the cursor just hangs and nothing is printed. If I change the "send
command" block to:

# Send command
$lsv->print("$cmd\n");
while(my $line = $lsv->getline){
     print $line;
}

That works to the extent that all the expected lines are printed but the
script seems to get stuck in the while. In others it hangs at the end of the
command response. If I stick a:

    last if eof($line);

line into the while loop after the print line, it prints *only* the first
line of the command output and then exits properly.

I've been trying all sorts of things and surfing around for hours now, so am
beginning to tear my hair out. So, any solutions would be much appreciated.

Regards
Bigus



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

Date: Fri, 14 May 2004 18:13:30 +0200
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: IO::Socket problem
Message-Id: <40a4f19e.0@juno.wiesbaden.netsurf.de>

Bigus wrote:

[...]

> 
> The "send command" block is the bit I'm having problems with. The response
> from the server, to the command I'm issuing, results in multiple lines so
> I'm trying to catch it with the $lsv->getlines method into an array.
> However, the cursor just hangs and nothing is printed. If I change the "send
> command" block to:
> 
> # Send command
> $lsv->print("$cmd\n");
> while(my $line = $lsv->getline){
>      print $line;
> }
> 
> That works to the extent that all the expected lines are printed but the
> script seems to get stuck in the while. In others it hangs at the end of the
> command response. 

That's because you call $lsv->getline one time to often and it blocks, 
because there is nothing to read anymore.

> If I stick a:
> 
>     last if eof($line);
> 
> line into the while loop after the print line, it prints *only* the first
> line of the command output and then exits properly.

eof($line)? Surely you mean $lsv->eof(), don't you. But this should also 
block because in checking for eof you still have to read from the socket.

Have a look at IO::Select and the can_read() method. You will be able to 
tell if a subsequent read will be successfull or not.

Getting eof after a safe read on the socket will tell you that the socket 
has been closed.

Also have a look at the connected() method of IO::Socket and the 
has_exception() method of IO::Select for checking the status for the 
socket connection.

Thomas


-- 
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</  #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..


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

Date: Fri, 14 May 2004 13:30:16 -0400
From: "B. W." <mysympatico001@sympatico.ca>
Subject: IO::socket question
Message-Id: <Jm7pc.79721$FH5.1821934@news20.bellglobal.com>

Is it possible to open a socket for loopback on win32 system?




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

Date: 14 May 2004 06:24:35 -0700
From: krakle@visto.com (krakle)
Subject: Re: Password scheme/Persistent session...
Message-Id: <237aaff8.0405140524.55308101@posting.google.com>

Thank you. However, the whole point to my post was to see if I could
do a session with out cookies...


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

Date: 14 May 2004 13:39:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Password scheme/Persistent session...
Message-Id: <c82i7e$n92$1@mamenchi.zrz.TU-Berlin.DE>

krakle <krakle@visto.com> wrote in comp.lang.perl.misc:
> Thank you. However, the whole point to my post was to see if I could
> do a session with out cookies...

 ...which is way off topic for clpm.  Why ask that here?

Anno


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

Date: Fri, 14 May 2004 11:20:57 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Password scheme/Persistent session...
Message-Id: <pan.2004.05.14.15.20.56.237532@remove.adelphia.net>

On Fri, 14 May 2004 06:24:35 -0700, krakle wrote:

> Thank you. However, the whole point to my post was to see if I could
> do a session with out cookies...

I don't see how you can.

You could try posting this question to a CGI newsgroup -or- using Google
to see what others have done.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
 Once, adv.:  Enough.   -- Ambrose Bierce, "The Devil's
 Dictionary" 
 


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

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 V10 Issue 6563
***************************************


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