[7055] in Perl-Users-Digest
Perl-Users Digest, Issue: 680 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 29 02:07:20 1997
Date: Sat, 28 Jun 97 23:00:21 -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 Sat, 28 Jun 1997 Volume: 8 Number: 680
Today's topics:
Re: ### FILE RIGHTS FROM PERL PROGRAM ### <rootbeer@teleport.com>
Re: Can I get STDERR of `command` ?? <wesley@woais.com>
Re: Compiling perl5.004_01 on linux problem <rootbeer@teleport.com>
Re: Forcing a browser auth w Perl <rootbeer@teleport.com>
Re: Free CGI Storage- Please Read! <rootbeer@teleport.com>
FreeNetAccessWorldwide- (Steph&Lise)
Re: Help with getting file contents <rootbeer@teleport.com>
Re: How do I decipher Time format? (Lloyd Zusman)
Re: Is PERL a compiled language? <dres@dimensional.com>
Re: It slices, It dices (what is a glog) (Jahwan Kim)
Re: It slices, It dices (what is a glog) <rootbeer@teleport.com>
Re: lastIndexOf ( String, SubStringRegex ) <rootbeer@teleport.com>
Learning Perl chris.deehan@east.sun.com
Re: Need PID of qx{command} <rootbeer@teleport.com>
Perl and PGP interface (Yvon D. Roustan)
Re: Question: split and anonymous arrays <rootbeer@teleport.com>
Re: Question: split and anonymous arrays <wesley@woais.com>
Re: removing weird characters <rootbeer@teleport.com>
split dumping core! (Gunnlaugur Thor Briem)
Re: split dumping core! <rootbeer@teleport.com>
Re: strings <rootbeer@teleport.com>
Re: Validating E-Mail addresses and URL's <jefpin@bergen.org>
Variable help please (CitiCentr)
Re: Where is Perl 5.004? <rootbeer@teleport.com>
Re: while(<INFILE>) fails to read to EOF? <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 28 Jun 1997 19:51:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Hardware Planet <sales@hardwareplanet.com>
Subject: Re: ### FILE RIGHTS FROM PERL PROGRAM ###
Message-Id: <Pine.GSO.3.96.970628194924.16294J-100000@kelly.teleport.com>
On Sat, 28 Jun 1997, Hardware Planet wrote:
> Subject: ### FILE RIGHTS FROM PERL PROGRAM ###
There's no need to shout.
> whenever my perl program creates a file within my perl program I try and
> give it 755 rights using umask (0022) but all I get is rw-rw-rw- .
If that's really what's happening, then there's a bug in your system or in
your perl binary. But I think that maybe something is not quite as you
say. :-)
Have you tried using chmod(), as documented in the perlfunc(1) manpage?
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 29 Jun 1997 01:06:54 -0500
From: Wesley Miaw <wesley@woais.com>
To: Pierre BERGDOLT <Pierre.Bergdolt@ansf.alcatel.fr>
Subject: Re: Can I get STDERR of `command` ??
Message-Id: <33B5FB7F.3B6E4D02@woais.com>
Pierre BERGDOLT wrote:
>
> Hi there,
> I have a set of perl scripts that perform various operations using
> `command`. Normally `command` is executed in a subshell, I can get
> return code of `command` using $?, but can I get what `command` put to
> STDERR in the subshell? The aim of this is to put warning or error
> message in a log file. Thanks to answer by e-mail.
> Thanks to all Perl gurus.
I think that $! will return the error you want. $? returns $CHILD_ERROR while
$! returns $OS_ERROR and $ERRNO.
--
Wesley Miaw wesley@woais.com
World of Artists Internet Services http://www.woais.com/
71 Middlesex Drive Tel: 518-439-0412
Slingerlands, NY 12159 FAX: 518-439-9722
------------------------------
Date: Sat, 28 Jun 1997 21:05:25 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Per Kistler <kistler@erdw.ethz.ch>
Subject: Re: Compiling perl5.004_01 on linux problem
Message-Id: <Pine.GSO.3.96.970628210355.16294Q-100000@kelly.teleport.com>
On Sat, 28 Jun 1997, Per Kistler wrote:
> If I want to compile perl5.004_01 on linux 2.0.9 then I get that
> error a lot of times:
>
> lib/symbol........perl: warning: Setting locale failed.
> Does perl5.004_01 not work on linux?
Sure it works. But you don't have locales installed. You need to either
install some locales or compile Perl without locale support. The latter
should be covered in the release notes which come with the source, but if
you still can't figure it out, post again. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 28 Jun 1997 19:29:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Daniel G. Drumm" <dgd@nebula.is.rpslmc.edu>
Subject: Re: Forcing a browser auth w Perl
Message-Id: <Pine.GSO.3.96.970628192351.16294H-100000@kelly.teleport.com>
On 27 Jun 1997, Daniel G. Drumm wrote:
> I'm searching for a way to force a browser to authenticate, as with a
> httpd protected page, strictly from within Perl.
You can't force a browser to do anything. The most you can do is to ask
nicely. :-)
All you need to do is output the right stuff to the browser, and that will
tell it what you want. To find out what to output, check out a newsgroup
about CGI, HTTP, servers, or browsers, or those groups' FAQs.
If you have questions about _how_ to do the output in Perl, those are Perl
questions, so check the docs and if you can't find the answer, those kinds
of questions are welcome here. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 28 Jun 1997 21:57:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Rikk Alessi <ace49@geocities.com>
Subject: Re: Free CGI Storage- Please Read!
Message-Id: <Pine.GSO.3.96.970628214551.16294V-100000@kelly.teleport.com>
On Sat, 28 Jun 1997, Rikk Alessi wrote:
> Subject: Free CGI Storage- Please Read!
Well, okay, since you said "please".
> Does anyone know where I can get *******FREE******** CGI storage? I am
> really in need of it. Thanx
When I can't afford to store my CGI scripts somewhere, I write them down
on my old grocery bags. But I try to save enough America On-Line diskettes
so that I can use those, since they're much more convenient. :-)
But maybe you are looking to find a machine on the Internet which lets
everybody install and run any old software for no charge. That doesn't
have anything to do with Perl, of course. Maybe they're talking about that
in the Java newsgroups. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 29 Jun 1997 01:23:10 GMT
From: stephlise@hotmail.com (Steph&Lise)
Subject: FreeNetAccessWorldwide-
Message-Id: <33b58bfd.2660676@192.136.24.2>
Free net connection worldwide via our BBS.
http://www.cybercity.hko.net/kl/gotam/freenet/free.htm
------------------------------
Date: Sat, 28 Jun 1997 22:01:25 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Shelle <shelle@interaccess.com>
Subject: Re: Help with getting file contents
Message-Id: <Pine.GSO.3.96.970628220008.16294X-100000@kelly.teleport.com>
On Sun, 29 Jun 1997, Shelle wrote:
> open (TEXT_FILE, "path/$text_file");
Don't forget to check that the open was successful:
open TEXT_FILE, "path/$text_file"
or die "Can't open 'path/$text_file': $!";
Good diagnostics only take an instant to write, but they save hours of
debugging time. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 29 Jun 1997 02:19:17 GMT
From: asfast@asfast.com (Lloyd Zusman)
Subject: Re: How do I decipher Time format?
Message-Id: <slrn5rbhbg.lo.asfast@ljz.asfast.net>
I found an error in my previous post:
> [ ... ]
>
> $secondsPerDay = 86400;
> $secondsPerHour = 3600;
> $secondsPerMinute = 60;
>
> $secondsSinceMidnight = ($time % $secondsPerDay);
>
> $hoursSinceMidnight = int($secondsSinceMidnight / $secondsPerHour);
>
> $secondsSinceHourBegan = ($secondsSinceMidnight % $secondsPerHour);
>
> $minutesSinceHourBegan = int($secondsSinceHourBegan / $minutesPerSecond);
>
> $secondsSinceMinuteBegan = ($minutesSinceHourBegan % $secondsPerMinute);
^^^^^^^^^^^^^^^^^^^^^^
The above line should read as follows:
> $secondsSinceMinuteBegan = ($secondsSinceMidnight % $secondsPerMinute);
^^^^^^^^^^^^^^^^^^^^^
> [ ... ]
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: 28 Jun 1997 21:50:32 -0600
From: James LewisMoss <dres@dimensional.com>
Subject: Re: Is PERL a compiled language?
Message-Id: <hh7mfedq47.fsf@dres.elam.org>
>>>>> On Thu, 26 Jun 1997 17:25:57 -0700, Tony McCormick <tony@peregrinco.com> said:
Tony> Webmaster wrote:
>>
>> I'm a newbie to PERL...how does this language run?
>>
>> Thanks, Matthew Robinson ExecuSoft Controls, Inc.
Tony> Perl is interpreted, sortof, the runtime loads the script,
Tony> compiles it then executes if not syntax errors are found.
The whole question of compiled vs interpreted is muddy. Does compiled
mean changed into some form that a machine can directly run. If so
what is a machine? Is a byte-code interpreter a machine? Most say
no. Course a piece of silicon is just an interpreter as well. [1]
Hmmm maybe the better question is `Does perl require a separate
pre-compile step before using a program?'. [2] And if that is the
question you were thinking, then no. It doesn't. [3]
Footnotes:
[1] In most cases faster than what people associate `interpreter'
with. :)
[2] Which seems to me how most people distinguish. [4]
[3] Unless of course you are using the perl `compiler'. [5]
[4] Which is completely inaccurate in many cases. [6]
[5] Which I haven't tried yet.[7]
[6] See many Lisp systems.
[7] Should I?
Jim
--
@James LewisMoss <dres@dimensional.com> | Blessed Be!
@ http://www.dimensional.com/~dres | Linux is cool!
@"Argue for your limitations and sure enough, they're yours." Bach
------------------------------
Date: 29 Jun 1997 02:09:23 GMT
From: jahwan@yunt.math.lsa.umich.edu (Jahwan Kim)
Subject: Re: It slices, It dices (what is a glog)
Message-Id: <slrn5rbguj.n0g.jahwan@yunt.math.lsa.umich.edu>
On Sat, 28 Jun 1997 00:22:08 -0400, Larry D'Anna <ldanna@ix.netcom.com> wrote:
[snip]
> And how does the symbol module create an _ anonymous _
> glob, I thought they were symbol table entries so how
> do you have one without a symbol?
Just looked at Symbol.pm. It's not anonymous; its name is just unique and
in the Symbol:: package. To read it yourself is the best way to see it; the
whole file is about 4-5 pages (including .pod).
Jahwan
------------------------------
Date: Sat, 28 Jun 1997 21:02:54 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Larry D'Anna <ldanna@ix.netcom.com>
Subject: Re: It slices, It dices (what is a glog)
Message-Id: <Pine.GSO.3.96.970628201800.16294O-100000@kelly.teleport.com>
On Sat, 28 Jun 1997, Larry D'Anna wrote:
> Can somebody explain what the expression " *glob "
> really means?
>
> is it a scalar like this?
> $fh = *glob
Yes!
> or it's own type, like this?
> *fred = *barny
Yes!
> or a scalar lvalue, like this?
> *fred = \$barny
Yes! Yes! Yes! And it's a floor wax _and_ a dessert topping!
Okay, I'm getting carried away. Here's what's really happening with a
typeglob. (I may fudge a couple of unimportant points here for simplicity;
folks who know more about this, please don't complain unless I say
something outright wrong here. And, so everybody knows, even though they
have similar names, a typeglob is totally different than a filename glob.
I'm only talking here about typeglobs.)
When you refer to the global variable $foo (this doesn't apply to my()
variables) you're referring to $foo in the current package. That package
has a symbol table, and that symbol table is actually a hash. If you were
to look into that hash (and you _can_!) you would see that there is a key
of 'foo'. It is that key which is looked up whenever you use $foo in your
script.
The value of that entry is a typeglob. The typeglob (magically) contains
within it one or more things which can be called foo. So there may be a
scalar ($foo) and a hash (%foo) and a sub (&foo) in there, among other
things. The whole batch of them is called *foo.
If you assign to *foo, Perl looks at what value you're giving so that it
can see how to modify the typeglob. If you assign an array reference,
you'll replace @foo. If you assign a hashref, that replaces %foo. If you
assign a coderef, that replaces &foo. (Yes, this redefines a subroutine at
runtime. Somebody splash some cold water on those Pascal programmers who
read this message by mistake.)
Suppose you assign a typeglob to *foo? Well, that replaces all of the
components with the ones from the typeglob. Actually, it makes them both
the _exact_same_ variables (and filehandles, and subroutines, and so on).
$fred = "fred";
$barney = "barney";
sub fred { print "I'm $fred\n" }
sub barney { print "I'm $barney, and that's $fred\n" }
&fred; &barney; # Just what you'd expect
*fred = *barney; # Replace all freds with barneys
# Now things get interesting...
&fred; # We really called &barney!
$fred = "really fred"; # fred and barney are really the same.
&barney; # Two names for the same objects.
As you can see, typeglobs are not a simple and obvious subject! But
they're used in the Exporter and other modules which use the heavy
wizardry of typeglobs to do their stuff. I can't explain all of that here,
but you can use Perl's built-in debugger to see it in action.
Use the command 'perl -de 0' to start the debugger up interactively, then
give it a little Perl code using typeglobs, such as '@foo::fred = qw(this
is the fred array);'. Now use the debugger's x command to examine the foo
symbol table with the command 'x \%foo::'. (If that command doesn't work,
you probably have an old debugger, and an old version of Perl to match.
Then again, you may have a newer version of the debugger than I have, so
check its help command! :-) This is one way of peeking into the symbol
table to see what lies within.
Enjoy the wild and wacky world of typeglobs!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 28 Jun 1997 22:05:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Miten S Mehta <mehta@mama.indstate.edu>
Subject: Re: lastIndexOf ( String, SubStringRegex )
Message-Id: <Pine.GSO.3.96.970628220355.16294Z-100000@kelly.teleport.com>
On Sun, 29 Jun 1997, Miten S Mehta wrote:
> Subject: lastIndexOf ( String, SubStringRegex )
> I need to get the last match to end of file. any hint?
I think you'll need to be more explicit. Reading both the subject line and
the phrase "last match to end of file", I'm not sure what you want. Could
you try saying it again? Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 28 Jun 1997 22:21:16 -0600
From: chris.deehan@east.sun.com
Subject: Learning Perl
Message-Id: <867554008.30837@dejanews.com>
Hi--I am learning Perl from scratch with the O'Reilly book "Learning
Perl".
I am using the Korn shell and perl is located in /usr/dist/exe/perl.
I am copying the script right out of the book and I continually get the
error message of "perl1[4]: syntax error at line 5 : `;' unexpected"
FYI--I attempted to remove the ";" from line 5 (and I assuming line 5 is
chop($name);) and I got the same error. I also got the same error when I
commented out the line??
Any ideas why this error keeps on harassing me?
Here is the script:
#!/usr/dist/exe/perl
@words = ("camel", "llama", "oyster");
print "What is your name?";
$name=<STDIN>;
chop($name);
if ($name eq "Chris") {
print "Hello Chris! You smell terrific!\n"
} else {
print "Hello $name! You are a big dummy!\n";
print "What is the secret word?.....dum dum";
$guess = <STDIN>;
chop($guess);
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Sat, 28 Jun 1997 19:48:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: stabro@almatel.net
Subject: Re: Need PID of qx{command}
Message-Id: <Pine.GSO.3.96.970628193132.16294I-100000@kelly.teleport.com>
On 27 Jun 1997 stabro@almatel.net wrote:
> I need to capture output of an external program:
>
> $stuff=`ProgName args`;
>
> However, due to network conditions, the poor program sometimes
> hangs (never returns).
If the command will produce just a small amount of output (under a few K),
I think you could fork a child process which can pipe its output back to
your parent process. If it doesn't die after a certain amount of time,
kill it. (Use HUP first, then try INT or KILL.) After it's dead, reading
the pipe won't be able to hang, of course.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 29 Jun 1997 05:54:15 GMT
From: roustan@wwa.com (Yvon D. Roustan)
Subject: Perl and PGP interface
Message-Id: <5p4ta7$b5e$1@kirin.wwa.com>
I created a Perl5 script program that generates a message into a
variable I call '$CryptFile', calls a subroutine to filter the message
through PGP with the -f option and then emails with a 'sendmail' module
or with a plain 'mail' command to any email address of my choice.
The problem is that the PGP filter subroutine does not work at all. It
does not work even if I incorporate the commands in the PERL script. It
works from the UNIX command line in my APACHE server. Everything else
works, the perl script works, the mailing module works and it emails
automatically, but I the encryption subroutine does not encrypt
on the fly using PGP. PGP is operational in my system and I use it all
the time, I have even incorporated it to my Pine mailer for selective
emailing to individual recipients. However, when it comes to operating it
automatically on the fly from the Perl script it does not work.
According to the Official PGP Users's Guide by Phillip R. Zimmerman,
The MIT Press pages 57 to 58:
____________________________________________
Using PGP as a Unix-Style Filter ...The output of one application can be
directly fed through a pipe to be read as input to another application.
For this to work, the applications must be capable of reading the raw
material from "standard input" and writing the finished output to
"standard output". PGP can operate in this mode. ...
To use a Unix-style filter mode, reading from standard input and writing
to standard output, add the '-f' option, like so:
pgp -feat her_userid < inputfile > outputfile
_______________________________________________
The problem I encounter is that the bits I am trying to filter from
the variable $CryptFile within the perl script (not an actual file in the
directory), through the pgp -f filter, are not processed as a filter as a
subroutine such as the following for example:
pgp -feat her_userid < $CryptFile > $outputfile
___________________________________________
I am able to encrypt a file from the command prompt using Perl and PGP
so long as the message resides as a physical file in my public directory.
For example if the message is a file named 'message'in my public directory,
the following program I call 'encrypt.cgi' generates an encrypted file in
the public directory under the name 'message.asc' which I then can email
manually:
Thus:
Program encrypt.cgi:
#!/usr/bin/perl
# encrypt.cgi
$filename = "message"; # I must type the file 'message' manually
# in my public directory
open(OUT, "| pgp -eat '$filename' userID");
close(OUT)
Procedure:
__________________________
After editing and saving a test file under the name 'message' in my
directory this program, when run from the UNIX command prompt with perl or
perl5, (with the command: perl encrypt.cgi), generates an encrypted file
in the same directory with the name 'message.asc' containing the encrypted
contents of the 'message' file. I can then easily email the encrypted file
'message.asc'.
__________________________
I does not work, however, when I try modifying this program into a
subroutine to be executed from the main Perl script. I have tried many
variations without success. I am not interested at this time in the CPAN
modules, I am only interested in the reason it fails to perform.
The following are some of the variations I have tried:
Variation number 107
RESULTS: It send the full message without encryption
USE: &EncryptOrder($CryptFile); # to call the subroutine
The subroutine being:
sub EncryptOrder {
local($CryptFile) = @_;
$filename = "$CryptFile"; # note this is a variable, not an actual file
# in the public directory.
open(OUT, "| pgp -feat '$filename' userspublickey" > $CryptFile);
print(OUT);
close(OUT);
return ($CryptFile);
}
____________________________________________________
Variation number 102
RESULTS: Emails an empty message with the headers but no content, does not
encrypt anything.
USE: local ($CryptFile) = &getOrder1($user, email, $street, etc. ); # to call
# the subroutine
The subroutine being:
sub getOrder1 {
.....
etcetera
.....
$filename = "$CryptFile";
open(OUT, "|pgp -feat userpublickey < $filename" > $CryptFile);
# print OUT $filename;
close OUT;
return($CryptFile);
}
____________________________________________________
Variation number 100
RESULTS: Emails a message with the headers and the name crypt.out, but
no content, and no encryption.
USE: local ($CryptFile) = &getOrder1($user, email, $street, etc. ); # to call
# the subroutine
The subroutine being:
sub getOrder1 {
.....
etcetera
.....
if ($#ARGV >=0) {
$CryptFile = shift @ARGV;
} else {
$CryptFile = "crypt.out";
}
$filename = "$CryptFile";
open(OUT,"| pgp -feat userpublickey < $filename > $CryptFile") || die "Can't run pgp\n";
# print OUT $filename;
close(OUT);
return($CryptFile);
}
____________________________________________________
Variation number 105
RESULTS: Emails the complete message with the headers and the text. However,
no encryption at all. In other words the complete content but no encryption.
USE: local ($CryptFile) = &getOrder1($user, email, $street, etc. ); # to call
# the subroutine
The subroutine being:
sub getOrder1 {
.....
etcetera
.....
$filename = "$CryptFile";
open(OUT, "|pgp -feat userpublickey" > $CryptFile);
print OUT $filename;
close OUT;
return($CryptFile);
}
____________________________________________________
Variation number 106
RESULTS: Emails a message without encryption containing all the test
comments within the script such as those generated by
print "<!-- Got tax1: $tax1 -->\n";
It does not email the $CryptFile message.
USE: local ($CryptFile) = &getOrder1($user, email, $street, etc. ); # to call
# the subroutine
The subroutine being:
sub getOrder1 {
.....
etcetera
.....
$filename = "$CryptFile";
$childpid = open ( CHILD, "-|");
if ( !$childpid ) {
open(OUT, "|pgp -feat userpublickey" );
print OUT $filename;
close OUT;
exit;
}
$CryptFile = join('', <CHILD>);
close CHILD;
return($CryptFile);
}
____________________________________________________
# Variation number 109
# Sends Server error
# Note this alternative does not use 'sendmail' but uses 'mail'
# and is also piping in and piping out. From the Unix command
# line it works fine it encrypts and emails an empty message.
sub EncryptOrder {
open(OUT, "|pgp -eatf roustan|mail nica@pobox.com");
print OUT $CryptFile;
close(OUT);
}
# Comment out (#) &SendMail
# Change print $CryptFile to print $message
____________________________________________________
Has someone had this problem before and can you offer any ideas or
suggestions. Thank you for your attention.
Regards,
Yvon D. Roustan
roustan@wwa.com
Following is the actual perl script summarized as much as possible.
This perl script collects the information from another perl script (not
included here) which passess the information through an html form and
puts it into the $CryptFile variable. The subroutine then tries to
encrypt the message on the fly using PGP as a filter as described
above in the Official PGP User's Guide, basically using variations of
of PGP as a filter as follows:
pgp -feat her_userid < $CryptFile > $outputfile
and a 'sendmail' library not included here (for variation 109 I used
the command 'mail')
++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++
#!/usr/local/bin/perl5/perl
# message.cgi
push(@INC, "/your_cgi_library");
require 'forms-lib.cgi';
# Uses &GetFormInput();
.....
etcetera, etcetera, etcetera,
.....
# --- Global Variables ---
MAIN: {
local($subject) = "Encrypted Web Message"; # marks this message.
# Make this your own address for testing purposes.
local($orderdept) = "youremail\@youremailaddress.com"; # receiver of messages.
local($tax1) = 0.00; #unformatted field
print "<!-- Got tax1: $tax1 -->\n";
.....
etcetera, etcetera, etcetera
.....
# Extract information from the URL.
local(%input) = &GetFormInput();
local($user) = $input{'user'};
local($email) = $input{'email'};
.....
etcetera, etcetera, etcetera
.....
# Do error checking on Name and E-mail fields.
......
etcetera, etcetera, etcetera
......
print "Content-type: text/html\n\n";
# Set the mail message info.
local($CryptFile) = &getOrder1($user, $email, $street, $city, $state,
etcetera, etcetera, etcetera
$Name);
# Encrypt the message. Used only in variation 107 and variation 108 & 109
# &EncryptOrder($CryptFile); # remove the comment # for 107, 108 and 109
# Send the mail message, from the user.
&SendMessage($email, $orderdept, $subject, $CryptFile); # comment (#) for
# 107, 108, and 109.
print "<HTML><HEAD>\n";
print "<TITLE>GLOBAL SHOPPING SERVICE - Order Sent</TITLE>\n";
print "<BODY><H1>Order Sent</H1>\n";
print "<PRE>\n";
print $CryptFile; # This prints the contents on the screen to the user.
print "</PRE>\n";
print "<H2>Thank You</H2>\n";
print "<BR><HR SIZE=3 WIDTH=70%><BR>\n";
print &Footer::GetFooter();
print "</BODY></HTML>\n";
}
# -- Utility Functions --
sub getOrder1 {
local($user, $email, $street, $city, $state, $zip, $items, $total,
$shipping, $Name) = @_;
local($CryptFile) = "
User: $user
E-mail: $email
Name: $Name";
.....
etcetera, etcetera, etcetera
.....
return($CryptFile);
}
# The above script was used with the variations in subroutine below
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# __________________________________________________
# Variation number 100
# emails a message with the headers and the name crypt.out, but no
# content, and no encryption
sub getOrder1 {
if ($#ARGV >=0) {
$CryptFile = shift @ARGV;
} else {
$CryptFile = "crypt.out";
}
$filename = "$CryptFile";
open(OUT,"| pgp -feat userpublickey < $filename > $CryptFile") || die "Can't run pgp\n";
# print OUT $filename;
# $Passwd = "pass_word";
# open(OUT,"| crypt '$Passwd' > $CryptFile") || die "Can't run crypt\n";
# while(<>) {
# print OUT;
# }
close(OUT);
return($CryptFile);
}
# ________________________________________________________
# Variation number 106
# emails a message without encryption containing all the comments within
# of the type print "<!-- Got tax1: $tax1 -->\n"; used for testing the
# perl script. It does not email the expected content of $CryptFile.
sub getOrder1 {
$filename = "$CryptFile";
$childpid = open ( CHILD, "-|");
if ( !$childpid ) {
open(OUT, "|pgp -feat userpublickey" );
print OUT $filename;
close OUT;
exit;
}
$CryptFile = join('', <CHILD>);
close CHILD;
return($CryptFile);
}
# ____________________________________________________
# Variation number 105
# emails an empty message with the headers but no content, does not encrypt
# anything.
sub getOrder1 {
$filename = "$CryptFile";
open(OUT, "|pgp -feat userpublickey" > $CryptFile);
print OUT $filename;
close OUT;
return($CryptFile);
}
# _________________________________________________
# Variation number 107
# Sends Server Error
sub EncryptOrder {
local($CryptFile) = @_;
$filename = $CryptFile; # variable within order.cgi script
open(OUT, "|pgp -feat '$filename' userpublickey" > $CryptFile);
print OUT;
close(OUT);
return($CryptFile);
}
# _________________________________________________
# Variation number 108
# Sends Sends the full message without encryption of anykind.
sub EncryptOrder {
local($CryptFile) = @_;
$filename = $CryptFile; # variable within order.cgi script
open(OUT, "|pgp -feat '$filename' userpublickey" > $CryptFile);
print OUT filename;
close(OUT);
return($CryptFile);
}
# _________________________________________________
# Variation number 109
# Sends Server error
# Comment out (#) &SendMail
# Change print $CryptFile to print $message
sub EncryptOrder {
local($CryptFile) = @_;
$filename = $CryptFile; # variable within order.cgi script
open(OUT, "|pgp -eatf roustan|mail nica@pobox.com");
print OUT $filename;
close(OUT);
}
------------------------------
Date: Sat, 28 Jun 1997 20:02:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jon Ewing <jon@webdev.co.uk>
Subject: Re: Question: split and anonymous arrays
Message-Id: <Pine.GSO.3.96.970628195451.16294K-100000@kelly.teleport.com>
On 27 Jun 1997, Jon Ewing wrote:
> If I understand things right, [split /\t/, $line] will create an
> anonymous reference to the array created by splitting the line $line at
> every tab.
So far, so good.
> Then, to get an element out we can do something like
>
> $mainarray = [split /\t/, $line];
> print @$mainarray[0];
Oops! You want a dollar sign in front, since you want an element instead
of a slice.
print $$mainarray[0];
Although I prefer to write it this way.
print $mainarray->[0];
> But is it possible to avoid using the string $mainarray?
Sure. You can call it $something_else. :-) But if you want to use it as a
reference, you have to mention it somewhere.
> i.e. why doesn't this work..
>
> print @[split /\t/, $line][0];
Maybe you want a literal slice?
print (split /\t/, $line)[0];
Although, as you say, there are better ways to do this.... Hope this
helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 29 Jun 1997 00:54:44 -0500
From: Wesley Miaw <wesley@woais.com>
Subject: Re: Question: split and anonymous arrays
Message-Id: <33B5F8A5.82B64386@woais.com>
Jon Ewing wrote:
>
> If I understand things right, [split /\t/, $line] will create an
> anonymous
> reference to the array created by splitting the line $line at every
> tab.
>
> Then, to get an element out we can do something like
>
> $mainarray = [split /\t/, $line];
> print @$mainarray[0];
>
> But is it possible to avoid using the string $mainarray?
>
> i.e. why doesn't this work..
>
> print @[split /\t/, $line][0];
I'm not completely sure if this is what you're looking for, or if it will work
correctly, but to forget $mainarray, might you do the following?
[split(/\t/, $line)];
print $_[0];
I don't know if the array reference will be passed to the default variable $_,
but if it does, that would work and you aren't creating an extra variable,
which is just about the only reason I can think of avoiding $mainarray, other
than hoping for faster execution.
--
Wesley Miaw wesley@woais.com
World of Artists Internet Services http://www.woais.com/
71 Middlesex Drive Tel: 518-439-0412
Slingerlands, NY 12159 FAX: 518-439-9722
------------------------------
Date: Sat, 28 Jun 1997 21:17:28 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Otis Gospodnetic <otis@acunet.net>
Subject: Re: removing weird characters
Message-Id: <Pine.GSO.3.96.970628210717.16294R-100000@kelly.teleport.com>
On Sat, 28 Jun 1997, Otis Gospodnetic wrote:
> I'm parsing some text with a perl script and occasionally I hit
> characters like: =A7 and they break my script every time :(
You've got to make your script tougher. It sounds like a real wimp. Have
you tried feeding it spinach? That works for Popeye. :-)
> Do, does anyone know what kind of character this is? (this is just an
> example, there are a number of other characters that also break myt
> script) Is this a control character?
It looks like a character with the high bit set. (On my machine, it shows
up as the German character which represents a double s.) So, did you
assume that only printable characters might be sent to your script? Tsk
tsk. :-)=20
> Does anyonek now what these characters are, how to detect them and maybe
> s/// them ?=20
Don't think of what you want to remove, since you might forget one. Think
of what you want to keep, and toss the rest. Change this listing as
needed, of course. (And note that I'm explicitly including space as a
keeper.)=20
$string =3D~ tr/A-Za-z0-9, .;+//cd;=09# Remove all not listed
Of course, this will turn 'nu=A7' into 'nu' which might drive somebody nuts
in an instant, at least if they speak German. But that's not a Perl
problem, so I'll leave that for another newsgroup to discuss. Hope this
helps!=20
--=20
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 29 Jun 1997 01:47:18 GMT
From: gthb@rhi.hi.is (Gunnlaugur Thor Briem)
Subject: split dumping core!
Message-Id: <5p4er6$hn9@eldborg.rhi.hi.is>
Keywords: split core dump
Hi all,
I've bumped into rather an oddity: When I run the following, and $_
ends with a space, Perl dumps core on me!
@tokens = split(/(\b&\b|\bAND\b|\b\|\b|\bOR\b|\bNOT\b|\(|\))|\s+/i);
This doesn't happen if that last \s+ is placed inside the parantheses,
but I don't want that included as a token.
Has anyone else encountered this, and perhaps found a neat workaround?
I'm running Perl 5.001 on Linux (kernel 2.0.30), on a Pentium Pro.
Regards,
- Gulli.
- - - - - - - - - - - - - - - -
/ Gunnlaugur Thor Briem \
| Student of Electrical Engineering |
| gthb@hi.is |
\ http://www.hi.is/~gthb /
- - - - - - - - - - - - - - - -
Don't get even ... get odd!
------------------------------
Date: Sat, 28 Jun 1997 22:18:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gunnlaugur Thor Briem <gthb@rhi.hi.is>
Subject: Re: split dumping core!
Message-Id: <Pine.GSO.3.96.970628221709.16294b-100000@kelly.teleport.com>
On 29 Jun 1997, Gunnlaugur Thor Briem wrote:
> Subject: split dumping core!
> I'm running Perl 5.001 on Linux (kernel 2.0.30), on a Pentium Pro.
If you can reproduce this under 5.004, please submit a bug report. Chances
are good, though, that it's been fixed for a long time. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 28 Jun 1997 20:16:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tri Tram <tram@olympic.seas.ucla.edu>
Subject: Re: strings
Message-Id: <Pine.GSO.3.96.970628200928.16294M-100000@kelly.teleport.com>
On Fri, 27 Jun 1997, Tri Tram wrote:
> I am wondering, is there a string to integer conversion under perl?
> If I have a string:
> $string="44";
>
> if ($string > 10)
> {
> print "$string is greater than 10";
> }
One of the things that make Perl a great programming language is that
there's a feature for everybody. Here's a nifty one which will help you
out: You can use Perl to find out what some code will do, and you don't
even have to read the documentation first!
Just save your code to a file; let's imagine that you call the file
"program". Now, when you type the command "perl program", perl will show
you exactly what your code would output if you used perl to run it. Of
course, this method is much faster than waiting for replies to come back
from the newsgroup. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 28 Jun 1997 22:49:33 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
To: Mark Thompson <mwt@cyberg8t.com>
Subject: Re: Validating E-Mail addresses and URL's
Message-Id: <Pine.SGI.3.96.970628224658.28806A-100000@davinci.bergen.org>
>/:http://(/: unmatched () in regexp at ./cnvt_member_db.pl line 251.
>cnvt_member_db.pl terminated abnormally, update not completed.
>note: the second line is the message showing that the program
>terminated with an error.
slashes are interpreted as actual perl slashes, not as characters.
when you write
/http://,
it thinks you are ending the search string with
that second slash! try
/http:\/\//
while that may LOOK weird, you're using the ESCAPE sequences... like:
\$ for a $ sign
\. for a .
\\ for a \
and \/ for a /
Hope it helps a LITTLE...
:)
----------------
| "I don't contemplate it, I just sit and think about it."
| - Sonia Balsky
----------------
Jeff "TechMaster" Pinyan | http://www.bergen.org/~jefpin
HTML/CGI Designer and Consultant and JavaScripter
jefpin@bergen.org | TechMasterJeff@juno.com
Got a JavaScript/CGI/Perl question or problem? Let me know!
webXS - the new eZine for WebProgrammers! webXS@juno.com
Visit us @ http://www.bergen.org/~jefpin/webXS
------------------------------
Date: 29 Jun 1997 05:06:00 GMT
From: citicentr@aol.com (CitiCentr)
Subject: Variable help please
Message-Id: <19970629050601.BAA19488@ladder02.news.aol.com>
I was hoping someone could help me with a quick problem- is there anyway
in Perl to have one variable become part of another variable name? For
instance, if I wanted to test ($cat1 eq 1) but I wanted the 1 to be
dependent on a variable $calendar (ie, if $calendar was 2 then the
expression would be ($cat2 eq 1)...is that possible?
Thanks for your time!
- m.
------------------------------
Date: Sat, 28 Jun 1997 22:16:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Perry <perry@alpha.jpunix.com>
Subject: Re: Where is Perl 5.004?
Message-Id: <Pine.GSO.3.96.970628220558.16294a-100000@kelly.teleport.com>
On 29 Jun 1997, John Perry wrote:
> Subject: Where is Perl 5.004?
> The subject pretty much says it all. All of the FTP sites
> mentioned in the FAQ didn't seem to have it and prep.ai.mit.edu doesn't
> seem to be responding at this time. Where can I get Perl 5.004?
I think you've found a bug in the FAQ, so I'm sending a copy of this to
the FAQ maintainers (who may already know about this). The link from this
page would be good...
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq2/
What_machines_suport_Perl_Wher.html
...except that it has a trailing comma, which messes up the URL. Of
course, the link on that page should look like this.
http://www.perl.com/CPAN/src/latest.tar.gz
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 28 Jun 1997 22:02:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: CARMAN <Carman@cris.com>
Subject: Re: while(<INFILE>) fails to read to EOF?
Message-Id: <Pine.GSO.3.96.970628220200.16294Y-100000@kelly.teleport.com>
On 29 Jun 1997, CARMAN wrote:
> The problem I've discovered, is that the second while() loop
> is not reading all the way through the input file. The input
> file is 500 lines, but the loop stops reading after 454.
Maybe you're using a DOS/Windows machine and you didn't use binmode on a
binary file? Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
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 680
*************************************