[18972] in Perl-Users-Digest
Perl-Users Digest, Issue: 1167 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 20 18:05:53 2001
Date: Wed, 20 Jun 2001 15:05:17 -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: <993074717-v10-i1167@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 20 Jun 2001 Volume: 10 Number: 1167
Today's topics:
Re: CGI Expect.pm - unknown terminal type <markg454@hotmail.com>
CGI::CARP (carpout) or (fatalsToBrowser) ? <davsoming@lineone.net>
Complete hash of an array <john@princenaseem.com>
Configuration problem <davsoming@lineone.net>
Re: Configuration problem <andras@mortgagestats.com>
Re: Configuration problem <davsoming@lineone.net>
Re: double key for hashtable <mjcarman@home.com>
Exception handling ? <beyondcontrol@runbox.com>
extract a line under another line with unique pattern? <mark_chou@hotmail.com>
Re: extract a line under another line with unique patte <andras@mortgagestats.com>
hash os hashes sorting <woltz@sewp.nasa.gov>
Re: match exact n times? <mbudash@sonic.net>
Re: Mix JS variables - David Eff.. <mischief@velma.motion.net>
Re: Mix JS variables - David Eff.. <flavell@mail.cern.ch>
Re: ord() and ...? <jurgenex@hotmail.com>
Re: Perl Tutorials or E-Books <yf32@cornell.edu>
problem with 'spaces' in url... <phreakazoid@gmx.ch>
problem with CGI <nbatada@tempdb.com>
Re: problem with CGI <andras@mortgagestats.com>
Re: problem with CGI <comdog@panix.com>
Question <hans@ti.com>
Re: Question <comdog@panix.com>
Re: Setting Return-Path in sendmail from Perl <steve@newmediacreations.com>
Re: Simple Info Aggregation Perl Sample Scrip? <mark_chou@hotmail.com>
Re: Simple Info Aggregation Perl Sample Scrip? <mark_chou@hotmail.com>
Re: Simple Info Aggregation Perl Sample Scrip? <mark_chou@hotmail.com>
string tokenization <lfzhang@lbl.gov>
Re: Unix - NT problems.... <mjcarman@home.com>
Re: Unix - NT problems.... <mjcarman@home.com>
Re: Unix - NT problems.... <gtoomey@usa.net>
Re: Why is perl faster then Tcl (Cameron Laird)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 20 Jun 2001 15:00:01 -0500
From: Mark Gaither <markg454@hotmail.com>
Subject: Re: CGI Expect.pm - unknown terminal type
Message-Id: <3B3100C0.31706BE0@hotmail.com>
David Efflandt wrote:
> On Tue, 19 Jun 2001 13:14:12 -0500, Mark Gaither <markg454@hotmail.com> wrote:
> > I have successfully created a script using Expect.pm and Perl 5 which
> > runs
> > nicely from the command line (perl ./backup.pl).
> >
> > I am trying to move this script to a CGI but I have have run into
> > a problem. I get an 'unknown terminal "unknown"' message and I suspect
> > that this is related to the fact that a CGI session is not runing as a
> > known
> > terminal such as vt100. I know how to set the terminal in Expect but
> > not using Expect.pm. Any help would be greatly appreciated. I've
> > included the code at the end of this message.
>
> It didn't occur to try: $ENV{TERM} = 'vt100';
>
> early in your script, or if that fails, with a shell command after you
> login, or from your .profile or .login depending upon destination shell.
> You could set it there to default to vt100 (.profile example for Solaris
> which doesn have terminfo for linux):
>
> if [ "$TERM" = "linux" ]
> then
> TERM=vt100
> export TERM
> fi
>
> if [ "$TERM" = "" -o "$TERM" = "unknown" ]
> then
> TERM=vt100
> export TERM
> fi
>
> --
> David Efflandt (Reply-To is valid) http://www.de-srv.com/
> http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
> http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
Crap! That worked.
I tried that before I posted but I got an error stating that the 'TERM' hash key
was incorrect
because the CGI environment didn't include TERM. Hmmm, I wonder what I did
wrong... sigh.
I've since tightened the loose screw on the end of the keyboard.
Thanks very much,
Mark Gaither
------------------------------
Date: Wed, 20 Jun 2001 19:18:02 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: CGI::CARP (carpout) or (fatalsToBrowser) ?
Message-Id: <tj1pqohv956h52@corp.supernews.co.uk>
Hi,
What is the difference between...
#use CGI::Carp qw(carpout);
#use CGI::Carp qw(fatalsToBrowser);
and what is the "qw"? I've looked in perldocs but no wiser.
Thanks.
--
David Soming
'Just a head-banger- doing what I do best'
______________
------------------------------
Date: Wed, 20 Jun 2001 20:37:35 +0100
From: "JohnShep" <john@princenaseem.com>
Subject: Complete hash of an array
Message-Id: <y57Y6.1$vf3.241@NewsReader>
I thought I had this array/hash business figured but I'm really losing it on
this one.
my %ratings;
while (my $ref = $sth->fetchrow_arrayref) {
if (!$ratings{$$ref[3]}{"now"}) {
$ratings{$$ref[3]}{"now"} = 1000;
$ratings{$$ref[3]}{"max"} = 1000;
}
(ratings{$$ref[3]}{"now"}) = get_rating_now($$ref[3]);
(ratings{$$ref[3]}{"max"}) = get_rating_max($$ref[3]);
}
OK so far I think, but how do I iterate through %ratings to update the
database with the new values ?
Thanks in advance, John
------------------------------
Date: Wed, 20 Jun 2001 20:03:49 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: Configuration problem
Message-Id: <tj1sgjavrc1tc8@corp.supernews.co.uk>
According to my ssi-env.shtml script Using: <!--#exec
cgi="cgi-bin/ALL_ENV.cgi"-->)
document root is:
DOCUMENT_ROOT = /home/sites/site13/web - this is OK and is set for all my
other
programs running on Unix virtual server.
However the following will not config properly and I only have two variables
to set
in variables.pl...
use constant TOP => 'home/sites/site13/web/cgi-bin/track';
use constant HOME => 'http://www.mydomain.com/cgi-bin/track';
but get software error using CGI::Carp qw(carpout);
"Cant open home/sites/site13/web/mydomain/cgi-bin/track/data/adps.txt(No
such
file or directory)!"
The directories track/data/permissions are OK and the file adps.txt already
exists in data dir!
Anything obvious why I get error message?
Also, what exactly does "use constant" mean?
Thanks
--
David Soming
'Just a head-banger- doing what I do best'
______________
------------------------------
Date: Wed, 20 Jun 2001 15:07:54 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Configuration problem
Message-Id: <3B30F48A.1F204026@mortgagestats.com>
David Soming wrote:
> According to my ssi-env.shtml script Using: <!--#exec
> cgi="cgi-bin/ALL_ENV.cgi"-->)
> document root is:
> DOCUMENT_ROOT = /home/sites/site13/web - this is OK and is set for all my
> other
> programs running on Unix virtual server.
>
> However the following will not config properly and I only have two variables
> to set
> in variables.pl...
>
> use constant TOP => 'home/sites/site13/web/cgi-bin/track';
> use constant HOME => 'http://www.mydomain.com/cgi-bin/track';
>
> but get software error using CGI::Carp qw(carpout);
> "Cant open home/sites/site13/web/mydomain/cgi-bin/track/data/adps.txt(No
> such
> file or directory)!"
>
> The directories track/data/permissions are OK and the file adps.txt already
> exists in data dir!
> Anything obvious why I get error message?
> Also, what exactly does "use constant" mean?
>
> Thanks
> --
> David Soming
> 'Just a head-banger- doing what I do best'
> ______________
Aren't you missing a / in front of home?
------------------------------
Date: Wed, 20 Jun 2001 21:18:06 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: Re: Configuration problem
Message-Id: <tj20rs2ga8308b@corp.supernews.co.uk>
All OK!
The misconfiguration error was due to adps.txt
My program was looking for adps.dat too which should have been uploaded with
the other files.
Thanks for your help
--
David Soming
'Just a head-banger- doing what I do best'
______________
"David Soming" <davsoming@lineone.net> wrote in message
news:tj1sgjavrc1tc8@corp.supernews.co.uk...
> According to my ssi-env.shtml script Using: <!--#exec
> cgi="cgi-bin/ALL_ENV.cgi"-->)
> document root is:
> DOCUMENT_ROOT = /home/sites/site13/web - this is OK and is set for all my
> other
> programs running on Unix virtual server.
>
> However the following will not config properly and I only have two
variables
> to set
> in variables.pl...
>
> use constant TOP => 'home/sites/site13/web/cgi-bin/track';
> use constant HOME => 'http://www.mydomain.com/cgi-bin/track';
>
> but get software error using CGI::Carp qw(carpout);
> "Cant open home/sites/site13/web/mydomain/cgi-bin/track/data/adps.txt(No
> such
> file or directory)!"
>
> The directories track/data/permissions are OK and the file adps.txt
already
> exists in data dir!
> Anything obvious why I get error message?
> Also, what exactly does "use constant" mean?
>
> Thanks
> --
> David Soming
> 'Just a head-banger- doing what I do best'
> ______________
>
>
>
>
------------------------------
Date: Wed, 20 Jun 2001 10:22:10 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: double key for hashtable
Message-Id: <3B30BFA2.FAF87FB1@home.com>
Torsten Drees wrote:
>
> i wrote two records in a hash table with the same key.
> Is it possible to get back both records.
No, the second one overwrote the first one.
> If not, is it possible to define a subkey?
Certainly. Hash values can be any scalar, so you can put a reference to
another hash in there:
my %hash;
$hash{key1} = 'foo';
$hash{key2}{subkey1} = 'bar';
$hash{key2}{subkey2} = 'baz';
Note that you'll want to define the subkey up front. If you do this:
my %hash;
$hash{key1} = 'foo';
$hash{key1}{subkey2} = 'bar';
You'll still lose the first value ('foo') that you stored. If you're
consistent about always using a subkey (no mixed-level hashes) this
shouldn't be a problem.
Another option is to use a HoL (Hash of Lists) instead:
my %hash;
push(@{$hash{key1}}, 'foo');
push(@{$hash{key1}}, 'bar');
print $hash{key1}[0]; # prints 'foo'
Which approach is better depends on what you're trying to do and what
the distinction is between the two values with the same primary key.
The ability to use references in this manner is very powerful and allows
you to create arbitrarily complex data structures. See the perlref and
perlreftut manpages for more information.
-mjc
------------------------------
Date: Wed, 20 Jun 2001 20:49:10 +0200
From: "BeyondContol Inc." <beyondcontrol@runbox.com>
Subject: Exception handling ?
Message-Id: <9gqof8$r9d$1@news.netvision.net.il>
Hi,
I'm running a scripts that loads subroutines from other script files.
My problem is that every time that any subroutine from those files fails
(like trying to manipulate undefined objects), my main script dies with it.
Now, I'm not going to sell myself out by running the subroutines using
system('perl xxx.pl'), I want to run them (relatively) cleanly as
subroutines.
Is there an equivalent to the try/catch c++ directives?
I saw something in the form of an Exception module at CPAN, but I'm not sure
it'll catch errors not thrown using this same module....
Help?
------------------------------
Date: Thu, 21 Jun 2001 02:37:18 +0800
From: Mark Chou <mark_chou@hotmail.com>
Subject: extract a line under another line with unique pattern?
Message-Id: <3B30ED5D.5D82A9AE@hotmail.com>
Dear Peal Guru,
Assume a few lines in a file like this
.........
ABC
1234
..........
ABC is the unique pattern in the file, but wanted to extract the line
just below it, i.e. line starting with 1234
Thanks & Regards,
Mark_chou@hotmail.com
------------------------------
Date: Wed, 20 Jun 2001 15:04:38 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: extract a line under another line with unique pattern?
Message-Id: <3B30F3C5.7026969@mortgagestats.com>
Mark Chou wrote:
> Assume a few lines in a file like this
>
> .........
> ABC
> 1234
> ..........
>
> ABC is the unique pattern in the file, but wanted to extract the line
> just below it, i.e. line starting with 1234
Assuming your file is called file.txt, you can do something like this:
open FH, "file.txt" or die "Can't open file.txt: $!";
while (<FH>){
if m/ABC/{ #see if this is the line that matches ABC
$myline=<FH>; #If yes, capture the next line.
last; #Exit the loop.
};
};
------------------------------
Date: Wed, 20 Jun 2001 17:25:53 -0400
From: woltz <woltz@sewp.nasa.gov>
Subject: hash os hashes sorting
Message-Id: <3B3114E1.9F664185@sewp.nasa.gov>
I'm perplexed on how to sort, or retrieve my data in a sorted fashion from, a hash of hashes on a
value from the bottom hash.
%top_hash = {id1=>%bottom_hash = {some_key => some_value,
anotherkey => another_value},
id2=>%bottom_hash = {some_key => some_value,
anotherkey => another_value},
id3=>%bottom_hash = {some_key => some_value,
anotherkey => another_value}}
I want to print all items sorted on another_value.
Thanks,
KG
------------------------------
Date: Wed, 20 Jun 2001 11:36:09 -0700
From: Michael Budash <mbudash@sonic.net>
Subject: Re: match exact n times?
Message-Id: <mbudash-39781E.11360920062001@news.pacbell.net>
In article <3B30D4A0.6883B490@tamu.edu>, bing-du@tamu.edu wrote:
> Hi,
>
> If {n} means matching exact n times, how come the output of the
> following script is 'yes'? What did I do wrong?
>
> #!/usr/local/bin/perl
>
> $test = "ohello";
>
> if ($test =~ /[0-9a-z]{5}/)
> {
> print "yes\n";
> } else {
> print "no\n";
> }
>
uh, it works, dude. you said "match exactly five consecutive chars of
any of these: 0-9 OR a-z"... ??
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Wed, 20 Jun 2001 19:21:05 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Mix JS variables - David Eff..
Message-Id: <tj1tt18kfpou1c@corp.supernews.com>
BUCK NAKED1 <dennis100@webtv.net> wrote:
> Thanks, David. Now, THAT was helpful!
> I'm still curious if anyone knows of a site that explains mixing JS with
> Perl. All I can find on the subject are the JS Event Handlers that are
> mixed with perl in CGI.pm.
I'm not sure how the search for references on mixing two languages
effectively will go. It might be fruitful, but it might return
nothing. Even if you do find somehting, it may not be very helpful.
You see, mixing languages is like deep magic. Those who know how
to do it well know both languages well enough to know why and
when to do it. Sometimes the best way to learn to mix two languages
is to further your knowledge of how to use each and when you'd
rather use one than the other.
Chris
--
Programming is a tool. A tool is neither good nor evil. It is
the user who determines how it is used and to what ends.
------------------------------
Date: Wed, 20 Jun 2001 21:31:37 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Mix JS variables - David Eff..
Message-Id: <Pine.LNX.4.30.0106202123360.18653-100000@lxplus003.cern.ch>
On Tue, 19 Jun 2001, BUCK NAKED1 wrote:
> I'm still curious if anyone knows of a site that explains mixing JS with
> Perl. All I can find on the subject are the JS Event Handlers that are
> mixed with perl in CGI.pm.
No, they aren't "mixed", and that's the whole key to understanding.
CGI.pm offers you a way to put event handlers into the generated HTML,
but there's nothing magical about that. You could perfectly well code
that by hand (as the 'zilla keeps telling us), just that (contrary to
what the 'zilla keeps telling us), there are benefits in first knowing
_how_ to do it by hand, and then _refraining_ from doing that.
So, like all complex tasks, the key to understanding what you're doing
is to take the complexity apart into well defined components separated
by well defined interworking specifications; to understand each
component separately, and then to assemble them together across those
well defined interworking specs to make a functioning whole.
"Mixing" is the wrong word for that. And never lose sight of where
the action is taking place. Whenever I see someone asking a WWW
question about an action, and failing to mention whether it's at the
client side or the server side (not all of them are "how do I execute
a CGI script in my browser?" but that one comes up disappointingly
often), then I conclude that's their first priority, irrespective of
programming language, race, colour or religion, to get sorted out.
------------------------------
Date: Wed, 20 Jun 2001 11:54:54 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: ord() and ...?
Message-Id: <3b30f17e$1@news.microsoft.com>
"Danny Hendrickx" <daniel.hendrickx@alcatel.be> wrote in message
news:3B309B53.BE8C1D9C@alcatel.be...
> I know I can use ord() to get the ASCII value of a character. But
> suppose I want to change this character by modifying the ASCII value
> afterwards, how would I do that?
>
> My goal is to convert lowercase to uppercase, so with ord() I can check
> if it is a lowercase alphabetical character, but how do I change the
> character then ?
Why not use lc and uc (see perldoc -f lc and perldoc -f uc)?
It will even do the right thing for all characters, not only for just 7-bit
ASCII.
jue
------------------------------
Date: Wed, 20 Jun 2001 14:17:52 -0400
From: "Young C. Fan" <yf32@cornell.edu>
Subject: Re: Perl Tutorials or E-Books
Message-Id: <9gqpdr$lqr$1@news01.cit.cornell.edu>
"[coder]" <coder@binbash.net> wrote in message
news:tiu6lup4vk40f6@corp.supernews.com...
> Hey
>
> anyone know where i can find some perl tutorials or free e-books?
I found this tutorial very helpful:
http://www.comp.leeds.ac.uk/Perl/start.html
------------------------------
Date: Wed, 20 Jun 2001 22:14:36 +0200
From: "Benjamin" <phreakazoid@gmx.ch>
Subject: problem with 'spaces' in url...
Message-Id: <9gr08g$gma$06$1@news.t-online.com>
i wrote this perl script to check for broken links of my homepage:
#!/usr/bin/perl -w
use LWP::Simple;
print "test the link to a file!\n";
if(!head('ftp://192.168.0.2/pub/README'))
{
print "link is dead!";
}
else
{
print "link is good!";
}
########################end.
this is running without problems. but if the url has spaces in it, i don't
know how to write it in the script.
i testet ==> if(!head('ftp://192.168.0.2/pub/%20/README')) # after the pub
directory there is one with only one space for its name.
i've to test links where are spaces, in the filename and the directory path.
but the hex code "%20" don't work. "\ ", like in unix, the same way.
although i set the url in " ", but no working too.
hope someone can help me! and sorry for my awful english.
------------------------------
Date: Wed, 20 Jun 2001 11:23:37 -0700
From: John Cat <nbatada@tempdb.com>
Subject: problem with CGI
Message-Id: <Pine.LNX.4.33.0106201120480.8657-100000@schewanella.stanford.edu>
Hi,
when i run the code with CGI in it i get the following mesg...
(offline mode: enter name=value pairs on standard input)
then when i type in Ctrl-d it continues properly. How can i prevent this
message?
my code is....................
#!/usr/bin/perl
use CGI qw/:standard :html3/;
print header,
start_html('Vegetables'),
h1('Vegetables are for the Strong'),
table({-border=>''},
caption(strong('When Should You Eat Your Vegetables?')),
Tr({-align=>CENTER,-valign=>TOP},
[
th(['Veg Name','Breakfast','Lunch','Dinner']),
th('Tomatoes').td(['no','yes','yes']),
th('Broccoli').td(['no','no','yes']),
th('Onions').td(['yes','yes','yes'])
]
)
),
end_html;
------------------------------
Date: Wed, 20 Jun 2001 14:56:57 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: problem with CGI
Message-Id: <3B30F1F9.DCAEC2F0@mortgagestats.com>
John Cat wrote:
> Hi,
> when i run the code with CGI in it i get the following mesg...
>
> (offline mode: enter name=value pairs on standard input)
>
> then when i type in Ctrl-d it continues properly. How can i prevent this
> message?
One of the things CGI.pm does is check the environment your program is
running in. If it runs under a web server, it does what you apparently
expect it to do. Otherwise it will give you an opportunity to pass
parameters to it by giving you the message you are complaining about. So
there is nothing wrong with your program, nor is there anything wrong with
the CGI module. If you don't want to get that message, run your program in a
CGI environment.
------------------------------
Date: Wed, 20 Jun 2001 15:35:59 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: problem with CGI
Message-Id: <comdog-964357.15355920062001@news.panix.com>
In article
<Pine.LNX.4.33.0106201120480.8657-100000@schewanella.stanford.edu>,
John Cat <nbatada@tempdb.com> wrote:
> Hi,
> when i run the code with CGI in it i get the following mesg...
>
> (offline mode: enter name=value pairs on standard input)
>
> then when i type in Ctrl-d it continues properly. How can i prevent this
> message?
CGI.pm looks in the environment variables to see how you are
executing the script. in this case CGI.pm does not think you
are executing it via a web server and assumes you and to give it
data for testing or debugging.
depending on what you want to do, you can work around this quite
easily. my favorite is simply to set the environment variable
REQUEST_METHOD to GET. at the same time you could set other
CGI relevant environment variables to affect how CGI.pm acts.
--
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Wed, 20 Jun 2001 13:48:27 -0500
From: "Hans Baartmans" <hans@ti.com>
Subject: Question
Message-Id: <9gqr5s$1kp$1@tilde.csc.ti.com>
I am reading in a file of user names and putting these files into an array.
Then I would like to use an 'if' statement within a 'foreach' loop to check
to see if these home directories contain a particular file. Can I use the
'-e' option to see if the file exists?
I am not a good perl programmer, but this is what I did in part of my
script.
foreach $user (@user) {
print "\n";
print "Checking home directory: $user\n";
if (-e "/home/$user/$rhosts") {
print "/home/$user/$rhosts exists. \n";
print OUT "ls -al /home/$user/$rhosts";
}
}
Thanks!
Hans
------------------------------
Date: Wed, 20 Jun 2001 15:19:22 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: Question
Message-Id: <comdog-2CD250.15192220062001@news.panix.com>
In article <9gqr5s$1kp$1@tilde.csc.ti.com>, "Hans Baartmans"
<hans@ti.com> wrote:
> Can I use the
> '-e' option to see if the file exists?
absolutely.
> I am not a good perl programmer, but this is what I did in part of my
> script.
> foreach $user (@user) {
> print "\n";
> print "Checking home directory: $user\n";
> if (-e "/home/$user/$rhosts") {
> print "/home/$user/$rhosts exists. \n";
> print OUT "ls -al /home/$user/$rhosts";
> }
> }
does this not work for you? how is it not working as e
you might want to use File::Find to do this.
http://search.cpan.org/doc/JHI/perl-5.7.1/lib/File/Find.pm
you could even use the find2perl facility to translate the
`find` command to perl.
you should already have it if you have perl. :)
--
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Wed, 20 Jun 2001 20:20:36 GMT
From: "Steven Stalzer" <steve@newmediacreations.com>
Subject: Re: Setting Return-Path in sendmail from Perl
Message-Id: <oA7Y6.1987$bR5.694752@typhoon2.gnilink.net>
Hmm, I have indeed been using a valid From. This seems to allow a receiver to
reply to me (such as to ask to be removed from the mailing list), but invalid
emails in the list still get bounced back to the default Return-Path set up by
the virtual server, rather than coming back to From, where I can deal with them.
--
Steven Stalzer, President
www.townvalues.com
New Media Creations, Inc.
----------
In article <Xns90C5C177F65A0IDIMOZ.NEUTRON.1@62.253.162.107>,
igor@hybrid-lab.net.nospam (Igor Mozolevsky) wrote:
>> I am hoping to do something like this:
>> open(MAIL,"|$mailprog -t");
>> print MAIL "To: $email\n";
>> print MAIL "From: $steve\n";
>> print MAIL "Return-Path: $bounce_alias\n";
>> print MAIL "Subject: $subject\n\n" ;
>>
>
> You can't just add a return-path as sendmail adds another one at the point
> of delivery, just use a valid from.
>
> IM :-)
------------------------------
Date: Thu, 21 Jun 2001 02:38:50 +0800
From: Mark Chou <mark_chou@hotmail.com>
Subject: Re: Simple Info Aggregation Perl Sample Scrip?
Message-Id: <3B30EDBA.305FB98F@hotmail.com>
Thanks
Ren Maddox wrote:
> On Mon, 18 Jun 2001, mark_chou@hotmail.com wrote:
>
> > Anyone can help me with a Simple Info Aggregation Perl Sample Scrip?
> > Basically what I want to do is to have a web page which extract some
> > simple infomation from different websites and combine them on one
> > web page. In particular, I want to know how to extract a field from
> > a line? Such as how to extract, say 3rd field from linw " Simple
> > Info Aggregation Perl Sample Scrip" which should be
> > "Aggregation". You help is most appreciated.
>
> Here are a couple of ways. (Keep in mind that element numbering in
> Perl starts at 0.)
>
> my $string = " Simple Info Aggregation perl Sample Scrip";
> my $one_way = (split ' ', $string)[2];
> my $another_way = ($string =~ /\w+/g)[2];
>
> Note that with the split solution it is important to use the literal
> " " rather than the more explicit / /, as a split treats a literal
> space special -- it ignores leading, trailing and multiple spaces (and
> other whitespace).
>
> --
> Ren Maddox
> ren@tivoli.com
--
Thanks & Regards,
Mark
------------------------------
Date: Thu, 21 Jun 2001 02:39:18 +0800
From: Mark Chou <mark_chou@hotmail.com>
Subject: Re: Simple Info Aggregation Perl Sample Scrip?
Message-Id: <3B30EDD6.82847D79@hotmail.com>
Thanks.
Andras Malatinszky wrote:
> Mark Chou wrote:
>
> > Dear Perl Guru,
> >
> > Anyone can help me with a Simple Info Aggregation Perl Sample Scrip?
> > Basically what I want to do is to have a web page which extract some
> > simple infomation from different websites and combine them on one web
> > page. In particular, I want to know how to extract a field from a line?
> > Such as how to extract, say 3rd field from linw " Simple Info
> > Aggregation Perl Sample Scrip" which should be "Aggregation". You help
> > is most appreciated.
> >
> > --
> >
> > Thanks & Regards,
> >
> > Mark
>
> The split function would be a handy tool to do what you seem to want. You
> can read up on it in perlfunc or your favorite Perl reference.
--
Thanks & Regards,
Mark
------------------------------
Date: Thu, 21 Jun 2001 02:39:30 +0800
From: Mark Chou <mark_chou@hotmail.com>
Subject: Re: Simple Info Aggregation Perl Sample Scrip?
Message-Id: <3B30EDE2.22AB1768@hotmail.com>
Thanks.
"Allan M. Due" wrote:
> "Mark Chou" <mark_chou@hotmail.com> wrote in message
> news:3B2E1950.B9C0F832@hotmail.com...
> : Dear Perl Guru,
> :
> : Anyone can help me with a Simple Info Aggregation Perl Sample Scrip?
> : Basically what I want to do is to have a web page which extract some
> : simple infomation from different websites and combine them on one web
> : page. In particular, I want to know how to extract a field from a line?
> : Such as how to extract, say 3rd field from linw " Simple Info
> : Aggregation Perl Sample Scrip" which should be "Aggregation". You help
> : is most appreciated.
> :
> $_ = "Simple Info Aggregation Perl Sample Scrip";
>
> my $field = (split)[2];
>
> You will want to read up on split and the module LWP in all likelihood.
>
> HTH
>
> AmD
> --
> $email{'Allan M. Due'} = ' All@n.Due.net ';
> --random quote --
> They sicken of the calm who know the storm.
> - Dorothy Parker
--
Thanks & Regards,
Mark
------------------------------
Date: Wed, 20 Jun 2001 14:41:38 -0700
From: Matthew Zhang da LBNL <lfzhang@lbl.gov>
Subject: string tokenization
Message-Id: <3B311892.81657E17@lbl.gov>
I am working on an autometic emailing program...intended to be written
in perl
I have a file of rows of email addresses and names separated by a space
and each entry by a linefeed
emailadd FirstName LastName
emailadd2 FN2 LN2
...
I want to read this file one line at a time, then basically extract the
email address so that I can email another text file out...
I am new to pearl, and from my java exp. The way I am tackling this is
that I will look for the index of the white space of each line I read
then substr. to get the first token...but I have heard so powerful str.
mani. machanism in perl and would like to write some more elegant
(shorter code) than doing what I consider tedious process...any
suggestion from perl ppl out there???
------------------------------
Date: Wed, 20 Jun 2001 08:33:54 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Unix - NT problems....
Message-Id: <3B30A642.2C6CECB5@home.com>
Rajesha wrote:
>
> I'm working on a project in which my perl script has to search for
> particular keyword in a file (of size 2.9+ MB, 85000+ lines) &
> replace some data matching that keyword stored in array.
> On NT, i have installed ActivePerl version 5.003_07.
> Execution in this version takes only 3 minutes. But on Unix
> (solaris os, I have perl version 5.005_03) same script is taking
> 20+ minutes.
You're running the script under two different versions of Perl, on two
different pieces of hardware, with two different operating systems; one
of which is multi-user. It's pretty unrealistic to expect it to take the
same amount of time. Your problem, presumably, is that the Unix box is
either older/slower than the NT box, or that it is more heavily loaded.
> I'm using grep command to fetch/search the keywords from array/file.
> I guess that this grep is slowing the processing in UNIX.
But not on NT? C'mon now...
> I'm using following statements to fetch the data from file or array.
> I'm searching $var_label in global array.
>
> @line_val=grep{/[\s]*$var_label/} @globaltypes::array_details;
>
> #@line_val = grep{/[\s]*$var_label/} <MAPDATA>;
Hrm. That's not much context to work with. I assume that
@globaltypes::array_details contains the full file slurped in from
MAPDATA? There's really no (performance) difference between the two.
grep() puts the filehandle in list context, so the whole thing gets
slurped up anyway. The only difference is that in the first one you keep
a copy of the file around.
The regex could use a little tweaking though. You don't need a character
class ([]) for just one character (\s). Furthermore, it's worthless as
an anchor if it's optional (* is "zero or more").
My suggestion would be to do it this way:
my @line_val;
while (<MAPDATA>) {
push(@line_val, $_) if /$var_label/;
}
The regex is probably slightly faster. I don't know how that offsets
replacing grep() with a loop and push(). You can benchmark it if you
like. The main advantage is that you only read in one line from
<MAPFILE> at a time, and only keep the lines you really want. While this
is a memory improvement, it may also boost performance if your system is
loaded to the point of swapping.
> I tried hash. Eventhough hash is faster in search, it is very slow in
> inserting the data into hash.
I'm not sure what you mean here. Did you have an example?
> Can anyone help me to make the code run faster in unix?
Sure. Buy a faster workstation, or kick everyone else off the system. :)
-mjc
------------------------------
Date: Wed, 20 Jun 2001 09:05:31 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Unix - NT problems....
Message-Id: <3B30ADAB.4E25279E@home.com>
Michael Carman wrote:
>
> Rajesha wrote:
> >
> > #@line_val = grep{/[\s]*$var_label/} <MAPDATA>;
>
> My suggestion would be to do it this way:
>
> my @line_val;
> while (<MAPDATA>) {
> push(@line_val, $_) if /$var_label/;
> }
>
> The regex is probably slightly faster. I don't know how that offsets
> replacing grep() with a loop and push(). You can benchmark it if you
> like.
I know now. It's much faster, and only partially due to simplifying the
regex:
#!/usr/bin/perl -w
use strict;
use Benchmark;
my $org = tell(DATA);
my $label = 'u';
timethese(10000, {
'grep1' => sub {
seek(DATA, $org, 0);
my @lv = grep {/[\s]*$label/} <DATA>;
},
'grep2' => sub {
seek(DATA, $org, 0);
my @lv = grep {/$label/} <DATA>;
},
'loop' => sub {
seek(DATA, $org, 0);
my @lv;
while (<DATA>) {
push(@lv, $_) if /$label/;
}
},
});
__DATA__
[text from previous post]
Benchmark: timing 10000 iterations of grep1, grep2, loop...
grep1: 4 wallclock secs
( 4.23 usr + 0.25 sys = 4.48 CPU) @ 2234.14/s (n=10000)
grep2: 4 wallclock secs
( 3.45 usr + 0.12 sys = 3.57 CPU) @ 2805.05/s (n=10000)
loop: 2 wallclock secs
( 2.31 usr + 0.18 sys = 2.49 CPU) @ 4011.23/s (n=10000)
You should probably repeat the experiment using real data and a real
$label, but the trend should be the same. (Of course, this still won't
make the Solaris box run as fast as the NT one -- it'll just make them
both faster.)
-mjc
------------------------------
Date: Thu, 21 Jun 2001 07:34:58 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Unix - NT problems....
Message-Id: <_p8Y6.109244$hV3.139314@newsfeeds.bigpond.com>
"Tim Schmelter" <tschmelter@statesman.com> wrote in message
news:3B30B3B8.1B8C441B@statesman.com...
> Really, though, 2.9 MB isn't that big a file. I run processes every night
on my
> linux box against a file with 60K-120K+ lines, ranging from 1.5-5.0 MB,
and the
> script takes about 20 seconds.
That's my experience too. Grep of a 3MB file on Linux with a 800MHz+
processor should take under 30 sec.
The OP report of this taking 20 min is unusual - either the CPU is slow,
there is too much swapping or other processes hogging the CPU.
gtoomey
------------------------------
Date: 20 Jun 2001 15:47:53 -0500
From: claird@starbase.neosoft.com (Cameron Laird)
Subject: Re: Why is perl faster then Tcl
Message-Id: <CAF708EEFAD18AD6.8B8325277B08D303.D403FE0748C03361@lp.airnews.net>
In article <3B2D938B.CB2D4C02@localhost.blorg>, <karl@localhost.blorg> wrote:
>Q: Why is perl faster than tcl?
.
.
.
>> I'm doing a paper on Tcl and perl and I have an import
>> quesition.
>>
>> Do you know why perl is so much faster then Tcl? I've
.
.
.
<URL: http://mini.net/tcl/1799.html > is slowly
accreting material that bears on this question.
--
Cameron Laird <claird@NeoSoft.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
------------------------------
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 1167
***************************************