[7275] in Perl-Users-Digest
Perl-Users Digest, Issue: 900 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 21 12:07:59 1997
Date: Thu, 21 Aug 97 09:00:22 -0700
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, 21 Aug 1997 Volume: 8 Number: 900
Today's topics:
"-T" problem after building 5.0004_01 <rayyu@cup.hp.com>
Re: "-T" problem after building 5.0004_01 (Michael Fuhr)
Re: Binary I/O: simple question? (Bart Lateur)
CGI Error, any ideas? george@adirondack.net
Re: changing perl to gibberish (Tad McClellan)
Re: Converting text to Excel data with UNIX <petri.backstrom@icl.fi>
Re: Converting text to Excel data with UNIX (Scott McMahan)
Re: Converting text to Excel data with UNIX (Scott McMahan)
Re: Filtering CR & CRLF from text input (Bart Lateur)
Re: Filtering CR & CRLF from text input <merlyn@stonehenge.com>
Re: Help reading massive file <rayyu@cup.hp.com>
help with CGI.pm and IIS <Michael_Drons@harvard.edu>
Re: HELP!!!!Please..... (Andrew M. Langmead)
Re: HELP: Perl5 on Novell Web Server 3.0 "Document Cont <%Fairful@kcms.msu.edu>
Re: How do I create a directory and then create a direc <merlyn@stonehenge.com>
Re: Java or CGI password protect a web <mrao@nospam.trincoll.edu>
Re: Passing 1 programs O/P to anothers I/P via file han (Andrew M. Langmead)
Re: PERL 5.001 on WIN NT 4.0 with IIS 3.0 <Janne.Blomqvist@lmf.ericsson.se>
Perl script calling an html file? <chris@fflm.com>
Redirecting output...... <devli002@gold.tc.umn.edu>
Re: Redirecting output...... (Andreas Schmidt)
shell command "more" <schan@rice.edu>
Re: unexpected foreach value <mchase@ix.netcom.com>
using variable as file name <temp.ed.vanderbush@bentley.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 19 Aug 1997 10:57:03 -0700
From: Raymond W Yu <rayyu@cup.hp.com>
Subject: "-T" problem after building 5.0004_01
Message-Id: <33F9DE6F.32AF@cup.hp.com>
After building 5.0004_01, everything works except the "-T"
option.
For example:
The file hello.pl contains:
-----------------------------------
#!/usr/local/bin/perl -T
print "hello\n";
-----------------------------------
% /usr/local/bin/perl -v
This is perl, version 5.004_01
Copyright 1987-1997, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.
% perl -c hello.pl
Too late for "-T" option at hello.pl line 1.
This error message appears for every script with "-T" option.
However, I can run hello.pl without any problem, except I can
do perl -d hello.pl.
Please help. Thank you.
Raymond Yu
rayyu@cup.hp.com
------------------------------
Date: 21 Aug 1997 07:01:26 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: "-T" problem after building 5.0004_01
Message-Id: <5the76$7gj@flatland.dimensional.com>
Raymond W Yu <rayyu@cup.hp.com> writes:
> After building 5.0004_01, everything works except the "-T"
> option.
>
> For example:
>
> The file hello.pl contains:
> -----------------------------------
> #!/usr/local/bin/perl -T
>
> print "hello\n";
> -----------------------------------
[snip]
> % perl -c hello.pl
> Too late for "-T" option at hello.pl line 1.
Try this:
% perl -cT hello.pl
Hope this helps.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Thu, 21 Aug 1997 11:38:14 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Binary I/O: simple question?
Message-Id: <34102762.13360066@news.tornado.be>
pulsifer@ppdpi4.ppd.nrl.navy.mil (Peter E. Pulsifer) wrote:
>As part of my intro to perl, I'm writing a Base64 decoder. The decoding
>is easy, but now how do I get the results out? When I print, perl writes
>the ASCII representation of the character, not the actual binary number.
>That is, if the number I decode is 65, it writes '65', not 'A' as it ought.
>I tried syswrite, but this does the same thing.
Test this:
print pack("C*",65,66,67);
This prints out "ABC".
Uh, if you're doing this decoding on a PC, don't forget to do
binmode(DECODED);
before printing anything to the output. You don't really need this on
other platforms, but it never hurts. It helps documenting your code.
Finally, base64 can easily be converted to UUcode. Apart from a
different alphabet, UUcode only uses an extra "count char", whereas
base64 only uses the raw encoded chars. In case you didn't know, Perl
has a built-in UUcoder/decoder.
You can see how it can be done in the module MIME/Base64.pm. You may
even decide to USE that module. :-) For that, you would need to upgrade
to Perl5.
Here's a (simplified) extract:
tr|A-Za-z0-9+=/||cd; # remove non-base64 chars
#length must now be multiple of 4
s/=+$//; # remove padding
tr|A-Za-z0-9+/| -_|; # convert to uuencoded format
my $len = chr(32 + length*3/4); # compute length byte
$res .= unpack("u", $len . $_ ); # uudecode
HTH,
Bart.
------------------------------
Date: Thu, 21 Aug 97 15:07:54 GMT
From: george@adirondack.net
Subject: CGI Error, any ideas?
Message-Id: <5thlrv$lkf$1@Usenet.Logical.NET>
First: NT4 w/SP2, IIS3, Perl from Activewear. Running CyberCash and Cold
Fusion.
Next: needed Perl for the CyberCash servers, so installed it. Now get CGI
Errors randomly which require a reboot to correct. The message is CGI Error:
The CGI application you are running misbehaved by not returning proper
headers. The headers it did return are:
No headers were ever listed. I have posted MS news, with no response, and also
sent email to CyberCash and Cold Fusion, and they cant say any more than it is
a permission problem. It isn't, because it ran without a hitch for 3 months,
only beginning with this install.
Are there any known problems, and is there a fix (aside from throwing it into
the lake)? I seem to have talked to (but not recieved a reply from) just about
everyone else.
Thanks, in advance.
George
george@adirondack.net
------------------------------
Date: Thu, 21 Aug 1997 06:02:11 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: changing perl to gibberish
Message-Id: <j77ht5.fm.ln@localhost>
T. Wheeler (twheeler@m-net.arbornet.org) wrote:
: I thought perl was already gibberish :-)
: On unix machines there is often crypt command to encrypt documents.
^^^^^^^^^^^^^
Which is a one way algorithm.
Do you ever wanna get the code back (there is no 'decrypt' command...)?
: If you do an eval 'crypt' type of system call, you might be headed in
: the right direction.
^^^^^^^^^^^^^^^^^^^
... then again, maybe not ;-)
[snip]
: On Fri, 08 Aug 1997 16:09:06 -0400, Victor Magdic <vmagdic@talas.com>
: wrote:
: >Does anyone know if there are any programs that will take perl source
: >and scramble it into gibberish, so that it is effectively unreadable
: >(i.e. human readable variable names are converted to strings of
: >letters+numbers, spaces compacted etc.)
: >
: >I've seen stuff like this for javascript code.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 21 Aug 1997 12:09:50 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Converting text to Excel data with UNIX
Message-Id: <33FC05DE.3821@icl.fi>
Joe Petrow wrote:
>
> Could somebody point me to some information on a Perl routine that
> converts tab delimited text data in native Excel format?
>
> Or if not that, to a place that specifies exactly what native Excel format
> is?
>
> Thank you.
>
> Joe Petrow
> joepet@server.berkeley.edu
> http://server.berkeley.edu/~joepet
Try books titled:
File Formats
More File Formats
The File Formats Handbook
Inside Windows File Formats
You can probably locate them via http://www.amazon.com
They're also bunlded with a couple of additional titles
on the Dr.Dobb's "Essential Books on File Formats CD-ROM",
http://www.ddj.com
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: 21 Aug 1997 14:58:47 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: Converting text to Excel data with UNIX
Message-Id: <5thl37$odg$1@scully.new-era.net>
Some guy wrote:
: Could somebody point me to some information on a Perl routine that
: converts tab delimited text data in native Excel format?
No.
Such a portable routine would be almost impossible to achieve, since
"native Excel format" is an OLE storage, which you couldn't recreate on
a non-Windows platform. You'd have to recreate the entire storage
subsystem to write a properly formatted file.
I'm not sure why you'd even want to do this. Excel's text input
routines are incredibly good. If you can get the file into any type of
delimited data format, you'll be able to import it easily.
: Or if not that, to a place that specifies exactly what native Excel format
: is?
The latest version of the Microsoft Developer Network CD has the gory
details. The new book Excel Developer's Guide does, too.
Still, this will not help you much, since it only describes the
internal layouts within the OLE storage, *NOT* the OLE storage file
format. The storage format could even change, there's no guarantee that
it will always be the same. The only guarantee is the API will always
behave the same.
Scott
------------------------------
Date: 21 Aug 1997 15:04:33 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: Converting text to Excel data with UNIX
Message-Id: <5thle1$odg$2@scully.new-era.net>
Some guy wrote:
: > Could somebody point me to some information on a Perl routine that
: > converts tab delimited text data in native Excel format?
: Try books titled:
: File Formats
: More File Formats
: The File Formats Handbook
: Inside Windows File Formats
This answer is not helpful. First of all, you don't even need these
books because the Excel Developer's Guide has the complete specs in
it. But mainly, the problem with knowing the file format is that all
this information does is tell you the *internal* file format. Excel
files are OLE storages. Knowing what is in the storage doesn't tell
you how to create a binary compatible storage file. If you're on UNIX,
you (most likely) have no COM API available, and even if you did what
are the odds it would be binary compatible with Windows?
You could create some pre-OLE Excel file in a prior version, but that's
a lot of trouble since you'd have to do a conversion to load it into a
modern Excel version. If you have to convert, why not use a text-based
format like CSV that Perl can generate very easily?
For that matter, Excel 97 can slurp up web pages from URLs, so just
make this Perl program emit HTML, and read the output in Excel. You
could even make it a CGI program.
Scott
------------------------------
Date: Thu, 21 Aug 1997 11:38:10 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Filtering CR & CRLF from text input
Message-Id: <340c1c7a.10567789@news.tornado.be>
roger@ole-net.com (Roger Easlick) wrote:
>Can anyone tell me how to strip CRLFs from text input fields? I'm
>writing a classified ad script which features a muti-row textbox where
>the user is very tempted to hit return and to format his/her entry.
Maybe this will do what you want.
tr/\000-\037/ /; #turn all control characters into spaces
tr/ //s; #at most a single space
This is the same in one statement:
tr/\000-\040/ /s; #\040 = 32 = space
HTH,
Bart.
------------------------------
Date: 21 Aug 1997 07:25:56 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: roger@ole-net.com
Subject: Re: Filtering CR & CRLF from text input
Message-Id: <8chgcja9zf.fsf@gadget.cscaper.com>
>>>>> "Roger" == Roger Easlick <roger@ole-net.com> writes:
Roger> read(STDIN, $save_string, $ENV{CONTENT_LENGTH});
[rest of evil,
do-it-yourself-hack-extracted-from-some-clueless-web-book deleted]
Roger> Any suggestions would be GREATLY appreciated.
Yes. First off, stop cutting and pasting code from clueless web
books. Get CGI.pm. Install it. Or install 5.004 which does this for
you automatically. Read the docs. CGI.pm handles soooooo much for
you. You'll be glad you did. For many examples of using CGI.pm,
see my Web Techniques columns at:
http://www.stonehenge.com/merlyn/WebTechniques/
And yes, the case is important... this isn't any DOS path. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 376 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Tue, 19 Aug 1997 11:50:35 -0700
From: Raymond W Yu <rayyu@cup.hp.com>
Subject: Re: Help reading massive file
Message-Id: <33F9EAFB.B06@cup.hp.com>
Ed Vander Bush wrote:
>
> I am creating a text file to hold user information for a site.
> User ID Name Var1 var2 etc......,..
> Seperated by tabs
> I need to know how to find a line based on the User Id and then take the
> information out of that line and set each one to a variable in the
> script. Thanks!
If this file is huge, try using NDBM_File or GDBM_File. These modules
can help you locate a record a lot faster and easier than using a text
file.
If a text file is the one way to go for you, then try something like:
open FILE, 'data.txt' for die;
while(<FILE>){
if ( (split /\t/)[0] eq $uid) ){
return $_;
}
}
close FILE;
return undef;
--
____________________________________________________________________
Raymond W Yu Tel: 408-447-4050
R&D Engineer Fax: 408-447-3660
Test Environment Management Group mail: rayyu@cup.hp.com
Cupertino, Hewlett-Packard Co. M/S: 43LJ
--------------------------------------------------------------------
CC:Mail: raymond_yu@hp-cupertino-om5.om.hp.com
------------------------------
Date: Thu, 21 Aug 1997 08:59:49 -0400
From: Mike Drons <Michael_Drons@harvard.edu>
Subject: help with CGI.pm and IIS
Message-Id: <33FC3BC5.2074@harvard.edu>
I am using CGI.pm version 2.36 and can not get my perl scripts to read
in values from the web. The web server runs on NT4.0 and is IIS 3.0.
My code looks like this
$query=new CGI;
$input=$query->param('foo');
$input never gets assigned a value, but when I run it from the command
line and enter the values it works great. I am using perl version 5.003
build 307 from activeware. The perl script worked fine in perl version
5.001.
Please help...
Mike Drons
Michael_Drons@ins.com
------------------------------
Date: Thu, 21 Aug 1997 12:10:47 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: HELP!!!!Please.....
Message-Id: <EF9J5z.59r@world.std.com>
jhaveri@hops.cs.jhu.edu (Nilay Jhaveri) writes:
>I have a Perl Question for anyone kind enough to help me.
>I have an array of words, say @fields...
>But since this array is dynamically allocated, I do not know how many
>words are in it before run time.
>Is there a regular expression that basically looks for those words in
>sequence, but allowing unlimited spaces(\s)+ between words?
One thing that I'm not clear from reading your posting, is whether you
need all elements to match, or just any element to match. Your example
show just any element causing a match, but if so, why do spaces
matter? If you find any element its a match and the surrounding spaces
do not have to be considered.
Well, since the specs are ambiguous, I get to give my own
interpretation. I'll use one where any element must match, but the
element must be a separate word. "jack" won't match "jackrabbit", or
any other word that begins with "jack"
The first thing that most people would think of is to loop around each
element in the array, and insert the current element in the regular
expression.
while(<>) {
for $word (@fields) {
if(/\b$word\b/) {
print;
next;
}
}
}
Unfortunately, its horribly slow. Since the regular expression changes
each time, Perl has to keep recompiling it. On the other hand,
computers are rather fast, and depending on the size of the data you
are searching, and the number of words you want to search for, the
program most likely be much faster than visting a McDonalds drive
through window.
For a much more confusing (but luckily the confusing part is already
done), but much more efficient solution, the FAQ suggests this:
> How do I efficiently match many regular expressions at once?
>
> The following is super-inefficient:
>
> while (<FH>) {
> foreach $pat (@patterns) {
> if ( /$pat/ ) {
> # do something
> }
> }
> }
>
> Instead, you either need to use one of the experimental Regexp
> extension modules from CPAN (which might well be overkill for your
> purposes), or else put together something like this, inspired from a
> routine in Jeffrey Friedl's book:
>
> sub _bm_build {
> my $condition = shift;
> my @regexp = @_; # this MUST not be local(); need my()
> my $expr = join $condition => map { "m/\$regexp[$_]/o" } (0..$#regexp);
> my $match_func = eval "sub { $expr }";
> die if $@; # propagate $@; this shouldn't happen!
> return $match_func;
> }
>
> sub bm_and { _bm_build('&&', @_) }
> sub bm_or { _bm_build('||', @_) }
>
> $f1 = bm_and qw{
> xterm
> (?i)window
> };
>
> $f2 = bm_or qw{
> \b[Ff]ree\b
> \bBSD\B
> (?i)sys(tem)?\s*[V5]\b
> };
>
> # feed me /etc/termcap, prolly
> while ( <> ) {
> print "1: $_" if &$f1;
> print "2: $_" if &$f2;
> }
The book that it refers to is "Mastering Regular Expressions" by
Feffrey Friedl. published by O'Reilly and Associates.
--
Andrew Langmead
------------------------------
Date: Thu, 21 Aug 1997 09:18:02 -0700
From: Doug Fairful <%Fairful@kcms.msu.edu>
Subject: Re: HELP: Perl5 on Novell Web Server 3.0 "Document Contains No Data" error
Message-Id: <33FC6A39.4883@kcms.msu.edu>
Mahlon Inksetter wrote:
>
> Hi,
>
> I'm new to Perl but I'm not having much trouble understanding Perl,
> it's getting it to run. I'm working with Perl 5 on Novell Web Server (NWS) 3.0
>
> I am not the admin but I have spoken with the admin many times. The NWS is set
> up with the default installation.
>
> As per the documentation, I'm placing my perl scripts (*.pl) in the directory
>
> SYS:INW_WEB\SHARED\DOCS\LCGI\PERL5
>
> There are sample scripts in there that work fine. And I can get the most *basic*
> script (ie. Send print statments to the browser) to work. But anytime I add more
> complicated stuff (if..else, passing info from a form etc.) I'm getting a "Document
> Contains No Data" error. I've checked my code against the examples provided with NWS
> and I can't see where I'm going wrong.
>
> Is there a way to run Perl on NWS with the "-w" switch?
>
> Here is a snipet of code that works in the example, but not in mine:
>
> EXAMPLE: (works)
>
> require("cgilib.pl");
> print &PrintHeader;
> &ReadParse;
>
> if($ENV{"REQUEST_METHOD"} eq "GET" && $ENV{QUERY_STRING"} eq "") {
>
> ....here HTML is sent to the browser....
>
> MY CODE: (Does NOT work)
>
> require("cgilib.pl");
> print &PrintHeader;
> &ReadParse;
>
> if ($ENV{"REQUEST_METHOD"} eq "GET" && $ENV{"QUERY_STRING"} eq "") {
>
> ...here HTML is sent to the browser....
>
> To me they look exactly the same. The HTML is different, but once inside
> the "if" statement, it's simple statements like:
>
> print "<HTML><HEAD><TITLE>My Page</TITLE></HEAD>\n";
>
> The properties of the file are the same too (no "execute" mode or anything)
>
> I would really appreciate any help as I am trying to get a project done and
> my position ends this week. I only have a few minor things to do, but i can't
> seem to get Perl to perform the simplest tasks!! Which is all I want it to do
> anyway.
>
> Thanks in advance to any who may help!
>
> Mahlon
I am new to Perl myself and, coincidentally, also trying to get a form
to work in NWS 3.0 + Perl5. I do not know enough to do any code
debugging, but on thing that may help you is to load Perl debugging
screens on the NWS console:
PERL5 DBGON
PERL5 ACCESS
PERL5 SCRIPT
I believe any syntax errors will show up on the script debug screen...
Cheers,
Doug Fairful
------------------------------
Date: 21 Aug 1997 07:20:01 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Clark Dorman <clark@s3i.com>
Subject: Re: How do I create a directory and then create a directory within that directory?
Message-Id: <8ck9hfaa9a.fsf@gadget.cscaper.com>
>>>>> "Clark" == Clark Dorman <clark@s3i.com> writes:
Clark> You need to remember that the MODE needs to be in octal.
Clark> Therefore, you need to do:
Clark> mkdir( "p2", 0755 );
Clark> Please remember the 0 before the rest of the numbers.
Well, no. Mode doesn't have to be in octal. This works
perfectly fine, as in the same as the one above:
mkdir "p2", 493;
The trouble is, I don't recall easily that 0755 is 493, so I let Perl
do all that work at compile time. :-) But that value out there is just
an ordinary expression... you could even do this:
mkdir "p2", 7*8*8 + 5*8 + 5;
Again, silly. But this is all to disprove your oft-quoted-misquote of
"the second parameter must be octal". Perl doesn't care. It just
wants a *value*.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 376 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 21 Aug 1997 09:26:37 -0400
From: Mukund Rao <mrao@nospam.trincoll.edu>
To: Nick Marcantonio <marcan@notes.nu.com>
Subject: Re: Java or CGI password protect a web
Message-Id: <Pine.SOL.3.95.970821092626.14373F-100000@shakti.cc.trincoll.edu>
Nick,
Take a look at http://hoohoo.ncsa.uiuc.edu/docs/tutorials/user.html, the
authoritative tutorial on setting up .htaccess, which is what you seem to
want to do.
Bye,
On Thu, 14 Aug 1997, Nick Marcantonio wrote:
: I've been looking for a way to password protect a highly confidential
: web that I've done. I've played with many self-written and downloadable
: Java and CGI scripts, but none seem to be truly effective. If you know
: of a sure fire way to password protect a web, it would be greatly
: appreciated if you would share that with me. Please e-mail:
: marcan@nu.com with any info. I extend my thanks in advance.
:
:
_ _ ____
| \ / | \ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| \/ | () / Mukund Rao | Trinity College
| | |\ \ "visualize whirled peas" | WWW Admin, Programmer
|_|\/|_|_| \_) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Note: To reply, remove "nospam" from mrao@nospam.trincoll.edu
------------------------------
Date: Thu, 21 Aug 1997 13:59:05 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Passing 1 programs O/P to anothers I/P via file handles
Message-Id: <EF9o6H.Mux@world.std.com>
Mark Worsdall <jaydee@worsdall.demon.co.uk> writes:
>I think I might be on the right trail below but is there such a thing as
>doing a:-
>print MAIL TRACE
>(where MAIL is the handle for the mail program and TRACE is the handle
>for the traceroute program, so data flow directly from it?)
yes, you are pretty close. Things that I see that are wrong are:
1. When you want to pipe the output of traceroute into your program,
you put the pipe symbol on the right. A pipe on the left means you
want to redirect its input.
2. Perl's string concatination operator is a period, not a plus
sign. Plus signs add numbers. You can also use double quotes to
perform variable interpolation, Since you are already interpolating
$traceprog into a double quoted string, you might as well interpolate
both.
3. You need to check that your open succeeds.
4. You need to check that both calls to close() succeed. The fact that
open succeeds doesn't tell you all that you want to know. If the
program doesn't get run, you won't know until you close() the pipe.
5. When you read from TRACE, you need to use perl's "<>" operator to
read the data from the filehandle you created.
open(TRACE,"$traceprog $surfer |") or die "Error starting $traceprog: $!\n"
print MAIL <TRACE>;
close MAIL or die "Error running $mailprog: $!\n";
close TRACE or die "Error running $tracerpog: $!\n";
--
Andrew Langmead
------------------------------
Date: Thu, 21 Aug 1997 16:29:41 +0300
From: Janne Blomqvist <Janne.Blomqvist@lmf.ericsson.se>
To: dRAGoNFLy <mEu@mindless.com>
Subject: Re: PERL 5.001 on WIN NT 4.0 with IIS 3.0
Message-Id: <33FC42C5.5CEADC0A@lmf.ericsson.se>
dRAGoNFLy wrote:
>
> Hello,
>
> I have serious trouble installing perl on my IIS 3.0 webserver. I want to
> install perl on the Webserver HD (which is easily done with install.bat I
> guess) but after that I create a directory called "cgi-bin" in the wwwroot
> directory, I make it executable with the Internet Service Manager and I map
> it so that http://azul/cgi-bin is the cgi-bin directory. Works fine, but
> then comes the problem, when I put a simple script in the cgi-bin directory
> and a html file in the samples directory, and I press my submit button
> (it's a simple search engine) I arrive at the search.pl script with the
> nice error: HTTP/1.0 501 Not Supported
> I think he doesn't recognize the .pl file and he doesn't associate it with
> the perl.exe interpreter.
> Can somebody please help me out with this because it's rather important.
> BTW I ain't a Windows NT specialist or IIS 3.0 freak either (yet :)
>
> Thanks in Advance,
>
> Dominique
Hello,
IMHO, you should seriously consider taking another approach. I read
in MikroDatorn (A swedish computer mag) that IIS 3.0 has some serious
problems relating to CGI. It seems that there is no way of stopping
a runaway CGI process! Since the CGI process runs under IIS, which
happens to be a system process, you aren't allowed to kill it, even
if you're root (or whatever superuser is called in NT, administrator
maybe??). So the only way to stop this runaway CGI process is to
reboot...hardly a very elegant nor efficient solution, especially if
you are supposed to be a high availability server. The MicroSoft
solution to this problem is called ISAPI, Internet Server API.
This is similar to CGI, but much more complicated, and of course
it supports only the programming languages MicroSoft chooses to
support, i.e. things like Visual Basic...UGH!!! I think Perl is
supported too, but I don't know. Another solution is to get another
web server. And while you're at it, why don't you switch to a real
OS, like Linux or the plethora of other UNIXes available. Then you
will also have the chance of using Apache, the best free HTTP server
around...the newest versions support HTTP 1.1, BTW. OTOH, UNIX+Apache
isn't so easy to set up as NT+IIS, you might need help by your local
UNIX guru with it... If you don't want to change server nor OS you
might want to try to make a batch wrapper for your perl script,
i.e. make a .bat file that you put in your cgi-bin directory.
The .bat file should simply look like this:
c:\path\to\perl\interpreter\perl \path\to\script\script.pl
This should solve the problem, if that is the problem, of course...;-)
Hope this helps,
---
Janne Blomqvist
------------------------------
Date: Thu, 21 Aug 1997 05:53:17 -0500
From: Chris Beidel <chris@fflm.com>
Subject: Perl script calling an html file?
Message-Id: <33FC1E1D.79F8@fflm.com>
Perl Guru's:
I've created a simple Perl script and would like to modify it to have it
display a html page from within the Perl script.
Background: The Perl script is a form processor that accepts customer
info. The html page is simply a confirmation that the customer had
successfully completed the form.
1. Can this be done?
2. If so, what are my options?
Thanks in advance for your help.
--
Chris Beidel (chris@fflm.com)
Sideline Software
http://www.fflm.com
------------------------------
Date: Thu, 21 Aug 1997 08:41:29 -0700
From: John Devlin <devli002@gold.tc.umn.edu>
Subject: Redirecting output......
Message-Id: <33FC61A9.198@gold.tc.umn.edu>
I am running a server level cobol program which is executed by a script.
The output of this program is displayed to the screen. How do redirect
this output to a file in PERL? I tried the following, but it did not
work:
$_ = `cd /directory_where_the_executable_script_resides; ./script >>
/mydirectory/file_I_want_the_output_to_go`;
------------------------------
Date: 21 Aug 1997 14:16:37 GMT
From: schmidt@miserv2iai.kfk.de (Andreas Schmidt)
To: John Devlin <devli002@gold.tc.umn.edu>
Subject: Re: Redirecting output......
Message-Id: <5thik5$he2$1@nz12.rz.uni-karlsruhe.de>
In article <33FC61A9.198@gold.tc.umn.edu>, John Devlin <devli002@gold.tc.umn.edu> writes:
|> I am running a server level cobol program which is executed by a script.
|> The output of this program is displayed to the screen. How do redirect
|> this output to a file in PERL? I tried the following, but it did not
|> work:
|>
|> $_ = `cd /directory_where_the_executable_script_resides; ./script >>
|> /mydirectory/file_I_want_the_output_to_go`;
hi john,
there is a special form of the open command, which allows you to start a program.
you simply have to write:
open(PROG_HANDLE,"/directory_where_the_executable_script_resides/script|");
look at the pipe symbol '|' at the end of the command. in this case the handle
reads the output from your program.
print "The output of my program is:\n";
while (<PROG_HANDLE>) {
print $_;
}
close(PROC_HANDLE);
another solution is using the 'system()' command.
try:
system("/directory_where_the_executable_script_resides/scrip >/tmp/a_logile.log")
&& die "cannot execute program!";
hopethishelps
smiff
========================================================================
andreas schmidt email: schmidt@iai.fzk.de
institut fuer angewandte informatik (iai) phone: +49 7247 82 5714
forschungszentrum karlsruhe gmbh
- technik und umwelt -
postfach 3640 76021 karlsruhe (germany)
------------------------------
Date: Thu, 21 Aug 1997 09:58:42 -0700
From: sabrina chan <schan@rice.edu>
Subject: shell command "more"
Message-Id: <33FC73C2.7664@rice.edu>
This is probably a newbie question, but I've been going through the man
pages and faqs and can't find the answer... I wrote a script that gathers
various information into one file, and then I want to output this file to
the screen. However, I can't figure out how to output it in the style of
the command "more", ie stopping and asking for a key to be pressed when
the screen is full. If anyone can help, I'd really appreciate it.
sabrina
------------------------------
Date: Thu, 21 Aug 1997 07:30:20 -0700
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: unexpected foreach value
Message-Id: <5thnfa$2sm@dfw-ixnews5.ix.netcom.com>
It appears that the last element of @traces ($traces[8]) is being
assigned a reference to a Bcm::PM_Trace object which is implemented as a
hash. I don't have Bcm::PM_Trace here, so you'll need to post more
information about how @traces is set to get more help.
Mac :}) mchase@ix.netcom.com
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/E/IT/O d s+:+ a+ C++$ ULUHSC*++$ P++$ L+(++) E- W++ N++ o? K-? w+
O M- V- PS+@ PE Y+ PGP+ t+ 5++ X R tv b+++(++++) DI++(+++) D? G e++ h---
r+++ y+
------END GEEK CODE BLOCK------
Andrew D. Arenson wrote in article ...
>
>Platform: Solaris2.5, perl-5.003
>
>I have a simple loop:
>
> foreach $trace (@traces) {
> $result = &filter($trace);
> }
>
>That is doing something quite unexpected. In a fully reproducable
>fashion, but for no reason I've been able to discern, the last time
>the variable '$trace' is set, instead of actually getting the value
>of $traces[$#traces], it gets either 8 or 0.
>
>The above is a simplification of the code. I'd be more than happy
>to expand on it, but I didn't want to scare people off right away.
>I've used the debugger to get to the inner code above and am stunned
>to see:
>
> DB<11> p $trace
>8
> DB<12> p $traces[$#traces]
>Bcm::PM_Trace=HASH(0x76f260)
------------------------------
Date: Thu, 21 Aug 1997 08:48:51 -0400
From: Ed Vander Bush <temp.ed.vanderbush@bentley.com>
Subject: using variable as file name
Message-Id: <33FC3932.A68@bentley.com>
I retreive a variable from my database and then set it to a variable
How can I
Normal content type and headers
print "<!--#include virtual="$var1.htm"-->\n";
It won't parse the data...
------------------------------
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 900
*************************************