[18532] in Perl-Users-Digest
Perl-Users Digest, Issue: 700 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 14 18:10:39 2001
Date: Sat, 14 Apr 2001 15:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <987286212-v10-i700@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 14 Apr 2001 Volume: 10 Number: 700
Today's topics:
Re: New NG member - seeks a little help :) <r1ckey@home.com>
Re: New NG member - seeks a little help :) <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Re: New NG member - seeks a little help :) <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Re: New NG member - seeks a little help :) <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Re: New NG member - seeks a little help :) <r1ckey@home.com>
Re: New NG member - seeks a little help :) <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Re: PERL DBI Problem (Gwyn Judd)
perl equivalent for (char) long_var in C ? <chho@privat.utfors.se>
R: How can u group together fields and sum them up <diab.lito@usa.net>
Re: to get a PId <guillaume.3@free.fr>
YAY YAY YAY <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 14 Apr 2001 19:10:57 GMT
From: r1ckey <r1ckey@home.com>
Subject: Re: New NG member - seeks a little help :)
Message-Id: <3AD8A0FE.2D1B5FC7@home.com>
Robb Meade wrote:
>
> Hi all,
>
> Kinda new here - usually hanging out in the ASP NG's...but today I have a
> Perl problem, and desperately seek help :)
>
> I've got some pages that use ASP to do the 'work' if you like, then a Perl
> script to handle emailing needs (as my web host doesnt have CDONTS
> installed)..
>
> At the moment this does what I want it to do, but its limited to only
> sending an email to 1 user, what I need is to add some kind of file it can
> get emails from.
>
> Its to be part of an Admin section on my site (not muc there yet - save your
> time! :D)..
>
> All client details are held in a database at the moment, this I handle
> through ASP, so I'll probably be sending the email address(s) from this to
> the Perl script to send them out, or I could get them from the database,
> write them to a text file, and then use the Perl script to read from there I
> guess...anyway...below is the script I have for one user - I really dont
> know anything about Perl, I've looked at it once, but got hopelessly lost
> with all the /\& and the rest of em!
>
> I got this script partly from a book, and then it was modified a little by a
> friend...
>
> *********** BEGINS **************
>
> #!/usr/bin/perl -w
> use strict;
> use CGI qw(:all);
> use CGI::Carp qw(fatalsToBrowser);
>
> my $target="go here afterwards";
>
> sub send_mail {
>
> my $sendmail="/usr/sbin/sendmail -t -oi";
> my $comments=param("comments");
> my $from=param("email");
> my $name=param("name");
> my $to="feedback\@insertdomainnamehere.com";
> my $subject="Feedback from ** a web site **";
>
> open(MAIL, "|$sendmail") || die "Can't start sendmail: $!";
> print MAIL<<END_OF_HEADER;
> From: $from
> To: $to
> Subject: $subject
>
> The following information was submitted via the online feedback form at **
> insert name here **
>
> $name wrote :
> $comments
>
> END_OF_HEADER
>
> close(MAIL);
> }
>
> send_mail();
>
> print redirect( -url => $target );
>
> ********** ENDS *******************
>
> I dont know what it ALL does, but I can recognise certain areas, and what
> they are doing - if someone could show me what to add to read say from a
> text file more email addresses, and get the script to loop through until its
> done I'd be very greatful :)
>
> Thanks in advance for any help,
>
> Respectfully
>
> --
>
> Robb Meade
> GoofyMouse Designs
> www.goofymouse.com
Here is what I came up with. I tested the code with print statements on
Linux:
#!/usr/bin/perl -w
use strict;
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);
my $target="go here afterwards";
####################################
# new sub to retrieve mailing list #
####################################
sub send_to($)
{
my $file = shift;
my @list;
open(SEND, "< $file") or die "Could not open $file: $!";
@list = <SEND>;
close SEND;
return(@list);
}
sub send_mail {
my $sendmail="/usr/sbin/sendmail -t -oi";
my $comments=param("comments");
my $from=param("email");
my $name=param("name");
#################################
# this line needs to be removed #
#################################
# my $to="feedback\@insertdomainnamehere.com";
my $subject="Feedback from ** a web site **";
############################################################
# return value of send_to sub is placed into your new list #
############################################################
my @email_list = send_to("/your/dir/and/file");
##################################
# loop through each item in list #
##################################
for my $to (@email_list)
{
chomp $to;
open(MAIL, "|$sendmail") || die "Can't start sendmail: $!";
print MAIL<<END_OF_HEADER;
From: $from
To: $to
Subject: $subject
The following information was submitted via the online feedback form at
**
insert name here **
$name wrote :
$comments
END_OF_HEADER
close(MAIL);
} # for loop complete
}
send_mail();
print redirect( -url => $target );
------------------------------
Date: Sat, 14 Apr 2001 20:38:44 +0100
From: "Robb Meade" <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Subject: Re: New NG member - seeks a little help :)
Message-Id: <9ba8un$r7d$1@newsg1.svr.pol.co.uk>
Hi there,
Thanks for a prompt reply :)
Just one question, as you've explained stuff well with the comments and
stuff - thanks :)
> my $file = shift;
I presumably need to change the word 'shift' to the location of my email
file dont I?
ie, "/mailing/list.txt" or something similar?
--
Robb Meade
GoofyMouse Designs
www.goofymouse.com
------------------------------
Date: Sat, 14 Apr 2001 20:47:54 +0100
From: "Robb Meade" <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Subject: Re: New NG member - seeks a little help :)
Message-Id: <9ba9ft$8b1$1@newsg2.svr.pol.co.uk>
Damn it! I cant get it to work :(
I put this back to what you had
> my $file = shift;
I keep getting errors saying it cant find/open the file @ blah blah blah
etc...??
> my @email_list = send_to("/your/dir/and/file");
Do I just need to list it from my /cgi-bin/ dir..
In my case...
("/mailing/mailing_list/email.txt")
Or do I need to go back further, right to the start of the path etc?
I've tried it from
/home/myname/cgi-bin/mailing/mailing_list/email.txt
and that didnt work either :o/
--
Robb Meade
GoofyMouse Designs
www.goofymouse.com
------------------------------
Date: Sat, 14 Apr 2001 21:00:07 +0100
From: "Robb Meade" <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Subject: Re: New NG member - seeks a little help :)
Message-Id: <9baa6q$269$1@newsg4.svr.pol.co.uk>
Nope - its beaten me :(
Keep getting this, with what ever variation I try....
Could not open /cgi-bin/mailing/email.txt: No such file or directory at
/home/goofymouse/cgi-bin/mailing/mailing.cgi line 15.
--
Robb Meade
GoofyMouse Designs
www.goofymouse.com
------------------------------
Date: Sat, 14 Apr 2001 20:41:37 GMT
From: r1ckey <r1ckey@home.com>
Subject: Re: New NG member - seeks a little help :)
Message-Id: <3AD8B63E.D0F5B34F@home.com>
Robb Meade wrote:
>
> Hi there,
>
> Thanks for a prompt reply :)
>
> Just one question, as you've explained stuff well with the comments and
> stuff - thanks :)
>
> > my $file = shift;
Do not change this line, in fact the subroutine should not be altered
unless you want to customize it. The only thing that you must change is
the argument to the send_to subroutine:
my @email_list = send_to("/your/dir/and/file");
^^^^^^^^^^^^^^^^^^
change this only
>
> I presumably need to change the word 'shift' to the location of my email
> file dont I?
>
> ie, "/mailing/list.txt" or something similar?
>
> --
>
> Robb Meade
> GoofyMouse Designs
> www.goofymouse.com
------------------------------
Date: Sat, 14 Apr 2001 22:25:55 +0100
From: "Robb Meade" <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Subject: Re: New NG member - seeks a little help :)
Message-Id: <9baf7n$5re$1@newsg4.svr.pol.co.uk>
> > > my $file = shift;
>
> Do not change this line, in fact the subroutine should not be altered
> unless you want to customize it.
Nope :) (I've put it back!)
>The only thing that you must change is
> the argument to the send_to subroutine:
>
>
> my @email_list = send_to("/your/dir/and/file");
> ^^^^^^^^^^^^^^^^^^
> change this only
This has been changed soooo many times now - and still its not working :o/
I've currently got the actually 'mailing.cgi' script (this one) here :
www.goofymouse.com/cgi-bin/mailing/mailing.cgi
The send_to bit has been set to :
/mailing/email.txt
And the email.txt file is living with the mailing.cgi file in
www.goofymouse.com/cgi-bin/mailing/
Whats different this time is now I'm getting 404 errors? I figured the
'redirect' thing I had was wrong, so I've set it to www.goofymouse.com which
does exist - but still I get the same error? Presumably, this is also why I
am not receiving any emails from the script, because its not getting to
complete?
Thanks again for any help you can offer with this - if I can get it working
I can base my ASP stuff around it :)
--
Robb Meade
GoofyMouse Designs
www.goofymouse.com
------------------------------
Date: Sat, 14 Apr 2001 19:13:50 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: PERL DBI Problem
Message-Id: <slrn9dh8bc.e63.tjla@thislove.dyndns.org>
I was shocked! How could Tad McClellan <tadmc@augustmail.com>
say such a terrible thing:
>Victor Carnale <vcarnale@snet.net> wrote:
>>We have a PERL script that has successfully run for 6 months on a Unix
^^^^
>=item Allocation too large: %lx
>
>(X) You can't allocate more than 64K on an MS-DOS machine.
^^^^^^
Somehow I doubt that.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Half of the harm that is done in this world is due to people who want
to feel important.
-T.S. Eliot, "The Cocktail Party"
------------------------------
Date: Sat, 14 Apr 2001 21:55:00 +0200
From: "Christer Holmdahl" <chho@privat.utfors.se>
Subject: perl equivalent for (char) long_var in C ?
Message-Id: <9ba9rp$all$1@yggdrasil.utfors.se>
This is a multi-part message in MIME format.
------=_NextPart_000_000C_01C0C52D.8D824960
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi!
I'm a newbie (i admit) to Perl and I'm trying to convert an old C =
program.
Is there a Perl equivalent for (char)long_var in C?
Thanx in advance! :)
/Christer
------=_NextPart_000_000C_01C0C52D.8D824960
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2014.210" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#fff8f0>
<DIV><FONT size=3D2>Hi!</FONT></DIV>
<DIV><FONT size=3D2>I'm a newbie (i admit) to Perl and I'm trying to =
convert an=20
old C program.</FONT></DIV>
<DIV><FONT size=3D2>Is there a Perl equivalent for (char)long_var in=20
C?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>Thanx in advance! :)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>/Christer</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></BODY></HTML>
------=_NextPart_000_000C_01C0C52D.8D824960--
------------------------------
Date: Sat, 14 Apr 2001 20:09:31 GMT
From: "Mario Rizzuti" <diab.lito@usa.net>
Subject: R: How can u group together fields and sum them up
Message-Id: <%72C6.14602$s93.850847@news.infostrada.it>
sdfsd <sdfes@dsf.com> wrote in message
3ad89b62$0$66056$45beb828@newscene.com...
> We have a unix file with 100 million lines (broken into 12 files of 8
million
> each)
>
> fields are as follows:
>
> acct# type1 amt1 type2 amt2 type3 amt3 c_type4 amt4
> 125 x2 34 x41 43 x14 76 x54 54
>
> each line has unique types with a corresponding amout. however sometimes
> (around 1-2 %) we get duplicate types with their amouts as follows
>
> 125 x2 34 x41 43 x2 76 x41 54 x14 65
>
> in that case we need to combine the duplicate types, summing up their
> corresponding amounts.
>
> our output should be normalized that is a line for each type:
>
> 125 x2 110
> 125 x41 97
> 125 x14 65
>
> with any dupes having been combined and summed
>
> how can we (or can we?) do this in Perl?
>
> Speed IS important. Currently a vendor sorting program is doing it but it
> takes 15 hours. We need to this very fast. I asked in the AWK group but
they
> passed due to speed issue
>
> p.s. there are no spaces between fields and its one rec per line.
>hardware is Sun 10k, 8 gigs ram 900 gigs HD, 10 CPUS. Sun 5.6 is OS.
Maybe you need to give additional info about the structure of the files.If
there are no spaces,I don't see how the script can understand if x234 is
x2-34 or x23-4.
About the time,I think your machine could do the job much faster than in 15
hours.If I understand good, it could handle the whole database on ram, the
disks seem state of the art too.
I really don't have the experience and the data to estimate, but 15-30
minutes wouldn't be a big surprise.
Mario Rizzuti
------------------------------
Date: Sat, 14 Apr 2001 20:03:25 GMT
From: "guillaume" <guillaume.3@free.fr>
Subject: Re: to get a PId
Message-Id: <h22C6.442$yP4.892013@nnrp6.proxad.net>
Ilmari Karonen a écrit:
>>how can i get the PId of any application? i didn't find a PERL function
>>to do that. (i don't speak of the PERL program's PId)
>
> http://search.cpan.org/search?dist=Proc-ProcessTable
thank you, but i'm under Win32.
guillaume.3@free.fr
------------------------------
Date: Sat, 14 Apr 2001 22:31:20 +0100
From: "Robb Meade" <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
Subject: YAY YAY YAY
Message-Id: <9bafhs$62p$1@newsg4.svr.pol.co.uk>
GOT IT!!!
It was me - sorry - my own stupidity..I was tapping the wrong URL into the
browser, missing out the /mailing directory in the URL after the /cgi-bin
bit.. *tut*!
Thanks very much for your help with this :)
(now, how can I get it to do a confirmation thing too :p)
--
Robb Meade
GoofyMouse Designs
www.goofymouse.com
------------------------------
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 700
**************************************