[7684] in Perl-Users-Digest
Perl-Users Digest, Issue: 1310 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 13 03:07:12 1997
Date: Thu, 13 Nov 97 00:00:36 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 13 Nov 1997 Volume: 8 Number: 1310
Today's topics:
./[script.pl] not working <tristram@freemail.c3.hu>
Re: Block comments in Perl? (Eric Bohlman)
Can Perl dial the phone? (S)
Cannot Opendir in NT? <lai@src.ncu.edu.tw>
CGI script to locate file on ISP server. <lkj@Lesbois.com>
Re: CGI script to locate file on ISP server. <itootall@earthlink.net>
Re: Finding "best fit" subset of a set? <wtansill@erols.com>
Re: Help subroutines! (John Moreno)
Re: How to use perl script to download exe file? (brian d foy)
Re: HTML Forms and Data Storage (Martien Verbruggen)
Re: htpasswd help! PLEASE! (brian d foy)
Re: Initiating Write from a CGI <webmaster@fccj.cc.fl.us>
Re: Open, File-handle problems. <webmaster@fccj.cc.fl.us>
Re: Open, File-handle problems. <westxga@ptsc.slg.eds.com>
Re: printing lines following the line with a match (Eric Bohlman)
Re: Proxy Authorization with LWP (Martien Verbruggen)
Re: Q: Wierd argument passing, bug? (brian d foy)
Re: Q: Wierd argument passing, bug? (Henry Gabryjelski)
QUESTION: How to do a string comparison? <xieyum@nortel.ca>
Re: QUESTION: How to do a string comparison? (brian d foy)
Sendmail without SENDMAIL <mcmapait@erols.com>
Re: Sendmail without SENDMAIL <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Socket.pm error message <apollock@bit.net.au>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 13 Nov 1997 08:26:42 +0100
From: Radix <tristram@freemail.c3.hu>
Subject: ./[script.pl] not working
Message-Id: <346AABB2.25C0@freemail.c3.hu>
Hello ppl,
I would like to have our web server run perl scripts using cgi on a
machine with sun solaris 2.6. Still, the script doesnt seem to work. Its
is placed in the cgi-bin dir. There are sample scripts coming with the
web server software [sun ws], however, they are not perl scripts,
instead something like this:
#!/usr/bin
echo "hello world"
They can be run from the shell with ./[script].
I have perl installed on the machine, so in the shell i can do:
perl [script.pl]
It runs the script. Still, i cant run it from ./[script.pl]. As I
understand it would be needed to implement perl scripts on the web
server.
Any help appreciated, thanks.
Radix
------------------------------
Date: Thu, 13 Nov 1997 03:08:04 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Block comments in Perl?
Message-Id: <ebohlmanEJKE1G.97@netcom.com>
Jim Turner (turnerj@cliffy.lmtas.lmco.com) wrote:
: Try this:
: goto RESUME;
: Type anything you want here, this will
: all be commented out.
: RESUME:
Neither this method nor the if(0){...} method truly "comment out" code.
The code will still be compiled, which is a problem if the commented-out
section contains syntax errors or, more importantly, incomplete
constructs or pseudo-code (or compile-time statements like use).
------------------------------
Date: 13 Nov 1997 00:55:01 -0700
From: se@primenet.com (S)
Subject: Can Perl dial the phone?
Message-Id: <346bb22f.1400897964@news.primenet.com>
Could someone please point me to more info/howto/module for getting
perl to dial a phone line.
I need to do this for Win95, NT4.0, and Linux
Thanks,
shawn
------------------------------
Date: Thu, 13 Nov 1997 15:27:10 +0800
From: lai <lai@src.ncu.edu.tw>
Subject: Cannot Opendir in NT?
Message-Id: <346AABCD.A3B5E573@src.ncu.edu.tw>
hi all,
My follow program always die at "opendir" in NT but never die in Unix.
What's wrong with me or with the program ? I has tried many many times
and cannot find why? Would anybody help me?
my $mydir="C:\\Inetpub\\wwwroot\\";
### I had tried C:\\Inetpub\\wwwroot";
### and even C:\Inetpub\wwwroot\;
read_dir($mydir);
sub read_dir
{
local($target_dir) = @_ ;
local($files);
return 0 if( !$target_dir );
opendir(DIR, $target_dir) || die "$target_dir: return 0 file";
@files=readdir(DIR);
closedir(DIR);
return @files;
}
Thanks
------------------------------
Date: Wed, 12 Nov 1997 20:35:40 -0700
From: John Long <lkj@Lesbois.com>
Subject: CGI script to locate file on ISP server.
Message-Id: <346A758C.74A5E492@Lesbois.com>
This is an invitation to hack.
My ISP can't seem to help me much on this, nice people
nevertheless. They have allowed me to install CGI scripts
at no extra charge, but the problem is where to place the
data files that the scripts will read to or write from(sic).
I've installed a script to help do this, which is called
from a web page. You (you) enter your guess as to the path
to a certain text file, and the CGI script looks for the
file on that path. If successful, displays the text file
and presents a button. Push the button and it mails me the
path. If not, it gives an error message.
To try it, go to http://www.lesbois.com/members/razzbar/testcgi.htm
I've tested it on my home server, and it works. Testing on
my ISP has me stumped. As well as my ISP...
Now, this might start somebody off on a long-winded lecture
about a few things. That would be nice, too!
Thanks,
LJ
------------------------------
Date: Thu, 13 Nov 1997 00:47:38 -0600
From: <itootall@earthlink.net>
Subject: Re: CGI script to locate file on ISP server.
Message-Id: <64e7fm$aer@ecuador.earthlink.net>
Does your IP have a CGI-BIN, and if not create one. Just make sure that the
file and folder are set to Admin: read-write-execute; Group: read-execute;
Other: read-execute. If you are not allowed to do this then change your IP.
chris@guardiancom.net
John Long wrote in message <346A758C.74A5E492@Lesbois.com>...
>This is an invitation to hack.
>
>My ISP can't seem to help me much on this, nice people
>nevertheless. They have allowed me to install CGI scripts
>at no extra charge, but the problem is where to place the
>data files that the scripts will read to or write from(sic).
>
>I've installed a script to help do this, which is called
>from a web page. You (you) enter your guess as to the path
>to a certain text file, and the CGI script looks for the
>file on that path. If successful, displays the text file
>and presents a button. Push the button and it mails me the
>path. If not, it gives an error message.
>
>To try it, go to http://www.lesbois.com/members/razzbar/testcgi.htm
>
>I've tested it on my home server, and it works. Testing on
>my ISP has me stumped. As well as my ISP...
>
>Now, this might start somebody off on a long-winded lecture
>about a few things. That would be nice, too!
>
>Thanks,
>LJ
------------------------------
Date: Thu, 13 Nov 1997 00:50:44 -0500
From: "William B. Tansill, III" <wtansill@erols.com>
Subject: Re: Finding "best fit" subset of a set?
Message-Id: <346A9534.1A96@erols.com>
samdie@ibm.net wrote:
>
> In <6482h7$1mg$1@shell3.ba.best.com>, on 11/10/97
> at 02:40 PM, mcravit@best.com (Matthew Cravit) said:
>
> > I'm in the process of writing a perl script to "stage" files for writing to
> > a CD-ROM, and I'd like to find a function/module which will, given an array
> > of integers, return the subset of them whose sum is closest to a specified
> > "target" value. In other words, given an array which contains the sizes of a
> > series of directories, I want it to return the subset of those directories
> > which most closely approximates 625 megs.
>
> > Does anyone know if a module exists that could do this? I didn't find
> > anything obvious on CPAN. Alternatively, could someone suggest an algorithm
> > that I could use to write my own?
>
> Can't make any specific suggestion but the problem is a classic in computer
> science and is usually refered to as "the bin packing problem". It may help if
> you use "bin" and "packing" as keywords in your searching.
>
> --
> -----------------------------------------------------------
> samdie@ibm.net 199711121143 -0500
I've also heard it called the Knapsack problem. HTH, Bill.
--
How do I set my laser printer to "stun"?
------------------------------
Date: Wed, 12 Nov 1997 22:37:13 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Help subroutines!
Message-Id: <1997111222280366611340N@roxboro-175.interpath.net>
Phil R Lawrence <prl2@lehigh.edu> wrote:
] Greg Bacon <gbacon@adtran.com> wrote in article
]
] > Character classes (like [0-9]) are only available within regular
] > expressions. You want to use numeric comparison here:
] >
] > sub check_input {
] > my $n = shift;
] >
] > if ($n >= 0 and $n <= 9) {
] > return 1;
] > }
] > else {
] > return 0;
] > }
] > }
]
] Is there anything wrong or depracated about using regular expressions
] in this case (where we're hoping to deal with a digit input?) Or is
] the following acceptable?
I don't think it's a problem in principle.
] sub check_input {
] my $n = shift;
]
] if ($n !~ /^[0-9]$/) {
] return 1;
] }
] else {
] return 0;
] }
] }
The problem is that you have the values reversed - and that it would
return a bad value for say 1a1 or even 11 since he's only dealing with
values between zero and nine.
--
John Moreno
------------------------------
Date: Wed, 12 Nov 1997 22:36:50 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: How to use perl script to download exe file?
Message-Id: <comdog-ya02408000R1211972236500001@news.panix.com>
[follow ups set, but i don't think it's going to help]
In article <01bcefdd$c784a0a0$511e09a8@weixiao>, "David" <mysun@mbox2.singnet.com.sg> wrote:
>My simplified perl script likes as follows:
>print "Location: http://www.mysite.com/pub/$filename\n\n";
>This script works fine with .doc,.txt and .zip, but not .exe file. The
>reason is that .exe file is interpreted as CGI script.
what did you expect?
why not zip the file so it can be a .zip too?
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
i smell a microsoft product...
------------------------------
Date: 13 Nov 1997 02:55:45 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: HTML Forms and Data Storage
Message-Id: <64dq7h$d3r$2@comdyn.comdyn.com.au>
In article <346A5889.B835D3DC@twnetwork.com>,
Thomas George <tgeorge@twnetwork.com> writes:
> Does anyone have a simple script for storing/appending data from
> web-based forms in an ascii file?
Use CGI.pm (should come with perl) to process whatever is entered in the form, open a file for writing or appening (perldoc -f open) and write to it (perldoc -f print).
Something along the lines
#!perl -w
use strict;
use CGI;
# Do here whatever you need to do to process the input to the CGI app
open (FF, '>some_file') or die "Cannot open file: $!"
# print your data to the file here
close (FF);
exit;
Also, read the faqs (especially part 9) and some more documentation.
Visit www.perl.com to find lots and lots of info.
> It doesn't seem like it would be difficult, but I have not yet had the
> time to learn the perl coding for such a task.
Not a problem. The best time to learn things is when you need them.
The best way to learn them is by first reading some stuff about it (in
the case of perl: in the documentation or a good book, titles
available from www.perl.com)
HTH
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd. | make a better idiot.
NSW, Australia |
------------------------------
Date: Wed, 12 Nov 1997 22:11:57 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: htpasswd help! PLEASE!
Message-Id: <comdog-ya02408000R1211972211570001@news.panix.com>
In article <64dcbk$a0f$1@goblin.uunet.ca>, Me@home.sleeping (Me) wrote:
>I'm currently trying to figure out how the heck
>I can re-create or at least emulate the
>htpasswd command in perl.
>
>essentially I want to be able to configure
>an .access file, without having to telnet
>into the server everytime.
configuring .htaccess is not the same as emulating the htpasswd
command, which manages the password file for you.
>Does anyone know exactly how servers
>salt their crypt of the password?
servers don't generate the crypt-ed passwords. external support
programs, such as htpasswd, do. salts can be chosen randomly.
>but what is the proper salt sequence?
there isn't a proper salt sequence. it's a two character string
(or the first two characters of the string you use). it can
be chosen randomly. the perlfunc manpage discusses this:
perldoc -f crypt
>Is the unencrypted password a combination of the
>unencrypted password and login?
no. it's just the crypt-ed password. you can also read the man
page on crypt to get more info.
bon chance :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
$RTFM_post{'brian d foy'}++;
------------------------------
Date: Wed, 12 Nov 1997 20:06:12 -0500
From: "Bill Jones" <webmaster@fccj.cc.fl.us>
Subject: Re: Initiating Write from a CGI
Message-Id: <346a5363.0@usenet.fccj.cc.fl.us>
This is a common problem in CGI - it caused by the script running as the web
server user and not as you (or root...)
Try setting the directory/file premissions accordingly :-)
Patrick Stacey wrote in message <34696740.41D2@mediacity.com.sg>...
>I can write a new file using a command-line driven script with the
>following:
>
>#test file
>print "Content-Type: text/html\n\n";
>print "printing file...";
>open(FILE, ">afile.txt");
>print FILE "some text";
>close(FILE);
>
>However, when I try to run this as a CGI it will not write!
>Why?
>
>Any offers of help please?
>
>many thanks
>
>
>Patrick
------------------------------
Date: Wed, 12 Nov 1997 21:09:31 -0500
From: "Bill Jones" <webmaster@fccj.cc.fl.us>
Subject: Re: Open, File-handle problems.
Message-Id: <346a623a.0@usenet.fccj.cc.fl.us>
Problem you're experiencing is not Perl-related, it is passwd related. The
'passwd' command will only accept input from the unix keyboard device. it
'knows' that input is appearing from elsewhere and is ignoring it.
You should try 'expect' from Don Libes; it was the only way to 'trick'
'passwd' into accepting input :-)
He can be found at -
http://www.mel.nist.gov/msidstaff/libes/
You can also find 'Expect' there,
Enjoy
Thomas Kajhoej wrote in message <64bqlc$1up$2@sunsite.auc.dk>...
>Hi there,
>
>I'm running perl 5.003 on a pc running linux (redhat 4.3).
>
>I'm trying to create a perlprogram that starts the program "passwd".
>I want to be able to change my password from within a perl program.
>I do the following:
>
> ...
> open PW, "|passwd";
> print PW "my_current_password\n";
> print PW "my_new_password\n";
> print PW "my_new_password\n";
> close PW
> ...
>
>But it does not work !?
>
>I found out that when i open the "passwd" command it asks for my curren
password, and
>thats fine, but when i type in my current_password "print PW
"my_current_password\n"
>it does not prompt me for my new password. When i close PW then it just
says that my new password is too short!
>
>What am i doing wrong?
>
>Hope you can help me.
>
>Thomas
>Email: kajhoej@kom.auc.dk
>
------------------------------
Date: Wed, 12 Nov 1997 11:22:56 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: Open, File-handle problems.
Message-Id: <34699190.6DB9@ptsc.slg.eds.com>
Thomas Kajhoej wrote:
>
> Hi there,
>
> I'm running perl 5.003 on a pc running linux (redhat 4.3).
>
> I'm trying to create a perlprogram that starts the program "passwd".
> I want to be able to change my password from within a perl program.
> I do the following:
>
> ...
> open PW, "|passwd";
> print PW "my_current_password\n";
> print PW "my_new_password\n";
> print PW "my_new_password\n";
> close PW
> ...
>
> But it does not work !?
>
> I found out that when i open the "passwd" command it asks for my curren password, and
> thats fine, but when i type in my current_password "print PW "my_current_password\n"
> it does not prompt me for my new password. When i close PW then it just says that my new password is too short!
>
> What am i doing wrong?
Your problem probably has to do with the fact that the passwd program
takes input from a device, not standard input. So you can associate a
file descriptor to a pipe all you want, but passwd will never read from
the pipe.
>
> Hope you can help me.
>
> Thomas
> Email: kajhoej@kom.auc.dk
------------------------------
Date: Thu, 13 Nov 1997 03:30:07 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: printing lines following the line with a match
Message-Id: <ebohlmanEJKF28.1F2@netcom.com>
Tad McClellan (tadmc@flash.net) wrote:
: PsyTours (psycler@netcom.com) wrote:
: : I am trying to parse a file where I look for pattern-matching
: : in a specific line and upon locating that line, that line and
: : the following 5 lines (only) get print to the output.
: while (defined ($line = <IN>)) {
: # if ($line =~ /[7-9][0-9]|Query/) {
: if ($line =~ /[7-9][0-9]/ || $line =~ /Query/) {
: print "$line\n";
: print scalar(<IN>);
: print scalar(<IN>);
: print scalar(<IN>);
: print scalar(<IN>);
: print scalar(<IN>);
: }
: }
Note that this code assumes that none of the following 5 lines should
themselves be checked for matches. If they should be checked, then make
the following changes:
replace the while with
while (defined &nextline) {
and the prints with
print &readline;
and add
sub nextline {
return shift @cache if @cache;
return scalar <IN>;
}
sub readline {
my $line=<IN>;
push @cache,$line if defined $line;
return $line;
}
Oh yeah, and add
use vars qw(cache);
at the top of the script.
------------------------------
Date: 13 Nov 1997 03:02:23 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Proxy Authorization with LWP
Message-Id: <64dqjv$d3r$3@comdyn.comdyn.com.au>
In article <64b813$1l9$1@lennon.postino.com>,
danny@lennon.postino.com (Danny Aldham) writes:
> I am using LWP version 5.10 , and am trying to go thru a
> Netscape Proxy server version 2.53 . I am getting an error
I use LWP and a netscape proxy, no problem.
> message that "Resolution of Proxy Authentication required,
> not yet implemented." Please tell me it ain't so, and point
> me to the correct syntax to get thru the firewall.
What did you use?
perldoc LWP::UserAgent
/proxy
----
$ua->proxy(...)
Set/retrieve proxy URL for a scheme:
$ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
$ua->proxy('gopher', 'http://proxy.sn.no:8001/');
----
If thisis what you did;
It might be that your proxy is configured to work on a
usercode/password authentication. The error message sort of indicates
that that is not implemented yet. Convince your site admin to
reconfigure the proxy, or write a patch for LWP::UserAgent that does
user authentication, and submit it.
> Thanks.
Sure.
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: Wed, 12 Nov 1997 22:28:40 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Q: Wierd argument passing, bug?
Message-Id: <comdog-ya02408000R1211972228400001@news.panix.com>
In article <64dj15$1ag$1@bigboote.WPI.EDU>, henryg@ernie.WPI.EDU (Henry Gabryjelski) wrote:
>brian d foy <comdog@computerdog.com> wrote:
[snip contortions]
>Wow! This is highly contorted, and certainly not what I expected to
are you referring to my post? i hope not - i took me an hour to
compose it :). contorted is the example i gave at the end. it is
truly a work of evil. when you start to think like perl, things
are easier.
>occur. My previous experience with arguments is that evaluation done
>left-to-right (as Perl, I once thought, is)
well, that's why you should be careful about expressions as arguments
to a function. i never ran into this problem because i've never done
things that way. ;)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
sorta like speaking Russian but thinking English
------------------------------
Date: 13 Nov 1997 05:57:30 GMT
From: henryg@ernie.WPI.EDU (Henry Gabryjelski)
Subject: Re: Q: Wierd argument passing, bug?
Message-Id: <64e4sa$cqm$1@bigboote.WPI.EDU>
brian d foy <comdog@computerdog.com> wrote:
>henryg@ernie.WPI.EDU (Henry Gabryjelski) wrote:
>>Wow! This is highly contorted, and certainly not what I expected to
>are you referring to my post? i hope not - i took me an hour to
>compose it :). contorted is the example i gave at the end. it is
>truly a work of evil. when you start to think like perl, things
>are easier.
Ah-ha! I have just re-read the post (again), and finally understand (I
think):
Passing arguments is a two-pass process, each pass done left-to-right:
1) Do any pre-use modifications. This includes function calls, ...,
and especially pre-increment and pre-decrement.
2) Put the next value into the list and eval any post-use
modifications. This is mostly post-inc/decrement.
So, you example would resolve:
k stack
0 print $k--, $k++, ++$k, --$k, "\n";
1 print $k--, $k++, $k, --$k, "\n";
0 print $k--, $k++, $k, $k, "\n";
now deal with post-operations:
0 print $k--, $k++, $k, $k, "\n";
-1 print 0, $k++, $k, $k, "\n";
0 print 0, -1, $k, $k, "\n";
0 print 0, -1, 0, $k, "\n";
0 print 0, -1, 0, 0, "\n";
which finally resolves to: "0-100\n".
>>occur. My previous experience with arguments is that evaluation done
>>left-to-right (as Perl, I once thought, is)
>well, that's why you should be careful about expressions as arguments
>to a function. i never ran into this problem because i've never done
I never do this sort of thing in 'real' code either, but it's still
interesting behaviour. Thanks, Brian, for the patient help you offer.
Henry Gabryjelski
------------------------------
Date: Wed, 12 Nov 1997 21:43:49 -0500
From: Yu Xie <xieyum@nortel.ca>
Subject: QUESTION: How to do a string comparison?
Message-Id: <346A6964.982E0C7A@nortel.ca>
--------------9DC00066D16557BCE64954E5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
hi, all:
I am right now workin on a little perl script. And i have a
question to you. Here it is: and I would like to know how do
a string comparison.
Does nil represents empty string, or it is something else?
Wnat is the comparison operator? Is it == or = or eq?
Is $nothing eq "nil"; correct? Or what is the correct way?
thanks!
Cheers
Xie
Email: xieyum@nortel.ca
--------------9DC00066D16557BCE64954E5
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
<PRE>hi, all:</PRE>
<PRE>I am right now workin on a little perl script. And i have a</PRE>
<PRE>question to you. Here it is: and I would like to know how do</PRE>
<PRE>a string comparison.</PRE>
<PRE>Does nil represents empty string, or it is something else?</PRE>
<PRE>Wnat is the comparison operator? Is it == or = or eq?</PRE>
<PRE>Is $nothing eq "nil"; correct? Or what is the correct way?</PRE>
<PRE></PRE>
<PRE></PRE>
<PRE>thanks!
Cheers
Xie
Email: xieyum@nortel.ca</PRE>
</HTML>
--------------9DC00066D16557BCE64954E5--
------------------------------
Date: Wed, 12 Nov 1997 22:33:55 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: QUESTION: How to do a string comparison?
Message-Id: <comdog-ya02408000R1211972233550001@news.panix.com>
In article <346A6964.982E0C7A@nortel.ca>, Yu Xie <xieyum@nortel.ca> wrote:
>I am right now workin on a little perl script. And i have a
>question to you. Here it is: and I would like to know how do
>a string comparison.
>
>Does nil represents empty string, or it is something else?
an empty string is a string with nothing in it:
$empty_string = '';
>Wnat is the comparison operator? Is it == or = or eq?
what did you find out from reading the perl man page? or the
perlop man page?
>Is $nothing eq "nil"; correct? Or what is the correct way?
what happened when you tried it?
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
$RTFM_post{'brian d foy'}++;
------------------------------
Date: Wed, 12 Nov 1997 22:38:12 -0500
From: MCM <mcmapait@erols.com>
Subject: Sendmail without SENDMAIL
Message-Id: <346A7624.11F2@erols.com>
Is there a perl script out there to send the contents of a form without
using the sendmail program. (For those of us not on UNIX platforms. I
have the unfortunate fortune of using Novell WebServer 2.51, which runs
earlier perl, not using a lot of the useful UNIX programs and ease of
use.) HELP. Novell support will not.
mcmapait@erols.com
------------------------------
Date: Wed, 12 Nov 1997 20:18:44 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Sendmail without SENDMAIL
Message-Id: <64dv2l$656@mtinsc04.worldnet.att.net>
There are several mail scripts out there that will let you send mail without
having access to sendmail, such as the one below. (I wish I could remember
who wrote it so I could credit them properly. :D) The main thing you need is
proper implementation of sockets and access to a SMTP server. Whether this
will work for you probably depends on the version of Perl your WebServer
implements. Also, be warned -- I haven't been able to get this to work
properly under Windows 95, but it works just fine under NT and MacPerl.
MCM wrote in message <346A7624.11F2@erols.com>...
>Is there a perl script out there to send the contents of a form without
>using the sendmail program. (For those of us not on UNIX platforms. I
>have the unfortunate fortune of using Novell WebServer 2.51, which runs
>earlier perl, not using a lot of the useful UNIX programs and ease of
>use.) HELP. Novell support will not.
>
>mcmapait@erols.com
=====================================================================
use Socket;
$crlf = "\015\012";
$xfrom = "sender\@wherever.com";
$xreply = "sender\@wherever.com"; # or your alternate reply address
$xto = "recipient\@mailbox.com";
$xsmtp = "yourmailserver.com";
$xsubject = "foo";
$xmessage = "<<HERE";
This is where you place your message. If you use HERE document syntax like
this, you can make the message pretty much any length you like, or you can
use another perl script to put your message into the 'xmessage' variable.
HERE
&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;
}
------------------------------
Date: Thu, 13 Nov 1997 16:54:33 +1000
From: "Andrew Pollock" <apollock@bit.net.au>
Subject: Socket.pm error message
Message-Id: <64e877$d68$1@hermes.bit.net.au>
On one particular machine, running a script that uses Net::Ping, I get this
error message:
Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16 at
/usr/lib/perl5/Socket.pm line 236.
This same script works fine on another machine.
I've tried reinstalling the Sockets module several times, and I can't solve
it.
It's running on a Linux box running Linux 2.0.31
The other box that the script works on is also running Linux 2.0.31
Any suggestions?
Regards
Andrew
--
----
Andrew Pollock Programmer/System Administrator
apollock@bit.net.au http://staff.bit.net.au/apollock
Brisbane Internet Technology Pty Ltd.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 1310
**************************************