[13462] in Perl-Users-Digest
Perl-Users Digest, Issue: 872 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 22 00:09:21 1999
Date: Tue, 21 Sep 1999 21:05:09 -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: <937973108-v9-i872@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 21 Sep 1999 Volume: 9 Number: 872
Today's topics:
adduser/rmuser/passwd over socket? <song@isot.com>
Re: answers (Abigail)
Array length <raju@bernie.mit.edu>
help! trouble with a perl mail script topalli@my-deja.com
Re: I could use perldoc perlipctut (Martien Verbruggen)
Re: LinkSwitcher with dodgy bits <andrew.yuen@fujitsu.com.au>
Re: need HELP for Perl/CGI application <bwalton@rochester.rr.com>
newbie question...well kindof <juergenp@cc.gatech.edu>
Re: Perl : Excel OLE Automation (Philip 'Yes, that's my address' Newton)
problems with a mail script topalli@my-deja.com
Re: Redirect STDERR <madebeer@igc.apc.org>
Re: REQ: tell-a-friend script <planb@newsreaders.com>
sorry for the duplicate posts ilir@poboxes.com
sort depth <dana@oz.net>
Re: sort depth (Larry Rosler)
stripping newlines out of a string <qcoldiro@thetoolhouse.com>
Re: stripping newlines out of a string <juergenp@cc.gatech.edu>
Re: Test regex <bwalton@rochester.rr.com>
Re: Test regex (Ilya Zakharevich)
Trouble with a mail script topalli@my-deja.com
Trouble with a mail script topalli@my-deja.com
Trouble with a mail script topalli@my-deja.com
Re: Using Perl Modules outside lib directory? (AcCeSsDeNiEd)
Re: Which are the best books for learning Perl for use topalli@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 21 Sep 1999 22:39:22 -0500
From: "Song Kim" <song@isot.com>
Subject: adduser/rmuser/passwd over socket?
Message-Id: <rugjip9klg725@corp.supernews.com>
I have a FreeBSD boxes, one running WWW and the other running SENDMAIL. I
want to be able to adduser/rmuser/passwd from a NT box. Is the perl socket
the right choice? Are there a port already available?
------------------------------
Date: 21 Sep 1999 22:49:39 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: answers
Message-Id: <slrn7ugkjc.db6.abigail@alexandra.delanet.com>
Tom Christiansen (tchrist@mox.perl.com) wrote on MMCCXII September
MCMXCIII in <URL:news:37e80636@cs.colorado.edu>:
|| In comp.lang.perl.misc, "Andrew" <casino@start.com.au> writes:
|| :love the way people say...
|| :'not a perl question'
|| :or
|| :'read some doco'
|| :
|| :is this because you are so arrogant or just don't know?
||
|| Anybody want to bet me this is a Prisoner of Bill? Sure smells of it.
That's trivially answered by looking at his headers. But that's the
only part of his posting from which I make up he's a PoB. Lusers are
everywhere.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 21 Sep 1999 23:19:19 -0400
From: Balasundar Raju <raju@bernie.mit.edu>
Subject: Array length
Message-Id: <37E84AB7.115E3143@bernie.mit.edu>
Hi,
Could someone let me know how to find the length of an array - i.e. the
number
of elements in an array? Thanks,
--
Balasundar I. Raju
raju@mit.edu
------------------------------
Date: Wed, 22 Sep 1999 02:58:57 GMT
From: topalli@my-deja.com
Subject: help! trouble with a perl mail script
Message-Id: <7s9glc$e04$1@nnrp1.deja.com>
I got this script from a post from Creede Lambard posted about a year and
a half ago on this newsgroup. I beleive it is supposed to be an
alternative to unix sendmail and seems to be compatible with macperl
Is there something that I have done wrong in this script? I seem to get
a lot of error messages
These are the messages
Diagnostic Output
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi'; Line 50
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi'; Line 53
# Unmatched right bracket, at end of line
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi'; Line 53
# Execution of Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi aborted due to
compilation errors.
------
This is the script
#!perl -w
use Socket;
$crlf = "\015\012";
$xfrom = "topalli\@aecom.yu.edu";
$xreply = "topalli\@aecom.yu.edu"; # or your alternate reply address
$xto = "topalli\@aecom.yu.edu";
$xsmtp = "mailserver.aecom.yu.edu";
$xsubject = "foo";
$xmessage = "This is the message";
&sendmail($xfrom,$xreply,$xto,$xsmtp,$xsubject,$xmessage) || die "Message
wasn't sent."; # you can check the return value of &sendmail to see
what happened
# ===============================================================
sub sendmail {
my ($from, $reply, $to, $smtp, $subject, $message) = @_;
my ($fromaddr) = $from;
my ($replyaddr) = $reply;
$to =~ s/[ \t]+/, /g; # pack spaces and add comma
$fromaddr =~ s/.*<([^\s]*?)>/$1/; # get from email address
$replyaddr =~ s/.*<([^\s]*?)>/$1/; # get reply email address
$replyaddr =~ s/^([^\s]+).*/$1/; # use first address
$message =~ s/^\./\.\./gm; # handle . as first character
$message =~ s/$crlf/\n/g; # handle line ending
$message =~ s/\n/$crlf/g;
$smtp =~ s/^\s+//g; # remove spaces around $smtp
$smtp =~ s/\s+$//g;
if (!$to) { return -8; }
my($proto) = (getprotobyname('tcp'))[2];
my($port) = (getservbyname('smtp', 'tcp'))[2];
my($smtpaddr) = ($smtp =~
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
? pack('C4',$1,$2,$3,$4)
: (gethostbyname($smtp))[4];
if (!defined($smtpaddr)) { return -1; }
if (!socket(S, AF_INET, SOCK_STREAM, $proto))
return -2; }
if (!connect(S, pack('Sna4x8', AF_INET, $port, $smtpaddr)))
return -3; }
my($oldfh) = select(S); $| = 1; select($oldfh);
$_ = <S>; if (/^[45]/) { close S; return -4; }
print S "helo localhost$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "mail from: <$fromaddr>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
foreach (split(/, /, $to)) {
print S "rcpt to: <$_>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -6; }
}
print S "data$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "To: $to$crlf";
print S "From: $from$crlf";
print S "Reply-to: $replyaddr$crlf" if $replyaddr;
print S "X-Mailer: Just Another Perl Mailscript$crlf";
print S "Subject: $subject$crlf$crlf";
print S "$message";
print S "$crlf.$crlf";
$_ = <S>; if (/^[45]/) { close S; return -7; }
print S "quit$crlf";
$_ = <S>;
close S;
return 1;
}
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 22 Sep 1999 02:34:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: I could use perldoc perlipctut
Message-Id: <OeXF3.145$ml3.8592@nsw.nnrp.telstra.net>
In article <iBWF3.2398$QJ.100887@typ11.nn.bcandid.com>,
kragen@dnaco.net (Kragen Sitaker) writes:
> No; they sit in a select() loop. Whenever a file descriptor that has
Ah, ok, right, I forgot about that :). I never needed to write code
like that.
> data waiting to be written becomes writable, they write to it.
> Whenever a file descriptor becomes readable -- i.e. has data waiting to
> be read -- they read it (or accept() on it, as the case may be). I
> understand IRC servers work the same way; they can't usefully fork into
> one process per client. I wrote a chat server that worked the same way
> in Perl, although I think I have deleted it by now. I have some
> similar code in Perl for an IRC client; would you like me to post it?
Naw, thanks anyway. I know the principle, it just slipped my mind. :)
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: Wed, 22 Sep 1999 13:24:45 +1000
From: "Fujitsu Australia Limited" <andrew.yuen@fujitsu.com.au>
Subject: Re: LinkSwitcher with dodgy bits
Message-Id: <7s9i22$d45@newshost.fujitsu.com.au>
That last one I sent was dodgier than I thought. Here's the latest, still
with a dodgy bit marked:
use strict;
#-------------------------------
# LinkSwitcher package
#
# This is intended to parse an HTML file and return
# in htmltext the same file, with links changed so
# that they are now relative to a new base URI.
#
#-------------------------------
BEGIN {
package LinkSwitcher;
use HTML::Parser;
use URI;
use vars qw(@ISA);
@ISA = qw(HTML::Parser);
## link structure
## $self->{Links} = {
## ------------------
## "url" => { origtext}, ...
## };
sub start { # called by parse
my $self = shift;
my ($tag, $attr, $attrseq, $origtext) = @_;
my $link;
$link = $attr->{href} if $tag eq "a";
$link = $attr->{src} if $tag eq "img";
$link = $attr->{src} if $tag eq "frame";
if (defined $link) {
$self->{Links}{$link}{'origtext'}=$origtext;
if ($link !~ m{^http://} and $link !~ m{^/} ) { # still dodgy
my $uri = URI->new_abs($link, $self->{oldbase});
my $uri_rel = $uri->rel($self->{newbase});
my $newlink = $uri_rel->as_string;
if ($tag eq 'a'){
$attr->{href}=$newlink;
} else {
$attr->{src}=$newlink;
}
}
my $newtag="<$tag"; # reconstruct the tag with the new link
foreach my $key (@$attrseq) {
$newtag .= " ".$key."=\"".$attr->{$key}."\"";
}
$newtag .= ">";
$self->{htmltext} .= $newtag;
} else {
$self->{htmltext} .= $origtext;
}
}
sub end {
my $self = shift;
my ($tag, $origtext) = @_;
$self->{htmltext} .= $origtext;
}
sub text {
my $self=shift;
$self->{htmltext} .= shift;
}
sub comment {
my $self=shift;
$self->{htmltext} .= shift;
}
sub declaration {
my $self=shift;
my $decl=shift;
$self->{htmltext} .= '<!'.$decl.'>';
}
sub get_links { # $instance->get_links()
my $self = shift;
$self->{Links};
}
sub get_htmltext {
my $self=shift;
$self->{htmltext};
}
sub set_bases($$) {
my $self=shift;
($self->{oldbase},$self->{newbase})= @_;
}
} # end of LinkSwitcher package
#-----------------------------
my $file = "linktest.htm";
my $oldbase="http://lev1/lev2/br1lev3/br1lev4/br1lev5/file.htm"; # original
file in which relative links were found
my $newbase="http://lev1/lev2/br2lev3/br2lev4/file.htm"; # new file in which
links are to be placed
my $filetext = do {
local ($/, *FH);
open FH, "< $file" or die "SUB: test_parse_links - Unable to open file
\"$file\" - ERROR: $!";
<FH>;
};
my $p = LinkSwitcher->new;
$p->set_bases($oldbase,$newbase);
$p->parse($filetext);
$p->parse(undef); # signal the end of parse
#my $links = $p->get_links; # key is relative url, value is hashref
#for my $link (sort keys %$links) {
# print "\t origtext:".$links->{$link}{'origtext'}."\n";
#}
print $p->get_htmltext;
__END__
test file linktest.htm
<a href="../../br1lev3/br1lev4/fred">Fred</a>
<a href="../../br1lev3/br1lev4/br1lev5/george">George</a>
<a href="../reg">Reg</A>
<a name=clive href="../../br1lev3/clive/percy/finglenagle">Finglenagle</a>
<a
name="bill"
href="http://bill.fred.com/colin">Colin</a><a
href="/alf.boris.craig/dilbert">Dilbert</a>
This is some stuff that is not a link
<HR>
and so is this<P>
<a href="../../br1lev3/br1lev4/mary/">Mary</a>
<img src="../../br1lev3/br1lev4/br1lev5/alice/">
<frame src="../../br1lev3/br1lev4/br1lev5/sylvester/">
not a link
<HR>
------------------------------
Date: Tue, 21 Sep 1999 22:29:15 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: need HELP for Perl/CGI application
Message-Id: <37E83EFB.BEF5E09@rochester.rr.com>
Federico wrote:
>
> Anybody could help me?
>
> First of all sorry for my terrible English! ^_^ I have read the
> Herrmann's book "Teach yourself CGI PROGRAMMING with PERL 5 in a week", but
> I think I haven't found what I need to know.
>
> I have to built a CGI application written in Perl 5 that:
>
> - send a HTML form information to a remote server with the methods GET or
> POST;
>
> - receive the reply from the server and store it in a variable for a further
> elaboration.
>
> In other words, this application has to simulate, in a simpler way, what a
> broswer do when it interacts whit a host HTML server sending a form and
> receiving the answer. I don't know which Perl functions I must use and how.
> I've thought, for example for the POST method, to open a file in this way:
>
> open(filename, '>>POST
> http://www.sitename.com/subdirectory/program_cgi.cgi HTTP/1.1')
>
> and then send the form information codified in URI standard to the STANDARD
> OUTPUT;
>
> 1) is it correct?
No. You want the "LWP" module, which lets Perl play web
browser.
>
> 2) have I to send some header too?
See the LWP docs.
>
> 3) can I find the remote server reply in STANDARD INPUT?
No.
>
> 4) if all yes, how can I do for the GET method?
GET is real simple -- you can use LWP::Simple for that :-).
>
> Thank you all, it would be great if you want reply me at
> artax@shineline.it Bye,
>
> Federico Bari.
--
Bob Walton
------------------------------
Date: Tue, 21 Sep 1999 23:56:07 -0400
From: Juergen Pabel <juergenp@cc.gatech.edu>
Subject: newbie question...well kindof
Message-Id: <37E85357.1B91F983@cc.gatech.edu>
hi y'all,
sorry if this is stupid but i have searched the web and looked at faq's
and tried this for hours but it won't work:
i wanna check if a certain key exists in a hash...i have an array
(@requiredFields) which is filled with the contents of a txt file. i
then test if all names (in @requiredData) exist in the hash (%data). all
fields that don't exist are to be pushed onto the @missingFields array.
here's what i got:
foreach $tmp (@requiredData)
{
#todo: this somehow won't work
if(not exists $data->{$tmp})
{
push(@missingFields, $tmp);
}
}
i have already suspected that a possible \n in the @requiredData is
causing problems but this ain't so since i get rid of it before this...
the behaviour is that every entry in @requiredData is not present when
in fact it is...
i have found one weird side effect: if i print the hash like
#inside a foreach loop
print "$data{$tmp}...\n"
then the output is weird, like the hash itself is corrupted but if i
print it out using
print "$data{'USER'}...\n"
print "$data{'PASS'}...\n"
then it shows me the expected values
one more thing: i am using the NET::POP3 package and found that if i
construct an object like
$pop = NET::POP3->new('pop.somedomain');
it connects, but if i do this
$pop = NET::POP3->new("$tmp");
or this
$pop = NET::POP3->new($tmp);
where $tmp = 'pop.somedomain' it won't work at all...this makes me
suspect that there is a difference between the type of a hardcoded (the
'') version and the "" version...is this so?
i am using perl 5.005_03 on a redhat 6.0 linux box, the net::pop3 is
version 2.16
please reply to this group and my email since i am not always having
access to a newsgroup server
thank you so much for help
jp
------------------------------
Date: Wed, 22 Sep 1999 03:47:10 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: Perl : Excel OLE Automation
Message-Id: <37e84ed3.209870175@news.nikoma.de>
On 21 Sep 1999 16:55:09 GMT, "pjd"
<duraipPLEEASE__REMOVE_THIIS@extendsys.com> wrote:
>>With the other other script, the PC with Excel had this error:
>>Undefined subroutine &Win32::OLECreateObject called at
>>D:/web/banking/perl/lib/OLE.pm line 104.
>
>Are you sure you have a more recent/complete version of ActivePerl running
>in this system ?. All the necessary modules installed ?
I think he needs more recent documentation. AFAIK, at some point
ActivePerl (or libwin32(?) in general?) moved from Win32::OLExxx to
Win32::OLE::xxx . perldoc Win32::OLE if you've got it (or read the
HTML page).
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.net>
------------------------------
Date: Wed, 22 Sep 1999 02:56:30 GMT
From: topalli@my-deja.com
Subject: problems with a mail script
Message-Id: <7s9ggr$dob$1@nnrp1.deja.com>
I got this script from a post from Creede Lambard
posted about a year and a half ago on this
newsgroup. I beleive it is supposed to be an
alternative to unix sendmail and seems to be
compatible with macperl
Is there something that I have done wrong in this
script? I seem to get a lot of error messages
These are the messages
Diagnostic Output
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 50
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 53
# Unmatched right bracket, at end of line
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 53
# Execution of Macintosh HD:WebSTAR
2.1.1:Web:dejavu2.acgi aborted due to compilation
errors.
------
This is the script
#!perl -w
use Socket;
$crlf = "\015\012";
$xfrom = "topalli\@aecom.yu.edu";
$xreply = "topalli\@aecom.yu.edu"; # or your
alternate reply address
$xto = "topalli\@aecom.yu.edu";
$xsmtp = "mailserver.aecom.yu.edu";
$xsubject = "foo";
$xmessage = "This is the message";
&
sendmail($xfrom,$xreply,$xto,$xsmtp,$xsubject,$xmes
sage) || die "Message
wasn't sent."; # you can check the return value
of &sendmail to see what happened
# =================================================
==============
sub sendmail {
my ($from, $reply, $to, $smtp, $subject,
$message) = @_;
my ($fromaddr) = $from;
my ($replyaddr) = $reply;
$to =~ s/[ \t]+/, /g; # pack
spaces and add comma
$fromaddr =~ s/.*<([^\s]*?)>/$1/; # get from
email address
$replyaddr =~ s/.*<([^\s]*?)>/$1/; # get reply
email address
$replyaddr =~ s/^([^\s]+).*/$1/; # use first
address
$message =~ s/^\./\.\./gm; # handle .
as first character
$message =~ s/$crlf/\n/g; # handle
line ending
$message =~ s/\n/$crlf/g;
$smtp =~ s/^\s+//g; # remove
spaces around $smtp
$smtp =~ s/\s+$//g;
if (!$to) { return -8; }
my($proto) = (getprotobyname('tcp'))[2];
my($port) = (getservbyname('smtp', 'tcp'))[2];
my($smtpaddr) = ($smtp =~
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\
d{1,3})$/)
? pack('C4',$1,$2,$3,$4)
: (gethostbyname($smtp))[4];
if (!defined($smtpaddr)) { return -1; }
if (!socket(S, AF_INET, SOCK_STREAM, $proto))
return -2; }
if (!connect(S, pack('Sna4x8', AF_INET, $port,
$smtpaddr)))
return -3; }
my($oldfh) = select(S); $| = 1; select($oldfh);
$_ = <S>; if (/^[45]/) { close S; return -4; }
print S "helo localhost$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "mail from: <$fromaddr>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
foreach (split(/, /, $to)) {
print S "rcpt to: <$_>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -6;
}
}
print S "data$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "To: $to$crlf";
print S "From: $from$crlf";
print S "Reply-to: $replyaddr$crlf" if
$replyaddr;
print S "X-Mailer: Just Another Perl
Mailscript$crlf";
print S "Subject: $subject$crlf$crlf";
print S "$message";
print S "$crlf.$crlf";
$_ = <S>; if (/^[45]/) { close S; return -7; }
print S "quit$crlf";
$_ = <S>;
close S;
return 1;
}
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 21 Sep 1999 14:50:15 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: Redirect STDERR
Message-Id: <APC&1'0'50775db7'c8f@igc.apc.org>
Dean, try reading
perldoc -q STDERR
-Mike
------------------------------
Date: Tue, 21 Sep 1999 22:54:24 -0400
From: "J. Moreno" <planb@newsreaders.com>
Subject: Re: REQ: tell-a-friend script
Message-Id: <210919992254246580%planb@newsreaders.com>
In article <m1d7vh33ou.fsf@halfdome.holdit.com>, Randal L. Schwartz
<merlyn@stonehenge.com> wrote:
> >>>>> "chetohevia" == chetohevia <chetohevia@my-deja.com> writes:
>
> chetohevia> (i agree-- odd that HTTP_REFERER is misspelled... same thing
> chetohevia> with elsif, which tripped me up at first too)
>
> Ahh, but elsif is *not* misspelled, unless you happen to type it as
> elseif... then *you* are the one mispelling it.
>
> :-)
Uhm, elsif may be correct perl, but it's still a typo.
--
John Moreno
January 1, 2000: 102 days away
------------------------------
Date: Wed, 22 Sep 1999 03:02:25 GMT
From: ilir@poboxes.com
Subject: sorry for the duplicate posts
Message-Id: <7s9grs$e2m$1@nnrp1.deja.com>
I have not usd Deja mail before and the duplicated my message many times
and left me with some silly deja mail return addres. Please contact me
at ilir@poboxes.com
thanks,
Ilir
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 22 Sep 1999 02:07:07 GMT
From: Dana Booth <dana@oz.net>
Subject: sort depth
Message-Id: <7s9dkb$8nd$0@216.39.141.21>
Can anyone tell me how deep the sort function goes?
--
------------------------
Dana Booth <dana@oz.net>
Tacoma, Wa., USA
---
pgp key on the keyserver pgpkeys.mit.edu:11371
------------------------------
Date: Tue, 21 Sep 1999 20:43:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sort depth
Message-Id: <MPG.1251f01cad8c101c989fba@nntp.hpl.hp.com>
In article <7s9dkb$8nd$0@216.39.141.21> on 22 Sep 1999 02:07:07 GMT,
Dana Booth <dana@oz.net> says...
> Can anyone tell me how deep the sort function goes?
100 meters?
Please explain what you mean by this question. If you mean "how many
fields can be compared?", the limit is your patience in writing the code
to extract and compare the subkeys.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 21 Sep 1999 21:47:14 -0500
From: Quinn Coldiron <qcoldiro@thetoolhouse.com>
Subject: stripping newlines out of a string
Message-Id: <37E84332.87D6A2E9@thetoolhouse.com>
I'm on RedHat 6.0 and am trying to write a Perl script that will strip
the newline character out of a string. Any help?
Quinn
------------------------------
Date: Tue, 21 Sep 1999 23:58:48 -0400
From: Juergen Pabel <juergenp@cc.gatech.edu>
To: qcoldiron@yahoo.com
Subject: Re: stripping newlines out of a string
Message-Id: <37E853F8.630F72FB@cc.gatech.edu>
chomp($var); # will get rid if it is the last character,
$var =~ s/\n//g; #will get rid of all \n in the string
jp
Quinn Coldiron wrote:
>
> I'm on RedHat 6.0 and am trying to write a Perl script that will strip
> the newline character out of a string. Any help?
>
> Quinn
------------------------------
Date: Tue, 21 Sep 1999 22:21:48 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Test regex
Message-Id: <37E83D3C.E9A21067@rochester.rr.com>
Samay wrote:
>
> Second takes far less than the first..
> Anyone can find out?
>
> perl -e '"OReilly and The Perl Conference"
> =~ /i(.+)+i/'
>
> perl -e '"OReilly and The Perl Conference"
> =~ /i(.+)+e/'
>
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
> The fastest and easiest way to search and participate in Usenet - Free!
Your first pattern doesn't match, and it is a "bad pattern" in the
sense that it causes a whole bunch of iteration as the regular
expression is matched. Search for the string .+ in perlre for an
explanation. In perlre, the claim is made that each extra character
in a non-matching string doubles the search time for this particular
construction. The second + serves no purpose, and should be removed.
The second pattern does match on a fairly short string, so the match
happens fairly quickly.
------------------------------
Date: 22 Sep 1999 02:46:51 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Test regex
Message-Id: <7s9fur$6vm$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Bob Walton
<bwalton@rochester.rr.com>],
who wrote in article <37E83D3C.E9A21067@rochester.rr.com>:
> > perl -e '"OReilly and The Perl Conference"
> > =~ /i(.+)+i/'
> >
> > perl -e '"OReilly and The Perl Conference"
> > =~ /i(.+)+e/'
> >
> > * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
> > The fastest and easiest way to search and participate in Usenet - Free!
>
> Your first pattern doesn't match, and it is a "bad pattern" in the
> sense that it causes a whole bunch of iteration as the regular
> expression is matched. Search for the string .+ in perlre for an
> explanation. In perlre, the claim is made that each extra character
> in a non-matching string doubles the search time for this particular
> construction. The second + serves no purpose, and should be removed.
Not any more. (Starting from 5.005_60 or somesuch.) The current
implementation of "shortcircuiting" is faulty, but I could no produce any
test case to trigger the known mode of failure. Will fix it anyway...
Ilya
------------------------------
Date: Wed, 22 Sep 1999 02:56:24 GMT
From: topalli@my-deja.com
Subject: Trouble with a mail script
Message-Id: <7s9ggk$do7$1@nnrp1.deja.com>
I got this script from a post from Creede Lambard
posted about a year and a half ago on this
newsgroup. I beleive it is supposed to be an
alternative to unix sendmail and seems to be
compatible with macperl
Is there something that I have done wrong in this
script? I seem to get a lot of error messages
These are the messages
Diagnostic Output
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 50
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 53
# Unmatched right bracket, at end of line
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 53
# Execution of Macintosh HD:WebSTAR
2.1.1:Web:dejavu2.acgi aborted due to compilation
errors.
------
This is the script
#!perl -w
use Socket;
$crlf = "\015\012";
$xfrom = "topalli\@aecom.yu.edu";
$xreply = "topalli\@aecom.yu.edu"; # or your
alternate reply address
$xto = "topalli\@aecom.yu.edu";
$xsmtp = "mailserver.aecom.yu.edu";
$xsubject = "foo";
$xmessage = "This is the message";
&
sendmail($xfrom,$xreply,$xto,$xsmtp,$xsubject,$xmes
sage) || die "Message
wasn't sent."; # you can check the return value
of &sendmail to see what happened
# =================================================
==============
sub sendmail {
my ($from, $reply, $to, $smtp, $subject,
$message) = @_;
my ($fromaddr) = $from;
my ($replyaddr) = $reply;
$to =~ s/[ \t]+/, /g; # pack
spaces and add comma
$fromaddr =~ s/.*<([^\s]*?)>/$1/; # get from
email address
$replyaddr =~ s/.*<([^\s]*?)>/$1/; # get reply
email address
$replyaddr =~ s/^([^\s]+).*/$1/; # use first
address
$message =~ s/^\./\.\./gm; # handle .
as first character
$message =~ s/$crlf/\n/g; # handle
line ending
$message =~ s/\n/$crlf/g;
$smtp =~ s/^\s+//g; # remove
spaces around $smtp
$smtp =~ s/\s+$//g;
if (!$to) { return -8; }
my($proto) = (getprotobyname('tcp'))[2];
my($port) = (getservbyname('smtp', 'tcp'))[2];
my($smtpaddr) = ($smtp =~
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\
d{1,3})$/)
? pack('C4',$1,$2,$3,$4)
: (gethostbyname($smtp))[4];
if (!defined($smtpaddr)) { return -1; }
if (!socket(S, AF_INET, SOCK_STREAM, $proto))
return -2; }
if (!connect(S, pack('Sna4x8', AF_INET, $port,
$smtpaddr)))
return -3; }
my($oldfh) = select(S); $| = 1; select($oldfh);
$_ = <S>; if (/^[45]/) { close S; return -4; }
print S "helo localhost$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "mail from: <$fromaddr>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
foreach (split(/, /, $to)) {
print S "rcpt to: <$_>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -6;
}
}
print S "data$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "To: $to$crlf";
print S "From: $from$crlf";
print S "Reply-to: $replyaddr$crlf" if
$replyaddr;
print S "X-Mailer: Just Another Perl
Mailscript$crlf";
print S "Subject: $subject$crlf$crlf";
print S "$message";
print S "$crlf.$crlf";
$_ = <S>; if (/^[45]/) { close S; return -7; }
print S "quit$crlf";
$_ = <S>;
close S;
return 1;
}
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 22 Sep 1999 02:56:25 GMT
From: topalli@my-deja.com
Subject: Trouble with a mail script
Message-Id: <7s9ggm$do8$1@nnrp1.deja.com>
I got this script from a post from Creede Lambard
posted about a year and a half ago on this
newsgroup. I beleive it is supposed to be an
alternative to unix sendmail and seems to be
compatible with macperl
Is there something that I have done wrong in this
script? I seem to get a lot of error messages
These are the messages
Diagnostic Output
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 50
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 53
# Unmatched right bracket, at end of line
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 53
# Execution of Macintosh HD:WebSTAR
2.1.1:Web:dejavu2.acgi aborted due to compilation
errors.
------
This is the script
#!perl -w
use Socket;
$crlf = "\015\012";
$xfrom = "topalli\@aecom.yu.edu";
$xreply = "topalli\@aecom.yu.edu"; # or your
alternate reply address
$xto = "topalli\@aecom.yu.edu";
$xsmtp = "mailserver.aecom.yu.edu";
$xsubject = "foo";
$xmessage = "This is the message";
&
sendmail($xfrom,$xreply,$xto,$xsmtp,$xsubject,$xmes
sage) || die "Message
wasn't sent."; # you can check the return value
of &sendmail to see what happened
# =================================================
==============
sub sendmail {
my ($from, $reply, $to, $smtp, $subject,
$message) = @_;
my ($fromaddr) = $from;
my ($replyaddr) = $reply;
$to =~ s/[ \t]+/, /g; # pack
spaces and add comma
$fromaddr =~ s/.*<([^\s]*?)>/$1/; # get from
email address
$replyaddr =~ s/.*<([^\s]*?)>/$1/; # get reply
email address
$replyaddr =~ s/^([^\s]+).*/$1/; # use first
address
$message =~ s/^\./\.\./gm; # handle .
as first character
$message =~ s/$crlf/\n/g; # handle
line ending
$message =~ s/\n/$crlf/g;
$smtp =~ s/^\s+//g; # remove
spaces around $smtp
$smtp =~ s/\s+$//g;
if (!$to) { return -8; }
my($proto) = (getprotobyname('tcp'))[2];
my($port) = (getservbyname('smtp', 'tcp'))[2];
my($smtpaddr) = ($smtp =~
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\
d{1,3})$/)
? pack('C4',$1,$2,$3,$4)
: (gethostbyname($smtp))[4];
if (!defined($smtpaddr)) { return -1; }
if (!socket(S, AF_INET, SOCK_STREAM, $proto))
return -2; }
if (!connect(S, pack('Sna4x8', AF_INET, $port,
$smtpaddr)))
return -3; }
my($oldfh) = select(S); $| = 1; select($oldfh);
$_ = <S>; if (/^[45]/) { close S; return -4; }
print S "helo localhost$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "mail from: <$fromaddr>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
foreach (split(/, /, $to)) {
print S "rcpt to: <$_>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -6;
}
}
print S "data$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "To: $to$crlf";
print S "From: $from$crlf";
print S "Reply-to: $replyaddr$crlf" if
$replyaddr;
print S "X-Mailer: Just Another Perl
Mailscript$crlf";
print S "Subject: $subject$crlf$crlf";
print S "$message";
print S "$crlf.$crlf";
$_ = <S>; if (/^[45]/) { close S; return -7; }
print S "quit$crlf";
$_ = <S>;
close S;
return 1;
}
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 22 Sep 1999 02:56:27 GMT
From: topalli@my-deja.com
Subject: Trouble with a mail script
Message-Id: <7s9ggn$do9$1@nnrp1.deja.com>
I got this script from a post from Creede Lambard
posted about a year and a half ago on this
newsgroup. I beleive it is supposed to be an
alternative to unix sendmail and seems to be
compatible with macperl
Is there something that I have done wrong in this
script? I seem to get a lot of error messages
These are the messages
Diagnostic Output
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 50
# syntax error, near ")
return"
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 53
# Unmatched right bracket, at end of line
File 'Macintosh HD:WebSTAR 2.1.1:Web:dejavu2.acgi';
Line 53
# Execution of Macintosh HD:WebSTAR
2.1.1:Web:dejavu2.acgi aborted due to compilation
errors.
------
This is the script
#!perl -w
use Socket;
$crlf = "\015\012";
$xfrom = "topalli\@aecom.yu.edu";
$xreply = "topalli\@aecom.yu.edu"; # or your
alternate reply address
$xto = "topalli\@aecom.yu.edu";
$xsmtp = "mailserver.aecom.yu.edu";
$xsubject = "foo";
$xmessage = "This is the message";
&
sendmail($xfrom,$xreply,$xto,$xsmtp,$xsubject,$xmes
sage) || die "Message
wasn't sent."; # you can check the return value
of &sendmail to see what happened
# =================================================
==============
sub sendmail {
my ($from, $reply, $to, $smtp, $subject,
$message) = @_;
my ($fromaddr) = $from;
my ($replyaddr) = $reply;
$to =~ s/[ \t]+/, /g; # pack
spaces and add comma
$fromaddr =~ s/.*<([^\s]*?)>/$1/; # get from
email address
$replyaddr =~ s/.*<([^\s]*?)>/$1/; # get reply
email address
$replyaddr =~ s/^([^\s]+).*/$1/; # use first
address
$message =~ s/^\./\.\./gm; # handle .
as first character
$message =~ s/$crlf/\n/g; # handle
line ending
$message =~ s/\n/$crlf/g;
$smtp =~ s/^\s+//g; # remove
spaces around $smtp
$smtp =~ s/\s+$//g;
if (!$to) { return -8; }
my($proto) = (getprotobyname('tcp'))[2];
my($port) = (getservbyname('smtp', 'tcp'))[2];
my($smtpaddr) = ($smtp =~
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\
d{1,3})$/)
? pack('C4',$1,$2,$3,$4)
: (gethostbyname($smtp))[4];
if (!defined($smtpaddr)) { return -1; }
if (!socket(S, AF_INET, SOCK_STREAM, $proto))
return -2; }
if (!connect(S, pack('Sna4x8', AF_INET, $port,
$smtpaddr)))
return -3; }
my($oldfh) = select(S); $| = 1; select($oldfh);
$_ = <S>; if (/^[45]/) { close S; return -4; }
print S "helo localhost$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "mail from: <$fromaddr>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
foreach (split(/, /, $to)) {
print S "rcpt to: <$_>$crlf";
$_ = <S>; if (/^[45]/) { close S; return -6;
}
}
print S "data$crlf";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "To: $to$crlf";
print S "From: $from$crlf";
print S "Reply-to: $replyaddr$crlf" if
$replyaddr;
print S "X-Mailer: Just Another Perl
Mailscript$crlf";
print S "Subject: $subject$crlf$crlf";
print S "$message";
print S "$crlf.$crlf";
$_ = <S>; if (/^[45]/) { close S; return -7; }
print S "quit$crlf";
$_ = <S>;
close S;
return 1;
}
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 22 Sep 1999 03:57:51 GMT
From: dillon_rm@magix.com.sg (AcCeSsDeNiEd)
Subject: Re: Using Perl Modules outside lib directory?
Message-Id: <37e85311.2212803@news.magix.com.sg>
Hey thanks folks.
Sorry, should have read the FAQ before barging in here.
And Eric, I am already looking at a new webhosting provider.
Thanks again!
On Tue, 21 Sep 1999 17:42:56 GMT, kragen@dnaco.net (Kragen Sitaker)
wrote:
>In article <37e7bce6.2665328@news.magix.com.sg>,
>AcCeSsDeNiEd <dillon_rm@magix.com.sg> wrote:
>>Is there anyway I can install the perl modules in a different
>>directory (e.g: cgi-bin) and let my script access the modules from
>>there?
>
>use lib '/home/dillon/cgi-bin';
>
>Isn't this in the FAQ?
>--
><kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
>Tue Sep 21 1999
>48 days until the Internet stock bubble bursts on Monday, 1999-11-08.
><URL:http://www.pobox.com/~kragen/bubble.html>
To e-mail me, remove "_rm"
------------------------------
Date: Wed, 22 Sep 1999 03:54:34 GMT
From: topalli@my-deja.com
Subject: Re: Which are the best books for learning Perl for use in a Web environment?
Message-Id: <7s9jtn$g32$1@nnrp1.deja.com>
Two books that have been very helpful for me have been
PERL and CGI for the world wide web a visual quickstart guide by peachpit
press. Very easy to read with many interesting examples. A very clear
book. www.cookwood.com/perl
Perl5 for web professionals (www.phptr.com/essential) by brown, bellow,
livingston prentice hall. Also a cleat guide. It has the benefit of
explaining _Every_ line of code in every example.
the web sites have large parts of the book republished see for yourself.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 872
*************************************