[18208] in Perl-Users-Digest
Perl-Users Digest, Issue: 376 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 28 14:06:04 2001
Date: Wed, 28 Feb 2001 11:05:25 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983387125-v10-i376@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 28 Feb 2001 Volume: 10 Number: 376
Today's topics:
Attachments <todd@mrnoitall.com>
fork() and ActiveState Perl - workarounds? (Win32 prog (Kenny McCormack)
Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari <comdog@panix.com>
Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Ben Okopnik)
Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Kenny McCormack)
Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Kenny McCormack)
Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Anno Siegel)
How can I search and delete a specific name in a textfi <fabian@markisspecialisten.com>
Re: How can I search and delete a specific name in a te (Tony L. Svanstrom)
Re: How the CLPM turns (Randal L. Schwartz)
Re: Is there A Perl "wrapper" for windows/Apache?? <somewhere@planet.earth>
Learning Perl and I need help. <remalone@sympatico.ca>
Re: Learning Perl and I need help. (Jon Bell)
Re: Learning Perl and I need help. (Arvid Warnecke)
Re: Learning Perl and I need help. nobull@mail.com
Re: Learning Perl and I need help. <mjcarman@home.com>
Re: Learning Perl and I need help. (Ben Okopnik)
Re: Learning Perl <davedavis69@yahoo.com>
Net::Telnet to AS/400 <dallas@haysmed.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 Feb 2001 10:46:18 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Attachments
Message-Id: <3A9D2A7B.DA7B5DC8@mrnoitall.com>
Dear Sirs,
I use the code below to send email with attachments. However when
sending to more than 1 recipient, the code does not recognize the new
"$to" and sends the second email to the first recipient. So the first
recipient gets 2 emails. And then some times on the second email the
attachment file appears to be empty and so it doesn't get attached. Any
ideas?
Thanks in advance for your help.
##########
sub send_email{
use MIME::Base64 qw(encode_base64); #Attachements
my %mime =
(
#-------------------------------------<TEXT>-----
'HTML',"text/html",
'HTM',"text/html",
'STM',"text/html",
'SHTML',"text/html",
'TXT',"text/plain",
'PREF',"text/plain",
'AIS',"text/plain",
'RTX',"text/richtext",
'TSV',"text/tab-separated-values",
'NFO',"text/warez-info",
'ETX',"text/x-setext",
'SGML',"text/x-sgml",
'SGM',"text/x-sgml",
'TALK',"text/x-speech",
'CGI',"text/plain",
'PL',"text/plain",
#-------------------------------------<IMAGE>----
'COD', "image/cis-cod",
'FID', "image/fif",
'GIF', "image/gif",
'ICO', "image/ico",
'IEF', "image/ief",
'JPEG', "image/jpeg",
'JPG', "image/jpeg",
'JPE', "image/jpeg",
'PNG', "image/png",
'TIF', "image/tiff",
'TIFF', "image/tiff",
'MCF',"image/vasa",
'RAS',"image/x-cmu-raster",
'CMX',"image/x-cmx",
'PCD',"image/x-photo-cd",
'PNM',"image/x-portable-anymap",
'PBM',"image/x-portable-bitmap",
'PGM',"image/x-portable-graymap",
'PPM',"image/x-portable-pixmap",
'RGB',"image/x-rgb",
'XBM',"image/x-xbitmap",
'XPM',"image/x-xpixmap",
'XWD',"image/x-xwindowdump",
#-------------------------------------<APPS>-----
'EXE',"application/octet-stream",
'BIN',"application/octet-stream",
'DMS',"application/octet-stream",
'LHA',"application/octet-stream",
'CLASS',"application/octet-stream",
'DLL',"application/octet-stream",
'AAM',"application/x-authorware-map",
'AAS',"application/x-authorware-seg",
'AAB',"application/x-authorware-bin",
'VMD',"application/vocaltec-media-desc",
'VMF',"application/vocaltec-media-file",
'ASD',"application/astound",
'ASN',"application/astound",
'DWG',"application/autocad",
'DSP',"application/dsptype",
'DFX',"application/dsptype",
'EVY',"application/envoy",
'SPL',"application/futuresplash",
'IMD',"application/immedia",
'HQX',"application/mac-binhex40",
'CPT',"application/mac-compactpro",
'DOC',"application/msword",
'ODA',"application/oda",
'PDF',"application/pdf",
'AI',"application/postscript",
'EPS',"application/postscript",
'PS',"application/postscript",
'PPT',"application/powerpoint",
'RTF',"application/rtf",
'APM',"application/studiom",
'XAR',"application/vnd.xara",
'ANO',"application/x-annotator",
'ASP',"application/x-asap",
'CHAT',"application/x-chat",
'BCPIO',"application/x-bcpio",
'VCD',"application/x-cdlink",
'TGZ',"application/x-compressed",
'Z',"application/x-compress",
'CPIO',"application/x-cpio",
'PUZ',"application/x-crossword",
'CSH',"application/x-csh",
'DCR',"application/x-director",
'DIR',"application/x-director",
'DXR',"application/x-director",
'FGD',"application/x-director",
'DVI',"application/x-dvi",
'LIC',"application/x-enterlicense",
'EPB',"application/x-epublisher",
'FAXMGR',"application/x-fax-manager",
'FAXMGRJOB',"application/x-fax-manager-job",
'FM',"application/x-framemaker",
'FRAME',"application/x-framemaker",
'FRM',"application/x-framemaker",
'MAKER',"application/x-framemaker",
'GTAR',"application/x-gtar",
'GZ',"application/x-gzip",
'HDF',"application/x-hdf",
'INS',"application/x-insight",
'INSIGHT',"application/x-insight",
'INST',"application/x-install",
'IV',"application/x-inventor",
'JS',"application/x-javascript",
'SKP',"application/x-koan",
'SKD',"application/x-koan",
'SKT',"application/x-koan",
'SKM',"application/x-koan",
'LATEX',"application/x-latex",
'LICMGR',"application/x-licensemgr",
'MAILPIPE',"application/x-mailfolder",
'MIF',"application/x-mailfolder",
'NC',"application/x-netcdf",
'CDF',"application/x-netcdf",
'SDS',"application/x-onlive",
'SGI-LPR',"application/x-sgi-lpr",
'SH',"application/x-sh",
'SHAR',"application/x-shar",
'SWF',"application/x-shockwave-flash",
'SPRITE',"application/x-sprite",
'SPR',"application/x-sprite",
'SIT',"application/x-stuffit",
'SV4CPIO',"application/x-sv4cpio",
'SV4CRC',"application/x-sv4crc",
'TAR',"application/x-tar",
'TARDIST',"application/x-tardist",
'TCL',"application/x-tcl",
'TEX',"application/x-tex",
'TEXINFO',"application/x-texinfo",
'TEXI',"application/x-texinfo",
'T',"application/x-troff",
'TR',"application/x-troff",
'TROFF',"application/x-troff",
'MAN',"application/x-troff-man",
'ME',"application/x-troff-me",
'MS',"application/x-troff-ms",
'TVM',"application/x-tvml",
'TVM',"application/x-tvml",
'USTAR',"application/x-ustar",
'SRC',"application/x-wais-source",
'WKZ',"application/x-wingz",
'ZIP',"application/x-zip-compressed",
'ZTARDIST',"application/x-ztardist",
#-------------------------------------<AUDIO>----
'AU',"audio/basic",
'SND',"audio/basic",
'ES',"audio/echospeech",
'MID',"audio/midi",
'KAR',"audio/midi",
'MPGA',"audio/mpeg",
'MP2',"audio/mpeg",
'TSI',"audio/tsplayer",
'VOX',"audio/voxware",
'AIF',"audio/x-aiff",
'AIFC',"audio/x-aiff",
'AIFF',"audio/x-aiff",
'MID',"audio/x-midi",
'MP3',"audio/x-mpeg",
'MP2A',"audio/x-mpeg2",
'MPA2',"audio/x-mpeg2",
'M3U',"audio/x-mpegurl",
'MP3URL',"audio/x-mpegurl",
'PAT',"audio/x-pat",
'RAM',"audio/x-pn-realaudio",
'RPM',"audio/x-pn-realaudio-plugin",
'RA',"audio/x-realaudio",
'SBK',"audio/x-sbk",
'STR',"audio/x-str",
'WAV',"audio/x-wav",
#-------------------------------------<VIDEO>----
'MPEG',"video/mpeg",
'MPG',"video/mpeg",
'MPE',"video/mpeg",
'QT',"video/quicktime",
'MOV',"video/quicktime",
'VIV',"video/vivo",
'VIVO',"video/vivo",
'MPS',"video/x-mpeg-system",
'SYS',"video/x-mpeg-system",
'MP2V',"video/x-mpeg2",
'MPV2',"video/x-mpeg2",
'AVI',"video/x-msvideo",
'MV',"video/x-sgi-movie",
'MOVIE',"video/x-sgi-movie",
#-------------------------------------<EXTRA>----
'PDB',"chemical/x-pdb",
'XYZ',"chemical/x-pdb",
'CHM',"chemical/x-cs-chemdraw",
'SMI',"chemical/x-daylight-smiles",
'SKC',"chemical/x-mdl-isis",
'MOL',"chemical/x-mdl-molfile",
'RXN',"chemical/x-mdl-rxn",
'SMD',"chemical/x-smd",
'ACC',"chemical/x-synopsys-accord",
'ICE',"x-conference/x-cooltalk",
'SVR',"x-world/x-svr",
'WRL',"x-world/x-vrml",
'VRML',"x-world/x-vrml",
'VRJ',"x-world/x-vrt",
'VRJT',"x-world/x-vrt",
);
$sender = "$user\@$Serv";
open (MAILPIPE,"|$sendmail $to") || order_error("Sorry! There's a big
line at the post office. Try again in a minute");
$message_header .= "From: $sender\n";
$message_header .= "To: $to\n";
$message_header .= "Subject: $form_data{'subj'}\n";
$message_header .= "Date: " . SentDate() . "\n";
$message_header .= "X-Mailer: \"$program_name\"\n";
$message_header .= "MIME-Version: 1.0\n";
$message_header .= "Content-Type: multipart/mixed;\n";
$boundary = "a_=docuharbor-=_fax.document=--" . time;
$message_header .= "\tboundary=\"$boundary\"\n";
print MAILPIPE "$message_header\n";
$temp = "This is a MIME encoded message.\n\n";
$temp .= "--$boundary\n";
$temp .= "Content-Type: text/plain;
charset=\"US-ASCII\"\n\n$form_data{'message'}\n";
print MAILPIPE $temp;
foreach $attachment (@document_name){#######################
$attachment =~ s/.*?([^\\\/:]+)$/$1/;
$full_path =
"$path/members/$session_username/$form_data{'db_id'}/$attachment";
next unless (-e $full_path); # make sure it's there
if (-T $full_path) {
open (ATTACH,"<$full_path") or next; # if open fails, go to next one
$temp = "--$boundary\n";
$type = 'plain';
$attachment =~ /.*\.(.*)$/;
if ($1 =~ /^htm/) {
$type = 'html';
}
$temp .= "Content-Type: text/$type;\n\tname=\"$attachment\"\n";
$temp .= "Content-Disposition:
inline;\n\tfilename=\"$attachment\"\n";
$temp .= "\n";
print MAILPIPE $temp;
while (<ATTACH>) {
print MAILPIPE $_;
}
close ATTACH;
print MAILPIPE \n;
}
else {# it's not a text file
open (ATTACH,"<$full_path") or next;
$temp = "";
$temp .= "--$boundary\n";
$attachment =~ /[^.]*\.(.*)$/;
$type = $mime{$1} || 'application/x-whatever';
$temp .= "Content-Type: $type;\n\tname=\"$attachment\"\n";
$temp .= "Content-Disposition:
inline;\n\tfilename=\"$attachment\"\n";
$temp .= "Content-Transfer-Encoding: base64\n";
$temp .= "\n";
print MAILPIPE $temp || order_error("Can not print mail pipe1");
$temp = "";
while (read(ATTACH, $buf, 60*57)) {
$temp .= encode_base64($buf); # Code it up baby
}
close ATTACH;
print MAILPIPE "$temp,\n" || order_error("Can not print mail
pipe2");
}
print MAILPIPE "--$boundary--" || order_error("Can not print mail
pipe3");
print MAILPIPE "\n" || order_error("Can not print mail pipe5");
}#foreach#######################################
print MAILPIPE "\n.\n" || order_error("Can not print mail pipe4");
close MAILPIPE || order_error("Can not close mail pipe1");
$full_path = "";
$to = "";
}
#########
------------------------------
Date: 28 Feb 2001 11:55:45 -0600
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: fork() and ActiveState Perl - workarounds? (Win32 programming question)
Message-Id: <97je31$mb1$1@yin.interaccess.com>
I am using ActiveState build 522 (Yes, I know it is a little old, but deal
with it - if a later version will fix the problem, that's to the good)
I am porting some Unix networking code (really, just the examples from the
Camel book) and the standard Unix model for a TCPIP server is: Accept the
connection, then fork() off a child to service it (using the open file
inheritance semantics of Unix) - so that the parent can accept further
connections.
Well, as you know, fork() is unimplemented in ActiveState - what is the
generally accepted work around for this? I assume if I used system() or
"start" to spawn a child, that it wouldn't inherit the open socket.
Also, what other Win32 ports of Perl are there? Other threads here mention
a Cygwin port - I've used the Cygwin gcc compiler - and I know that it has
fork(), but that it only works under NT (when I run my program that has fork
under Win98, it GPFs)
Anyway, suggestions?
------------------------------
Date: Wed, 28 Feb 2001 12:05:20 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <comdog-987647.12052028022001@news.panix.com>
In article <97j9qs$leh$1@yin.interaccess.com>, gazelle@interaccess.com
wrote:
> I don't think there is any point in continuing this in flame-war mode. I
> stated my conditions up front and people have seen fit to show their lack of
> reading comprehension skills. All I can say is that I assume that most
> people who post to the Usenet have some kind of mathematical background and
> understand the concept of "Here are the postulates you can use - here are
> the rules - now solve the problem". It is as if I gave you a simple problem
> in geometry and said "solve it using only straightedge and compass". I
> don't care if you like those rules, but they are the rules.
this is not mathematics. if you want to masturbate about theorems and
proofs and systems that's fine. most of us, however, live in the real
world. real world solutions often involve cleverness and indirect
solutions. it is often the postulates that are the problem, just as in
this case.
> And what you say above about defining my own problem is nothing short of
> outrageous. This is my thread. Of course I get to define the problem.
we are not, however, your students or your employees. you can't
assign work.
if you don't like it, take "your" thread elsewhere. we'll keep getting
work done and you'll keep doing whatever it is you do in the mean time.
--
brian d foy <comdog@panix.com>
------------------------------
Date: 28 Feb 2001 17:11:50 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <slrn99qcgm.p5h.ben-fuzzybear@Odin.Thor>
The ancient archives of 28 Feb 2001 10:43:08 -0600 showed
Kenny McCormack of comp.lang.perl.misc speaking thus:
>
>I
>stated my conditions up front and people have seen fit to show their lack of
>reading comprehension skills. All I can say is that I assume that most
>people who post to the Usenet have some kind of mathematical background and
>understand the concept of "Here are the postulates you can use - here are
>the rules - now solve the problem".
[ ... ]
>And what you say above about defining my own problem is nothing short of
>outrageous. This is my thread. Of course I get to define the problem. And
>of course, I get to flame people who decide to solve some other problem in
>my thread.
Your assumptions are wrong, your concepts idiotic, your arrogance
astounding, your comprehension of Usenet minimal, your mode of
communication infantile, and your plonk rating maximal.
Have A Nice Day.
*plonk!*
Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
It comes to pass oft that a terrible oath, with a swaggering accent sharply
twang'd off, gives manhood more approbation than ever proof itself would
have earned him. -- William Shakespeare
------------------------------
Date: 28 Feb 2001 11:32:47 -0600
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97jcnv$m0p$1@yin.interaccess.com>
In article <comdog-987647.12052028022001@news.panix.com>,
brian d foy <comdog@panix.com> felt compelled to opine:
...
>this is not mathematics. if you want to masturbate about theorems and
>proofs and systems that's fine. most of us, however, live in the real
>world. real world solutions often involve cleverness and indirect
>solutions. it is often the postulates that are the problem, just as in
>this case.
It is hysterical that you should say this. I have been arguing that
although "install Perl (completely)" may be the theoretically correct
answer, the fact is that in the real world, you may have to make do with
less. Part of living in the real world is accepting that you may not be
able to get your clients to install huge development environments on their
systems just to run one little application.
>> And what you say above about defining my own problem is nothing short of
>> outrageous. This is my thread. Of course I get to define the problem.
>
>we are not, however, your students or your employees. you can't
>assign work.
Did I misunderstand something? Am I paying you to participate in this
thread? If you don't like my assumptions, why are you bothering? You tell
me who's playing with themselves and/or whose got lots of time on their
hands.
- KM, Yours for a better Usenet -
------------------------------
Date: 28 Feb 2001 10:43:08 -0600
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97j9qs$leh$1@yin.interaccess.com>
In article <Pine.LNX.4.30.0102281547020.18159-100000@lxplus003.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
...
>> People can flame all they want that this is
>> a "broken" installation of Perl, but I don't care. It cuts no ice with me.
>
>Suit yourself, but if you define your own problem, then you have to be
>willing to take the consequences, and one of those consequences is
>that some people will advise you that you have set (or were set) a
>goal that is unrealistic, impractical, inappropriate, etc.
>
>If I tried to run a C compiler without any header files, then I'd be
>in a very analogous quandry. I wouldn't be blaming that on the C
>language usenet group, though.
>
I don't think there is any point in continuing this in flame-war mode. I
stated my conditions up front and people have seen fit to show their lack of
reading comprehension skills. All I can say is that I assume that most
people who post to the Usenet have some kind of mathematical background and
understand the concept of "Here are the postulates you can use - here are
the rules - now solve the problem". It is as if I gave you a simple problem
in geometry and said "solve it using only straightedge and compass". I
don't care if you like those rules, but they are the rules.
And what you say above about defining my own problem is nothing short of
outrageous. This is my thread. Of course I get to define the problem. And
of course, I get to flame people who decide to solve some other problem in
my thread.
So, just to re-iterate, solutions that involve external files may be
solutions to some other problem, but are not solutions to the problem under
discussion in this thread. You might as well ask me to sprout wings and
learn to fly.
------------------------------
Date: 28 Feb 2001 17:16:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97jbpr$2qf$1@mamenchi.zrz.TU-Berlin.DE>
[Newsgroups trimmed]
According to Kenny McCormack <gazelle@interaccess.com>:
> In article <Pine.LNX.4.30.0102281547020.18159-100000@lxplus003.cern.ch>,
> Alan J. Flavell <flavell@mail.cern.ch> wrote:
> ...
> >> People can flame all they want that this is
> >> a "broken" installation of Perl, but I don't care. It cuts no ice with me.
> >
> >Suit yourself, but if you define your own problem, then you have to be
> >willing to take the consequences, and one of those consequences is
> >that some people will advise you that you have set (or were set) a
> >goal that is unrealistic, impractical, inappropriate, etc.
> >
> >If I tried to run a C compiler without any header files, then I'd be
> >in a very analogous quandry. I wouldn't be blaming that on the C
> >language usenet group, though.
> >
>
> I don't think there is any point in continuing this in flame-war mode. I
Oh. If this is your response to Alan's calm objections you haven't
seen flame war. Your remark about reading comprehension is more
like it.
> stated my conditions up front and people have seen fit to show their lack of
> reading comprehension skills. All I can say is that I assume that most
> people who post to the Usenet have some kind of mathematical background and
> understand the concept of "Here are the postulates you can use - here are
> the rules - now solve the problem". It is as if I gave you a simple problem
> in geometry and said "solve it using only straightedge and compass". I
> don't care if you like those rules, but they are the rules.
Welcome to Usenet. You post and people respond as they see fit.
You don't get to say: This part of my posting is postulates and
can't be discussed.
In your case, the favored reply to your postulates was "They're rubbish",
and I concur, just in case you wanted to hear it again.
> And what you say above about defining my own problem is nothing short of
> outrageous. This is my thread. Of course I get to define the problem. And
> of course, I get to flame people who decide to solve some other problem in
> my thread.
No sir. Just because you started a thread doesn't mean you own it.
In fact, you just *saw* you don't. Welcome to Usenet.
> So, just to re-iterate, solutions that involve external files may be
> solutions to some other problem, but are not solutions to the problem under
> discussion in this thread. You might as well ask me to sprout wings and
> learn to fly.
Go away.
Anno
------------------------------
Date: Wed, 28 Feb 2001 16:55:56 GMT
From: "Fabian Thorbjörnsson" <fabian@markisspecialisten.com>
Subject: How can I search and delete a specific name in a textfile.
Message-Id: <w4an6.20952$AH6.2863370@newsc.telia.net>
My form sends this "$FORM{'name'}" to a perl script to add names etc.
I would like som help to create a simple "search and delete" script.
Thanks!
--
MVH
Markisspeciaisten
Fabian Thorbjörnsson
08-252500
------------------------------
Date: Wed, 28 Feb 2001 18:09:14 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: How can I search and delete a specific name in a textfile.
Message-Id: <1epjzrn.1rf8c3h1dybw42N%tony@svanstrom.com>
Fabian Thorbjörnsson <fabian@markisspecialisten.com> wrote:
> My form sends this "$FORM{'name'}" to a perl script to add names etc.
>
> I would like som help to create a simple "search and delete" script.
Anställ någon (mig ;) som fixar allt åt dig istället, det går otroligt
mycket snabbare och blir billigare om man ser på tiden du annars måste
lägga ner på att lösa små problem som för någon som kan det skrivs på
väldigt kort tid.
Translation:
Hire someone (me), it will save you a buck or two in the long run. [*]
/Tony
[*] Ok, so I was a lil bit lazy with the translation, but that covers
it. =)
------------------------------
Date: 28 Feb 2001 09:23:45 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How the CLPM turns
Message-Id: <m17l2a67ry.fsf@halfdome.holdit.com>
>>>>> "mothra" == mothra <mothra@nowhereatall.com> writes:
mothra> How about:
mothra> How to extract MIME encoded e-mail
Already done in a couple of different ways (a poor-man's CVS system,
and getting rid of the evilness that is HTML-alternative email).
mothra> How to spell check a textform field
Hmm. An idea for a snippet, but perhaps not a full program,
so I'll file this in the "when I'm doing things to a form, what's
one of them".
And you don't get credit if you post spamproofed addresses to Usenet
(hint hint).
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 28 Feb 2001 17:17:20 +0100
From: "Dimitri Gunsing" <somewhere@planet.earth>
Subject: Re: Is there A Perl "wrapper" for windows/Apache??
Message-Id: <97j89s$pst$1@omaha.pbnec.nl>
I believe it was called 'mod_perl' for Apache. Don't know if it runs under
windows though.
I use PerlEx at work and it works great since you can use persistent
connections.
Me <ja@nee.snee> wrote in message
news:QP9B9YVoAHA.379@asd24-aux-005.raketnet.nl...
> Hi Folks,
>
> Could anyone point me in the right direction for a perl-wrapper for Apache
> for win32?
> I found a nice wrapper, called "PerlEx". What it does is let perl.exe be
> resident in memory, thereby creating an enormous perl-execution-speed
(they
> talk about 50x speed improvement) because windows doesn't need to fire-up
> perl anymore.....
> That's the theory.....
>
> Anyaone has/knows something similar?
>
> Thank you!!
>
> Michel
> WebMaster@NetStyle.NL
>
>
------------------------------
Date: Wed, 28 Feb 2001 16:34:31 GMT
From: "Rick M" <remalone@sympatico.ca>
Subject: Learning Perl and I need help.
Message-Id: <rM9n6.261720$Pm2.4067910@news20.bellglobal.com>
From a shell scripter to a perl programmer in 24 hours. Not likely!
Its tough, trying to do in Perl what I used to do in shell, but I'm not
giving up.
How can I do this?
if $string exists in @arr do this else do something else.
I read
perlfaq4/How_can_I_tell_whether_a_list_or_array_contains_a_certain_element_.
html
and much more but I still can't quite get my tongue around it.
I tried this on my HP-UX 10.20 machine using perl v5.6.0
#!/opt/perl5/bin/perl -w
@FILES = ('file1', 'file2', 'file3', 'file4', 'file5');
print "@FILES\n";
print "Please select a file.\n";
chomp ($USERS_CHOICE = <STDIN>); # A string (file name) selected by user
if ($USERS_CHOICE eq $FILES[$USERS_CHOICE])
{
print "Good choice. Go to the next step.\n";
}
else
{
print "Sorry! That file does not exist.\n;
print "Please select another file.\n";
}
The output I get when $USERS_CHOICE = file1 is
Argument "file1" isn't numeric in array element at ./program.pl line 6,
<STDIN> line 1.
Good choice. Go to the next step.
This seems to give me the desired result except for the warning.
What do I have to change?
Thanks
Rick Malone
------------------------------
Date: Wed, 28 Feb 2001 17:12:03 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Learning Perl and I need help.
Message-Id: <G9H943.MFy@presby.edu>
In article <rM9n6.261720$Pm2.4067910@news20.bellglobal.com>,
Rick M <remalone@sympatico.ca> wrote:
>
>I tried this on my HP-UX 10.20 machine using perl v5.6.0
>
> #!/opt/perl5/bin/perl -w
> @FILES = ('file1', 'file2', 'file3', 'file4', 'file5');
> print "@FILES\n";
> print "Please select a file.\n";
> chomp ($USERS_CHOICE = <STDIN>); # A string (file name) selected by user
> if ($USERS_CHOICE eq $FILES[$USERS_CHOICE])
> {
> print "Good choice. Go to the next step.\n";
> }
> else
> {
> print "Sorry! That file does not exist.\n;
> print "Please select another file.\n";
> }
>
>The output I get when $USERS_CHOICE = file1 is
> Argument "file1" isn't numeric in array element at ./program.pl line 6,
><STDIN> line 1.
That's because array indices are numeric. You can think of the array
@FILES as a collection of variables: $FILES[0] contains the string
'file1', $FILES[1] contains the string 'file2', etc.
The online documentation that comes with Perl describes several methods
for determining whether an array contains a specified item. Do a 'perldoc
perlfaq4' and search for the question "How can I tell whether an array
contains a certain element?" If you don't have Perl installed on your own
computer, you can find a HTMLized version of the docs at
<http://www.perl.com/>.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
------------------------------
Date: Wed, 28 Feb 2001 18:36:12 +0100
From: arvid.warnecke@tu-clausthal.de (Arvid Warnecke)
Subject: Re: Learning Perl and I need help.
Message-Id: <cucj79.ln8.ln@heim2.tu-clausthal.de>
Hello!
In article <rM9n6.261720$Pm2.4067910@news20.bellglobal.com>, Rick M wrote:
>
> #!/opt/perl5/bin/perl -w
> @FILES = ('file1', 'file2', 'file3', 'file4', 'file5');
> print "@FILES\n";
> print "Please select a file.\n";
> chomp ($USERS_CHOICE = <STDIN>); # A string (file name) selected by user
> if ($USERS_CHOICE eq $FILES[$USERS_CHOICE])
I am not really sure about it, coz I am beginner, too, but I think you
have to use if($USERS_CHOICE eq $FILES{$USERS_CHOICE})
Hope that will work,
Arvid
--
.''`. ---------------------------------------------------
: :' : [Arvid Warnecke] [Mad-Hatter@BritneySpearsMail.Com]
`. `' [ICQ 55906559] [05323-715724] [ www.mad-hatter.de ]
`-----------------> Linux 2.4.2 Uptime: 22:14
------------------------------
Date: 28 Feb 2001 17:38:43 +0000
From: nobull@mail.com
Subject: Re: Learning Perl and I need help.
Message-Id: <u9wvaaoggs.fsf@wcl-l.bham.ac.uk>
"Rick M" <remalone@sympatico.ca> writes:
> How can I do this?
> if $string exists in @arr do this else do something else.
>
> I read
> perlfaq4/How_can_I_tell_whether_a_list_or_array_contains_a_certain_element_.
> I tried this...
[snip code nothing like what the above FAQ answer]
Why? Why didn't you try something like what the FAQ tells you to do>
Actually the grep solution that the FAQ tells you not to use will
work and is a good solution if the array is small and you only want to
check one value.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 28 Feb 2001 11:34:20 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Learning Perl and I need help.
Message-Id: <3A9D369C.80B59129@home.com>
Rick M wrote:
>
> #!/opt/perl5/bin/perl -w
Good to see -w! Now read up on 'use strict'.
> @FILES = ('file1', 'file2', 'file3', 'file4', 'file5');
> print "@FILES\n";
> print "Please select a file.\n";
> chomp ($USERS_CHOICE = <STDIN>); # A string (file name) selected by user
>
> if ($USERS_CHOICE eq $FILES[$USERS_CHOICE])
You're trying to use a string as an index into an array. You can't do
that, and that's exactly what perl told you:
> Argument "file1" isn't numeric in array element at ./program.pl
> line 6,
If you'd like more detailed warnings, add 'use diagnostics;' after your
shebang line.
> This seems to give me the desired result except for the warning.
Did you try it with 'file2'?
> What do I have to change?
One simple method to do what you want is to just loop through the array
looking for a match:
my $found = 0;
foreach my $file (@FILES) {
if ($USER_CHOICE eq $file) {
$found = 1;
last;
}
}
if ($found) {
print "Good choice. Go to the next step.\n";
}
# ...
If you'll want to do multiple checks, or if your array gets large,
you're probably better off using a hash.
-mjc
------------------------------
Date: 28 Feb 2001 18:28:53 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: Learning Perl and I need help.
Message-Id: <slrn99qgsg.p5h.ben-fuzzybear@Odin.Thor>
The ancient archives of Wed, 28 Feb 2001 16:34:31 GMT showed
Rick M of comp.lang.perl.misc speaking thus:
>From a shell scripter to a perl programmer in 24 hours. Not likely!
>Its tough, trying to do in Perl what I used to do in shell, but I'm not
>giving up.
>
>How can I do this?
>if $string exists in @arr do this else do something else.
>
>I read
>perlfaq4/How_can_I_tell_whether_a_list_or_array_contains_a_certain_element_.
>html
>and much more but I still can't quite get my tongue around it.
>
>I tried this on my HP-UX 10.20 machine using perl v5.6.0
>
> #!/opt/perl5/bin/perl -w
Good call, using "-w". Bad call, not using "use strict". Some people use
"strict" anytime they've got user input in a program; from hanging out in
here, I'm getting into the habit of using it in almost all my Perl coding.
It enforces some good coding habits, and can't hurt anything. See "perldoc
strict".
> @FILES = ('file1', 'file2', 'file3', 'file4', 'file5');
> print "@FILES\n";
> print "Please select a file.\n";
> chomp ($USERS_CHOICE = <STDIN>); # A string (file name) selected by user
> if ($USERS_CHOICE eq $FILES[$USERS_CHOICE])
^^^^^^^^^^^^^^^^^^^^
Something like this would work in a hash, but array members are addressed by
their _index,_ not a string. Also, a style note (from the "perlstyle" man
page):
* You may find it helpful to use letter case to indicate the scope
or nature of a variable. For example:
$ALL_CAPS_HERE constants only (beware clashes with perl vars!)
$Some_Caps_Here package-wide global/static
$no_caps_here function scope my() or local() variables
> {
> print "Good choice. Go to the next step.\n";
> }
> else
> {
> print "Sorry! That file does not exist.\n;
^^^
Don't retype code. *Please*, copy and paste only; we do not want to fix
problems only to find that they were caused by retyping errors.
> print "Please select another file.\n";
> }
>
>The output I get when $USERS_CHOICE = file1 is
> Argument "file1" isn't numeric in array element at ./program.pl line 6,
><STDIN> line 1.
> Good choice. Go to the next step.
>
>This seems to give me the desired result except for the warning.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No, it doesn't. Have you tried entering a non-existant file name?
>What do I have to change?
Your understanding of how arrays work.
I would suggest a careful reading of the "perldata" man page, which
describes them, as well as other Perl data structures in detail.
Meanwhile, try this:
#!/opt/perl5/bin/perl -w
use strict;
my @files = qw( file1 file2 file3 file4 file5 );
print "@files\n";
print "Please select a file.\n";
chomp ( my $reply = <STDIN> );
if ( grep /^$reply$/, @files ) {
print "Good choice. Go to the next step.\n";
}
else {
print "Sorry! That file does not exist.\n";
}
Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
I want to die peacefully in my sleep like my grandfather - not screaming in
terror like his passengers. -- Jim Larkin
------------------------------
Date: Wed, 28 Feb 2001 11:17:16 -0600
From: Dave Davis <davedavis69@yahoo.com>
Subject: Re: Learning Perl
Message-Id: <3A9D329B.AF4073DC@yahoo.com>
Hello,
I took a course at http://www.useractive.com. It's an online course
with an online compiler also. They've got backing from the University
of Illinois to (CEU's I think). Course wasn't too shabby.
Hope it helps,
The Double D
Robert Clark wrote:
> How can i go about learning perl??
>
> --
> Steve Wright
>
> schumie@totalise.co.uk
------------------------------
Date: Wed, 28 Feb 2001 11:53:03 -0600
From: "Dallas Haselhorst" <dallas@haysmed.com>
Subject: Net::Telnet to AS/400
Message-Id: <97jdtl$mpe$1@iac5.navix.net>
Does anyone currently use Net::Telnet for telnetting to an AS/400? If so,
what type of configuration do you use? In addition, I've been unable to find
any modules that would do this. Any help on this matter would be greatly
appreciated, Dallas.
P.S. I'm able to telnet to the system and even run quite a few command as
long as I use all of the commands in a single cmd() statement (separated by
\n's and \t's of course); unfortunately, this method simply isn't very clean
and has lots of other flaws.
------------------------------
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 V10 Issue 376
**************************************