CGI problem
Note: forwarded message attached.Do you Yahoo!? New DSL Internet Access from SBC & Yahoo!---BeginMessage--- Hi. This is the qmail-send program at onion.perl.org. I'm afraid I wasn't able to deliver your message to the following addresses. This is a permanent error; I've given up. Sorry it didn't work out. [EMAIL PROTECTED]: ezmlm-reject: fatal: Sorry, I don't accept message with empty Subject (#5.7.0) --- Below this line is a copy of the message. Return-Path: [EMAIL PROTECTED] Received: (qmail 15664 invoked by uid 76); 2 Oct 2002 12:39:52 - Received: from web13003.mail.yahoo.com (HELO web13003.mail.yahoo.com) (216.136.174.13) by onion.perl.org (qpsmtpd/0.11-dev) with SMTP; 2002-10-02 12:39:52Z Message-ID: [EMAIL PROTECTED] Received: from [80.247.147.25] by web13003.mail.yahoo.com via HTTP; Wed, 02 Oct 2002 05:39:51 PDT Date: Wed, 2 Oct 2002 05:39:51 -0700 (PDT) From: Yahaya Mohammed [EMAIL PROTECTED] To: [EMAIL PROTECTED] MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=0-1054349745-1033562391=:15960 X-SMTPD: qpsmtpd/0.11-dev, http://develooper.com/code/qpsmtpd/ --0-1054349745-1033562391=:15960 Content-Type: text/plain; charset=us-ascii Hi, Iam a novice in programming CGI with perl, Iam curently learning on how to send form fields to a cgi script for processing and return the processed fields to a client browser. I used many codes example I found internet but failed to work by giving me blank screen. Here is the code I used my(%frmFlds); getFormData(\%frmFlds); sub getFormData { my($hashRef) = shift; my($buffer) = ; if ($ENV{'REQUEST_METHOD'} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } foreach (split(//, $buffer)) { my($key, $value) = split(/=/, $_); $key = decodeURL($key); $value = decodeURL($value); %{$hashRef}-{$key} = $value; } } foreach (sort (keys (%hashRef))) { print $_: $hashRef{$_}br\n; } sub decodeURL { $_ = shift; tr/+/ /; s/%(..)/pack('c', hex($1))/eg; return($_); } Please assist. - Do you Yahoo!? Yahoo! News - Today's headlines --0-1054349745-1033562391=:15960 Content-Type: text/html; charset=us-ascii PHi,/P PIam a novice in programming CGI with perl, Iam curently learning on how to send form fields to a cgi script for processing and return the processed fields to a client browser. I used many codes example I found internet but failed to work by giving me blank screen. Here is the code I used/P Pmy(%frmFlds);BRBRgetFormData(\%frmFlds);BRBRsub getFormData {BRnbsp;nbsp;nbsp; my($hashRef) = shift;BRnbsp;nbsp;nbsp; my($buffer) = ;BRBRnbsp;nbsp;nbsp; if ($ENV{'REQUEST_METHOD'} eq 'GET') {BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; $buffer = $ENV{'QUERY_STRING'};BRnbsp;nbsp;nbsp; }BRnbsp;nbsp;nbsp; else {BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});BRnbsp;nbsp;nbsp; }BRBRnbsp;nbsp;nbsp; foreach (split(/amp;/, $buffer)) {BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; my($key, $value) = split(/=/, $_);BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; $keynbsp;nbsp; = decodeURL($key);BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; $value = decodeURL($value);BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; %{$hashRef}-gt;{$key} = $value;BRnbsp;nbsp;nbsp; }BR}BRBRforeach (sort (keys (%hashRef))) {/P Pnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; print $_:nbsp;nbsp;nbsp;nbsp; $hashRef{$_}lt;brgt;\n;/P P}/P Pnbsp;/P Psub decodeURL {BRnbsp;nbsp;nbsp; $_ = shift;BRnbsp;nbsp;nbsp; tr/+/ /;BRnbsp;nbsp;nbsp; s/%(..)/pack('c', hex($1))/eg;BRnbsp;nbsp;nbsp; return($_);BR}/P PPlease assist./TT/Ppbrhr size=1Do you Yahoo!?br ba href=http://news.yahoo.com/;Yahoo! News/a/b - Today's headlines --0-1054349745-1033562391=:15960-- ---End Message--- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: no shell account
On Tue, 1 Oct 2002 21:56:31 -0700 (PDT), [EMAIL PROTECTED] (Patricia Hinman) wrote: Hi everyone, It's my first day studying sockets. I'm having trouble getting the script on my server to initialize itself because I don't have a shell account for my website. Can I initialize the Socket on the server side from a cgi script on my machine? Here's my code. Probably not. If you have an account on a remote server for web page hosting, then they probably block you from opening ports. Write an email to your sysadmin if you really need to do this. On a remote server, with maybe a thousand or more users, everyone would be constantly fighting over ports to use. If you just want to practice with the script, use you own machine. LocalHost = 'localhost' or you will need to find someone who will give you a real user account on their machine. #!/usr/bin/perl BEGIN{open(STDERR,./errsocket.txt);} use CGI header; print header; use IO::Socket; $sock = new IO::Socket::INET ( LocalHost = 'www.websiteprogrammin.com', LocalPort = 1200, Proto = 'tcp', Listen= 5, Reuse = 1 ); print Socket could not be created. Reason: $! unless $sock; open (FILE, $file) || print \nCouldn't open $file to write socket input.$!; while ($new_sock = $sock-accept()) { while (defined ($buf = $new_sock)) { print FILE $buf; } } close ($sock); close (FILE); __ Do you Yahoo!? New DSL Internet Access from SBC Yahoo! http://sbc.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cookies
I find wih IE alot of the times when you specify a domain it can be very glitchy... Trevor Wilkes - Original Message - From: Robin Cragg [EMAIL PROTECTED] To: 'aman cgiperl' [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, October 02, 2002 11:04 AM Subject: RE: cookies Hi Aman, I've had exactly the same problem. I strongly suspect it's an IE thing. I've not found a way round it other than looking at the HTTP_REFERER and removing cookies from pages that had not come from my site. R -Original Message- From: aman cgiperl [mailto:[EMAIL PROTECTED]] Sent: 02 October 2002 14:27 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: cookies Hi all I need to set a cookie which expires when the browser is closed. I am not using CGI.pm My earlier query for the same for responded by telling that if I am using CGI.pm, I can do so by omitting the expiry date, but if I do so, when I do print Set-Cookie: cart=$cart domain=.domain.com\n; the cookie does not get set at all. Thanks for suggestions in advance. Aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: setting curser position (focus)
Thank you, it worked like magic. I'll have to read my Javascript book now so I know what it means. Maureen -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 01, 2002 12:11 PM To: 'Maureen E Fischer'; [EMAIL PROTECTED] Subject: RE: setting curser position (focus) -Original Message- From: Maureen E Fischer [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 01, 2002 1:13 PM To: [EMAIL PROTECTED] Subject: setting curser position (focus) I am trying to figure out how to get the curser to sit at the first entry field so the user doesn't have to position it. After your /FORM tag, add the following: script language=javascript defer=defer document.forms[0].elements[0].focus() /script (If there are multiple forms, use the appropriate form number instead of 0). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Net::POP3
If I am understanding correctly you should be able to just look for the first blank line following the header. This is part of the SMTP spec, the header is always concluded with a blank line that signifies it is ending and the actual message is beginning. http://danconia.org [EMAIL PROTECTED] wrote: I wrote a script with Net::POP3. Right now, it gets the message by counting the lines in the header and getting rid of them in the total message. It's a dopey way to do it. Anyone know a better way to get the message by itself still using the Net::POP3 Module? God Bless, Will -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Has Perl extra memory!?
Eureka! In fact I tried every method, but, as the examples didn't really correspond to my problem, I don't know if I did it well. Anyway nothing worked! I talked with one of my friend who finally explained me he had been confronted to the same problem. At the beginning of my script I had written my $cgi = CGI - new; and the solution was to put our $cgi = CGI - new;. Anyway thank you for your help, I have learn some interesting things. Ti Bruno - Original Message - From: Bob Showalter [EMAIL PROTECTED] To: 'Damien Delhomme' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, October 01, 2002 9:05 PM Subject: RE: Has Perl extra memory!? -Original Message- From: Damien Delhomme [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:45 AM To: [EMAIL PROTECTED] Subject: Has Perl extra memory!? Hi everybody! One of my program generates a HTML formulary whose number of checkboxes fluctuates (they are named mod_0, mod_1, mod_2, mod_3...etc). Therefore I need a loop in my other program which has to read the formulary : my $count ; for ($count=0; $count = $num; $count++) { my $mod = $cgi-param(mod_.$count) ? $cgi-param(mod_.$count) : ; if ($mod ne ) .etc ($num is the number (-1) of checkboxes and it is stocked in a hidden inputin the Web page) Unfortunately it seems that Perl memorises the values of these $mod_i and doesn't always execute the script with the values that are given to it!! I have tried differents ways of declaring these parameters (our, my, local, outside or inside the loop...etc) and there has always been the same problem. Basically the first formulary you fill is well executed, and after that there is no way to tell when it'll start to bug! Sometimes it executes the formulary you have filled three or four times before! I hope someone could help me with this, this problem is poisoning my programs! Read here: http://perl.apache.org/docs/1.0/guide/porting.html#Exposing_Apache__Registr y_secrets Short rule of thumb I have devised to avoid this problem: Anywhere you have a file-scoped lexical in your script, like my $foo; Change that declaration to: our $foo; local $foo; This only applies to file-scoped lexicals. my variables declared inside subs or blocks are fine. For details on why this happens and why changing it to a global fixes the problem, read the mod_perl guide. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Saving CGI session to DB
Hello, How can I save a CGI session to a db. I have only seen an example to a filehandle in the documentation. $query-save(FILEHANDLE) Thanks. --Kevin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cookies
Hi all I need to set a cookie which expires when the browser is closed. I am not using CGI.pm My earlier query for the same for responded by telling that if I am using CGI.pm, I can do so by omitting the expiry date, but if I do so, when I do print Set-Cookie: cart=$cart domain=.domain.com\n; the cookie does not get set at all. Thanks for suggestions in advance. Aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cookies
On Wednesday, October 2, 2002, at 08:26 AM, aman cgiperl wrote: I am not using CGI.pm I don't mean to be offensive here, but why would you not use a standard Perl module that's only purpose is to make coding CGI easier?! James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cookies
Hi Aman, I've had exactly the same problem. I strongly suspect it's an IE thing. I've not found a way round it other than looking at the HTTP_REFERER and removing cookies from pages that had not come from my site. R -Original Message- From: aman cgiperl [mailto:[EMAIL PROTECTED]] Sent: 02 October 2002 14:27 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: cookies Hi all I need to set a cookie which expires when the browser is closed. I am not using CGI.pm My earlier query for the same for responded by telling that if I am using CGI.pm, I can do so by omitting the expiry date, but if I do so, when I do print Set-Cookie: cart=$cart domain=.domain.com\n; the cookie does not get set at all. Thanks for suggestions in advance. Aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RES: cookies
I use the line: print Content-type: text/html\\nSet-Cookie: PS=$PS;\\n\\n; and it works well. []´s Ricardo
RES: cookies (FIX)
The correct line does not have double back slash. I use the line as the first line of my CGI script: print Content-type: text/html\nSet-Cookie: PS=$PS;\n\n; and it works fine. []´s Ricardo - Mensagem original - De: Ricardo Luiz Chamberline Maturana Enviada em: quarta-feira, 2 de outubro de 2002 12:38 Para: 'Robin Cragg'; 'aman cgiperl'; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Assunto: RES: cookies I use the line: print Content-type: text/html\\nSet-Cookie: PS=$PS;\\n\\n; and it works well. []´s Ricardo
mysql syntax problem
Hi all when i query a mysql db within a perl script this works fine... $sth = $dbh-prepare (SELECT venue from base1 WHERE op = 'K Trevan'); this doesn't.. $sth = $dbh-prepare (SELECT venue from base1 WHERE op = 'K O'Trevan'); i know the issue is 'K O'Trevan' in that the 2nd ' completes i just don't know how to resolve it - other than changing 'K O'Trevan' to 'K O Trevan' Any ideas appreciated Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mysql syntax problem
On Wed, Oct 02, 2002 at 09:06:16AM +0100, [EMAIL PROTECTED] wrote: when i query a mysql db within a perl script this works fine... $sth = $dbh-prepare (SELECT venue from base1 WHERE op = 'K Trevan'); this doesn't.. $sth = $dbh-prepare (SELECT venue from base1 WHERE op = 'K O'Trevan'); i know the issue is 'K O'Trevan' in that the 2nd ' completes i just don't know how to resolve it - other than changing 'K O'Trevan' to 'K O Trevan' Use placeholders: $sth = $dbh-prepare(SELECT venue FROM base1 WHERE op = ?); $sth-execute(K O'Trevan); This is a little silly with literal values, as you can easily escape them manually. It works much better with data you get from sources that won't escape it, such as user input. Read about placeholders in perldoc DBI. As for manually escaping your values, that's an SQL question, and you should read the documentation on your database for information on that. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: remove duplicate lines
This is a classic case for my favorite one-liner: perl -e'while(){print unless $seen{$_}++}' infile outfile On Wed, 02 Oct 2002 04:17:29 -0400, Sudarshan Raghavan wrote: On Fri, 27 Sep 2002, waytech wrote: hi, i want to remove duplicate lines from one file(original file), and save the result to another file. the origianl file like this: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] --- with each email address a line. I want to remove the duplicate lines(emais adresses) and save the result to a new file. I wrote a program , but it output nothing. can someome help ? Thanks a lot. kevin --- #!/usr/bin/perl -w ### #Remove the duplicate line # #from a orginal file and save # #the result to a file. # ### print Enter the file that has duplicate lines.\n; $Dupli_file=stdin; chomp; chomp by default works on $_, to chomp $Dupli_file you will have to say chomp ($Dupli_file); print The file you select is '$Dupli_file'\n; open (Dupli_file,$Dupli_file); When opening a file always check for failure like this open (Dupli_file, $Dupli_file) or die Cannot open $Dupli_file: $!\n; $! will contain the error string. For more info on $! (perldoc perlvar) print Please select the file you want to save the result to:\n; $Resu_file=stdin; chomp; chomp ($Resu_file); print The result file is $Resu_file\n; open (Resu_file,$Resu_file); Check for failure while (Dupli_file) { $orin_line=$_; while (Resu_file){ You are trying to read from a filehandle that has been opened for writing. This will throw a warning message. This logic will not work even if you open the result file for both reading and writing. If the result file is empty to start with, the execution path will never go into the while loop. while (Resu_file) will fail the first time, which means nothing gets written into Resu_file. This makes it fail again the 2'nd time, 3'rd time ... if($_ eq $orin_line) { next; } print Resu_file $orin_line; }; } } A hash is more suited for your job #!/usr/bin/perl -w use strict; chomp (my $dupli_file = STDIN); chomp (my $res_file = STDIN); open (DUPLI, $dupli_file) or die Failed to open $dupli_file: $!\n; open (RESULT, $res_file) or die Failed to open $res_file for writing: $!\n; my %res_hash; while (DUPLI) { chomp; unless ($res_hash{$_}++) { print RESULT $_\n; } } close (DUPLI); close (RESULT); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: remove duplicate lines
On Wed, 2 Oct 2002, jontn_swift wrote: This is a classic case for my favorite one-liner: perl -e'while(){print unless $seen{$_}++}' infile outfile You favourite one-liner can be even shorter perl -n -e 'print unless $seen{$_}++' infile outfile -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: remove duplicate lines
Sudarshan Raghavan wrote: On Wed, 2 Oct 2002, jontn_swift wrote: This is a classic case for my favorite one-liner: perl -e'while(){print unless $seen{$_}++}' infile outfile You favourite one-liner can be even shorter perl -n -e 'print unless $seen{$_}++' infile outfile You want short? :-) perl -ne'$s{$_}++||print' infile outfile John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mysql syntax problem
Michael Excellent - read DBI/placeholder thanks Michael Fowler michael@shoebox To: [EMAIL PROTECTED] .netcc: [EMAIL PROTECTED] Subject: Re: mysql syntax problem 10/02/02 09:33 AM On Wed, Oct 02, 2002 at 09:06:16AM +0100, [EMAIL PROTECTED] wrote: when i query a mysql db within a perl script this works fine... $sth = $dbh-prepare (SELECT venue from base1 WHERE op = 'K Trevan'); this doesn't.. $sth = $dbh-prepare (SELECT venue from base1 WHERE op = 'K O'Trevan'); i know the issue is 'K O'Trevan' in that the 2nd ' completes i just don't know how to resolve it - other than changing 'K O'Trevan' to 'K O Trevan' Use placeholders: $sth = $dbh-prepare(SELECT venue FROM base1 WHERE op = ?); $sth-execute(K O'Trevan); This is a little silly with literal values, as you can easily escape them manually. It works much better with data you get from sources that won't escape it, such as user input. Read about placeholders in perldoc DBI. As for manually escaping your values, that's an SQL question, and you should read the documentation on your database for information on that. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: remove duplicate lines
John W. Krahn wrote: Sudarshan Raghavan wrote: On Wed, 2 Oct 2002, jontn_swift wrote: This is a classic case for my favorite one-liner: perl -e'while(){print unless $seen{$_}++}' infile outfile You favourite one-liner can be even shorter perl -n -e 'print unless $seen{$_}++' infile outfile You want short? :-) perl -ne'$s{$_}++||print' infile outfile Or if you want something a bit more obfuscated. perl -pe'$+{$_}++y+++cd' infile outfile perl -pe'$s{$_}++s{.+}$$s' infile outfile :-) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
size of a process in memory
Hi all! I'm new in perl, and I'm a little lost. I want to find something, perl module, function, site to find it, ..., that return me the size of a process in memory. I've the pid of the process and need to now the size. If possible, I need that work in Unix, Linux and windows. Thanks in advance Ana -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: remove duplicate lines
On Wed, 2 Oct 2002, John W. Krahn wrote: John W. Krahn wrote: Sudarshan Raghavan wrote: On Wed, 2 Oct 2002, jontn_swift wrote: This is a classic case for my favorite one-liner: perl -e'while(){print unless $seen{$_}++}' infile outfile You favourite one-liner can be even shorter perl -n -e 'print unless $seen{$_}++' infile outfile You want short? :-) perl -ne'$s{$_}++||print' infile outfile Or if you want something a bit more obfuscated. perl -pe'$+{$_}++y+++cd' infile outfile perl -pe'$s{$_}++s{.+}$$s' infile outfile Thanks for that :-), learnt a couple of things in the process of understanding the second one. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: remove duplicate lines
On Wed, 2 Oct 2002, Sudarshan Raghavan wrote: On Wed, 2 Oct 2002, John W. Krahn wrote: John W. Krahn wrote: Sudarshan Raghavan wrote: On Wed, 2 Oct 2002, jontn_swift wrote: This is a classic case for my favorite one-liner: perl -e'while(){print unless $seen{$_}++}' infile outfile You favourite one-liner can be even shorter perl -n -e 'print unless $seen{$_}++' infile outfile You want short? :-) perl -ne'$s{$_}++||print' infile outfile Or if you want something a bit more obfuscated. perl -pe'$+{$_}++y+++cd' infile outfile perl -pe'$s{$_}++s{.+}$$s' infile outfile Thanks for that :-), learnt a couple of things in the process of understanding the second one. At the risk of incurring the wrath of the list admin :-), to obfuscate the second one a little more perl -pe'$s{$_}++s{$_}++' infile outfile -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Question about Mime::types
I 'm trying to make a program to handle mailing within our department. The program asks a bunch of questions about the message to be sent, reads the body for a text or html file, then looks up people's e-mail addresses in a database, and uses Net::SMTP to loop over the results of that query and send the message to them. So far, so good. Now, I need to add attachments to these messages. Here's where I run into trouble. I think I've got a handle on MIME::Lite, but I need to find out what type of attachment they are sending, so I am using MIME::Types to try to figure that out. However, I keep getting the following error: illegal MIME: can't have encoding base64 with type multipart/mixed Here's what my code looks like (I've taken out the querying stuff and am just using myself as a test message until I get it right): use DBI;### Call the DBI module. We need this to get the addresses. use Net::SMTP; ### Call the Net::SMTP module. We need this to send the message. use MIME::Lite; ### Call the MIME::Lite module. We need this if we're to have attachments. use MIME::Types qw(by_suffix);### Call the MIME::Types module. We need this to figure out what we're sending. print What should I use for a return address?\n; chomp(my $return = STDIN); print Where's the file that is the body of the message?\n; chomp(my $body = STDIN); print Is this message HTML formatted? (type Y or N)\n; chomp(my $html = STDIN); print Do you want to add an attachment? (type Y or N)\n; chomp(my $atyn = STDIN); if ($atyn =~ m/Y/i){ print What is the path to the attachment?\n; chomp(my $attach = STDIN); } print What would you like to use as a subject?\n; my $subject = STDIN; print Are you sure that you have entered the addresses into the database?\n(type Y to go on or N to quit)\n; chomp(my $conf = STDIN); exit if ($conf =~ m/N/i); my $message = ; open(BODY, $body); while (BODY){ $message = $message . $_; } if ($atyn =~ m/Y/i){ my ($atmt, $atenc) = by_suffix($attach); print Mime Type of Attach: $atmt \nEncoding: $atenc\n; } my $mimetype = Content-type\: text\/PLAIN\n; if ($atyn =~ m/Y/i){ $mimetype = multipart/mixed\n; }elsif (html =~ m/Y/i){ $mimetype = text/html\n; } $mtype = TEXT; if ($html =~ m/Y/i){ $type1 = HTML; } my $testadd = '[EMAIL PROTECTED]'; $msg = new MIME::Lite From=$return, To =$testadd, CC =, Subject =$subject, Type=$mimetype; attach $msg type=$mtype, Data=Hello. I am Aaron's Simple Mailer Program. If this message is as you want it to appear, let him know so that he can send the rest of them.\n\n-=-=-=-=-=-=-=-=Begin Test Message Below=-=-=-=-=-=-=-=-=-=-\n $message; if ($atyn =~ m/Y/i){ attach $msg type=$atmt, path='d:\pfe\attach.txt'; } MIME::Lite-send('smtp', smtp.service.ohio-state.edu, Timeout=60); $msg-send; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: remove duplicate lines
Sudarshan Raghavan wrote: On Wed, 2 Oct 2002, Sudarshan Raghavan wrote: On Wed, 2 Oct 2002, John W. Krahn wrote: John W. Krahn wrote: Sudarshan Raghavan wrote: On Wed, 2 Oct 2002, jontn_swift wrote: This is a classic case for my favorite one-liner: perl -e'while(){print unless $seen{$_}++}' infile outfile You favourite one-liner can be even shorter perl -n -e 'print unless $seen{$_}++' infile outfile You want short? :-) perl -ne'$s{$_}++||print' infile outfile Or if you want something a bit more obfuscated. perl -pe'$+{$_}++y+++cd' infile outfile perl -pe'$s{$_}++s{.+}$$s' infile outfile Thanks for that :-), learnt a couple of things in the process of understanding the second one. At the risk of incurring the wrath of the list admin :-), to obfuscate the second one a little more perl -pe'$s{$_}++s{$_}++' infile outfile Very nice. Unfortunately that regex will not work if there are certain special characters in $_. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to use 'open'
umm.. I think you want to look at DBI or Win32::OLE perldoc DBI perldoc Win32::OLE -Original Message- From: Cacialli, Doug [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 01, 2002 5:57 PM To: '[EMAIL PROTECTED]' Subject: how to use 'open' Lo, I apologize if this request is less than coherent. I'm running Win XP Pro using Perl 5.6.1. I'd like to do this: open (ACCESSDB, | C:\\Documents\ and\ Settings\\Doug\ Cacialli\\Desktop\\TEST DATABASE.mdb) or die Something is amiss: $! \n; Which starts Access, and requires the user to enter a password, which I would do: print ACCESSDB password\n; close (ACCESSDB); At which point Access would open up the database, and I could go on to live my happy life, frolicking around, doing cartwheels, whatnot. The problem seems to be that when Perl gets to that initial open function, it hangs because it can't really open the database (which is really what I'm asking it to do there) without the password. It never gets to the print. And of course, there's no frolicking or cartwheels. Does anyone know how I can get around this? Is there someway to use the open function without having Perl wait and see what happens? Does anyone know of a better way to do this? Any help would be great! Doug out. --- Douglas Cacialli - Data Manager / Data Analyst Sleep and Depression Research Laboratory University of Rochester Medical Center 300 Crittenden Blvd. - Box PSYCH Rochester, New York 14642 Phone: (585)273-3309 Fax: (585)506-0287 NOTE NEW FAX NUMBER --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hi! I need to be able to read incoming e-mail break down it's contents, input this data into an oracle table, do some numbers based on this data. Then generate a new e-mail and send it back. The only part that is new to me here is the e-mail. What is the best and or easiest way to deal with e-mail and to get started? I have seen comments based on CPAN, Net::SMTP, MIME, Net::POP3 etc. What do I need to read? Thanks, Jerry
Re: e-mail
I usually suggest MIME::Parser for breaking up emails in to nice seperate parts. See if that fits your needs. As for fetching the mail, look at one of the POP modules, or Mail::IMAPClient or Mail::Cclient if you use IMAP. Cheers, Kevin On Wed, Oct 02, 2002 at 07:34:39AM -0500, Jerry Preston ([EMAIL PROTECTED]) said something similar to: Hi! I need to be able to read incoming e-mail break down it's contents, input this data into an oracle table, do some numbers based on this data. Then generate a new e-mail and send it back. The only part that is new to me here is the e-mail. What is the best and or easiest way to deal with e-mail and to get started? I have seen comments based on CPAN, Net::SMTP, MIME, Net::POP3 etc. What do I need to read? Thanks, Jerry -- [Writing CGI Applications with Perl - http://perlcgi-book.com] If you were going to shoot a mime, would you use a silencer? -- Steven Wright -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: e-mail
I think you answered your own question :-) NET::POP3 to deal with the incoming mail and Net:SMTP to process the outgoing mail. Can also look at Mime::Lite -Original Message- From: Jerry Preston [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 8:35 AM To: Beginners Perl Subject: e-mail Hi! I need to be able to read incoming e-mail break down it's contents, input this data into an oracle table, do some numbers based on this data. Then generate a new e-mail and send it back. The only part that is new to me here is the e-mail. What is the best and or easiest way to deal with e-mail and to get started? I have seen comments based on CPAN, Net::SMTP, MIME, Net::POP3 etc. What do I need to read? Thanks, Jerry -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
COUNT(*) performance
On a Mysql database of 6 records performs better : my $sth = $dbh-prepare(qq|SELECT count(id) FROM log WHERE (field1 = ? and field2= ? )|); $sth-execute( $a1, $a2 ); $total = $sth-fetchrow_array(); or my $sth = $dbh-prepare(qq|SELECT id FROM log WHERE (field1 = ? and field2= ? )|); $sth-execute( $a1, $a2 ); $total = $sth-rows; where id is a primary key field Thanks david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is there a searchable archive for this list
Hi, Thank you very much. This is exactly I was looking for. I love this list. Anidil Patinatiyil Rajendran Burlingame,California 650 730 8271 - Original Message - From: Felix Geerinckx [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, October 01, 2002 10:10 AM Subject: Re: Is there a searchable archive for this list on Tue, 01 Oct 2002 15:24:40 GMT, Anidil Rajendran wrote: I dont find any search option in following site http://archive.develooper.com/beginners%40perl.org/ Try http://groups.google.com/advanced_group_search?group=perl.beginners -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: COUNT(*) performance
From: Davide Copelli [EMAIL PROTECTED] On a Mysql database of 6 records performs better : my $sth = $dbh-prepare(qq|SELECT count(id) FROM log WHERE (field1 = ? and field2= ? )|); $sth-execute( $a1, $a2 ); $total = $sth-fetchrow_array(); or my $sth = $dbh-prepare(qq|SELECT id FROM log WHERE (field1 = ? and field2= ? )|); $sth-execute( $a1, $a2 ); $total = $sth-rows; where id is a primary key field It's always better to do as much as possible as near to the data as possible. Besides ... if you really need to know ... why don't you benchmark it? Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: COUNT(*) performance
-Original Message- From: Davide Copelli [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 8:58 AM To: [EMAIL PROTECTED] Subject: COUNT(*) performance On a Mysql database of 6 records performs better : my $sth = $dbh-prepare(qq|SELECT count(id) FROM log WHERE (field1 = ? and field2= ? )|); $sth-execute( $a1, $a2 ); $total = $sth-fetchrow_array(); or my $sth = $dbh-prepare(qq|SELECT id FROM log WHERE (field1 = ? and field2= ? )|); $sth-execute( $a1, $a2 ); $total = $sth-rows; The latter will not work. $sth-rows will not have a meaningful value until you've fetched the data. Given that, the first method is almost certainly the most efficient. where id is a primary key field Doesn't really matter. What would affect the performance would be whether indexes are available on field1 and field2. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: mysql syntax problem
Use placeholders: Could you also use quote() for this? Ain't no blood in my body, it's liquid soul in my veins ~Roots Manuva -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Insertion and Quotes
Use placeholders and your quoting troubles will be over forever ;-) E.g.: my $sql = INSERT INTO atable VALUES (NULL, ?, ?); my $sth = $dbh-prepare($sql); $sth-execute($a_var, $another_var_with_embedded_quotes); -- felix -- I tried doing this on my last run of data but things still got shifted over by the quotes when I look at the actual data. It's kind of strange, when I run the same bit of code on some test info, it seems to work fine (nothing is shifted) but when I run it against a larger set of data, only the records that contain quotes seem to screw things up. Also, I know this is most likely a stupid question but when you do a select on the information you just stored, will the quotes mess up things if you do something like this (this is after setting up the query, preparing and then executing it) : ($field1,$field2,$field3,$field4,$field5) = $sth6-fetchrow; Jessee -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: size of a process in memory
Ana M2emarfagón wrote: Hi all! I'm new in perl, and I'm a little lost. I want to find something, perl module, function, site to find it, ..., that return me the size of a process in memory. I've the pid of the process and need to now the size. If possible, I need that work in Unix, Linux and windows. Thanks in advance Ana try: #!/usr/bin/perl -w use strict; use Proc::ProcessTable; my $t = new Proc::ProcessTable(); foreach my $p (@{$t-table}){ print $p-pid, ,$p-cmndline, ,$p-size,\n; } __END__ $p-pid gives you the process id of the process $p-cmndline gives you the command line that start the process $p-size gives you the size of the process in memory david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: COUNT(*) performance
Davide Copelli wrote: On a Mysql database of 6 records performs better : my $sth = $dbh-prepare(qq|SELECT count(id) FROM log WHERE (field1 = ? and field2= ? )|); $sth-execute( $a1, $a2 ); $total = $sth-fetchrow_array(); or my $sth = $dbh-prepare(qq|SELECT id FROM log WHERE (field1 = ? and field2= ? )|); $sth-execute( $a1, $a2 ); $total = $sth-rows; where id is a primary key field Thanks david i bet the first one will be faster especially if id is the primary key. most DBMS will be able to optimize the query to a level where it's really fast. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Insertion and Quotes
Jessee Parker wrote: I tried doing this on my last run of data but things still got shifted over by the quotes when I look at the actual data. It's kind of strange, when I run the same bit of code on some test info, it seems to work fine (nothing is shifted) but when I run it against a larger set of data, only the records that contain quotes seem to screw things up. i don't know what you mean by shifted over by the quote. does it mean everything before(or after) the quote character is chop off? can you paste a sample data of how this shifted over looks like? Also, I know this is most likely a stupid question but when you do a select on the information you just stored, will the quotes mess up things if you do something like this (this is after setting up the query, preparing and then executing it) : ($field1,$field2,$field3,$field4,$field5) = $sth6-fetchrow; no, it won't mess things up. if you get it into the DB correctly, it will come back out the way you expect it. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Insertion and Quotes
- Original Message - From: david [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, October 02, 2002 10:15 AM Subject: Re: Insertion and Quotes Jessee Parker wrote: I tried doing this on my last run of data but things still got shifted over by the quotes when I look at the actual data. It's kind of strange, when I run the same bit of code on some test info, it seems to work fine (nothing is shifted) but when I run it against a larger set of data, only the records that contain quotes seem to screw things up. i don't know what you mean by shifted over by the quote. does it mean everything before(or after) the quote character is chop off? can you paste a sample data of how this shifted over looks like? Also, I know this is most likely a stupid question but when you do a select on the information you just stored, will the quotes mess up things if you do something like this (this is after setting up the query, preparing and then executing it) : ($field1,$field2,$field3,$field4,$field5) = $sth6-fetchrow; no, it won't mess things up. if you get it into the DB correctly, it will come back out the way you expect it. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Unfortunately I already deleted the left over info in the table but I can give you an example of what is happening. Say you have the following 5 fields: ID: 1 FirstName: Jessee Jess Parker Date: 10/02/2002 Email: [EMAIL PROTECTED] Status:here So what happens after doing the insertion using placeholders, the information in the table would look like this: ID: 1 FirstName: Jessee Date: Jess Email: Parker Status:[EMAIL PROTECTED] The quotes throw off the insertion into the MySQL table. I'm using placeholders (?) when building the SQL statement and when I perform the execute I am filling in the blanks so to speak. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mysql syntax problem
On Wed, Oct 02, 2002 at 09:25:43AM -0700, nkuipers wrote: Could you also use quote() for this? Yes, $dbh-quote() can also be used for quoting strings. I generally don't suggest it because it's more awkward and makes for less readable code than placeholders. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: remove duplicate lines
John wrote: All, Hello, This is the first time I've ever seen a bunch of guys reaching for bragging rights on just how short theirs is...and to document it, too! g Then you need to check out Perl golf. :-) http://perlgolf.sourceforge.net/ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cookies
Hi all I need to set a cookie which expires when the browser is closed. I am not using CGI.pm My earlier query for the same for responded by telling that if I am using CGI.pm, I can do so by omitting the expiry date, but if I do so, when I do print Set-Cookie: cart=$cart domain=.domain.com\n; the cookie does not get set at all. Thanks for suggestions in advance. Aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cookies
On Wednesday, October 2, 2002, at 08:26 AM, aman cgiperl wrote: I am not using CGI.pm I don't mean to be offensive here, but why would you not use a standard Perl module that's only purpose is to make coding CGI easier?! James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RES: cookies
I use the line: print Content-type: text/html\\nSet-Cookie: PS=$PS;\\n\\n; and it works well. []´s Ricardo
RES: cookies (FIX)
The correct line does not have double back slash. I use the line as the first line of my CGI script: print Content-type: text/html\nSet-Cookie: PS=$PS;\n\n; and it works fine. []´s Ricardo - Mensagem original - De: Ricardo Luiz Chamberline Maturana Enviada em: quarta-feira, 2 de outubro de 2002 12:38 Para: 'Robin Cragg'; 'aman cgiperl'; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Assunto: RES: cookies I use the line: print Content-type: text/html\\nSet-Cookie: PS=$PS;\\n\\n; and it works well. []´s Ricardo