[11087] in Perl-Users-Digest
Perl-Users Digest, Issue: 4687 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 19 11:05:16 1999
Date: Tue, 19 Jan 99 08:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 19 Jan 1999 Volume: 8 Number: 4687
Today's topics:
Re: "Back button" in CGI script <spam@dikkelul.com>
Re: "Back button" in CGI script (Steve Linberg)
Re: Array slices with a maximum length <jdf@pobox.com>
Re: Calculate next [mon..sun]day (Steffen Beyer)
Re: Calling a sub (Tad McClellan)
Re: Changing elements in a text file (Tad McClellan)
Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus droby@copyright.com
Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus (I R A Aggie)
Re: Endian converter: Does anyone know of one? (Steffen Beyer)
Re: File Handle Elements as numeric values <staffan@ngb.se>
Re: File Handle Elements as numeric values (Tad McClellan)
Formatting in Perl richfunk@hotmail.com
Re: Formatting text ? <gellyfish@btinternet.com>
Re: Formatting text ? (Tad McClellan)
Hand Coded XS - Attempting to Learn <richardsonja@logica.com>
Re: How to determine time? <spam@dikkelul.com>
Re: How to determine time? ()
Re: How to determine time? richfunk@hotmail.com
Re: How to determine time? (Tad McClellan)
Re: modem access (Bbirthisel)
Perl CGI Error while calling a C function after making <blackk@dial.oleane.com>
Re: Perl Criticism (I R A Aggie)
Perl to C++ converter? <gino@wpi.edu>
Re: Perl Web browser problem <rmartens@nmsmedia.nl>
Re: Perl Web browser problem <rmartens@nmsmedia.nl>
Re: Perl Web browser problem (Clay Irving)
Re: Running Perl scripts for Macs (Dan Wilga)
Re: Send Signal when perl exit ??? <gellyfish@btinternet.com>
Re: split not working... (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 19 Jan 1999 16:02:36 +0100
From: "Willem" <spam@dikkelul.com>
Subject: Re: "Back button" in CGI script
Message-Id: <78270m$282$1@dinkel.civ.utwente.nl>
>You could use JavaScript:
There is another option, which supports also non-java browsers (lynx,
others?)
Make your perl script generate a new form, with the already filled in values
as VALUE tags. Lets say, some user had filled in his name in the <INPUT>
field. Then make your perl script generate <INPUT NAME=name TYPE=text
VALUE="$input_from_user">
>> If you can, please cc: your response to me via email, as I don't always
>> get to check the newsgroups at work.
>
>Then you shouldn't post here if you can't check for an answer.
Why not? It could be helpful for others. Besides, is it so hard to do a CC ?
------------------------------
Date: Tue, 19 Jan 1999 10:15:01 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: "Back button" in CGI script
Message-Id: <linberg-1901991015010001@ltl1.literacy.upenn.edu>
In article <36A4134D.4BD2@worldnet.att.net>, mr.marketing@worldnet.att.net
wrote:
> I want to duplicate the
> browser's "back button" functionality.
You can't. You can do it with javascript for browsers that both support
javascript and have it turned on, but you have to count on both of those
conditions, and it will obviously fail when either is false. Abigail
wrote a good explanation of why this is impossible. HTTP_REFERRER is not
guaranteed to contain anything.
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>
------------------------------
Date: 19 Jan 1999 16:09:30 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Array slices with a maximum length
Message-Id: <m3btjv9u51.fsf@joshua.panix.com>
bart.lateur@skynet.be (Bart Lateur) writes:
> I don't get it.
>
> print 2<1;
> >>
> Nothing.
print 0 + (2<1);
>> 0
If you coerce a logical("boolean") expression into a numeric context,
you'll get 0 and 1.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 19 Jan 1999 11:14:59 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Calculate next [mon..sun]day
Message-Id: <781pfj$jmp$1@en1.engelschall.com>
Steve Lamb <morpheus@no-spam.calweb.com> wrote:
> On Mon, 18 Jan 1999 17:02:24 GMT, marcel_anthonijsz@my-dejanews.com
> <marcel_anthonijsz@my-dejanews.com> wrote:
>>I want to calculate the date of next [mon..sun]day, what is the easiest and
>>most nice way to do this? It should work after the year 0 .. (Hey, my brain
>>has a Y2K bug!).
> $newtime = time + 604800;
> @time = localtime($newtime);
> $time[4] += 1;
> print("$time[4]+1/$time[3]/$time[5]\n");
> eg:
> {morpheus@web1;0.40:/s1/morpheus}date ; perl blah
> Mon Jan 18 14:43:06 PST 1999
> 1/25/99
IMHO, this is neither easy nor nice, but it admittedly has the advantage
of not needing additional code.
But if you want to have it easy AND nice, you should consider using one
of the Date::* modules like Date::Manip or Date::Calc, which provide
functions for exactly this problem.
Reading the FAQing manual ;-) ("man perlfaq" or "perldoc perlfaq") should
also help a great deal.
Yours,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software
http://www.perl.com/CPAN/authors/id/STBEY/ for Download)
New: Build'n'Play 2.1.0 (all-purpose Unix batch installation tool)
http://www.oreilly.de/catalog/perlmodger/bnp.html
------------------------------
Date: Tue, 19 Jan 1999 09:00:01 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Calling a sub
Message-Id: <hl6287.8of.ln@magna.metronet.com>
Gernot Homma (gernot@cat.at) wrote:
: This is a multi-part message in MIME format.
^^^^^^^^^^^^^^
Please configure your "newsreader" properly.
MIME is not appropriate on Usenet.
: $mysub = "function1";
: sub function1
: {
: print "Hello";
: }
: I want to call "function1" though the scalar $mysub.
: Is there a gobal solution?
References (documented in 'perlref.pod')
: I know I could solve this problem with "if" -
: statements, but I do'nt want to work this way.
---------------------
#!/usr/bin/perl -w
use strict;
my $mysub = \&function1;
&$mysub;
sub function1
{
print 'Hello';
}
---------------------
: Content-Type: text/x-vcard; charset=us-ascii;
vcard stuff has no place on Usenet either.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 19 Jan 1999 07:41:29 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Changing elements in a text file
Message-Id: <922287.m5f.ln@magna.metronet.com>
Artoo (r2-d2@REMOVEbigfoot.com) wrote:
: How can you change specific elements in a text file?
This is discussed in the Perl FAQ, part 5:
"How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
: EG: Text file:
: hello|test|1234|
: goodbye|tset|4321|
: How can you make perl just edit the file and replace 1234 with 5678. Is it
: possible
In the special case (as in your example) where you want to
replace *exactly the same number* of characters, you can avoid
reading/writing the entire file by using seek() and tell()
(look them up in 'perlfunc.pod').
: or do you have to bring in the file as an array and s/// the value
: and then right the info back to the file?
That is the usual approach, except you don't have to read it into
an array, you can do it a line at a time. See the above FAQ for
an example of the "line at a time" approach.
: I'm dealing with large files that
: will use unnecessary processor power to write the entire file each time it
: is changed.
You are pretty much stuck with rewriting the whole thing, unless
the only updates you want to do are replacing the same number of
characters.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 19 Jan 1999 14:23:34 GMT
From: droby@copyright.com
Subject: Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <7824gr$v01$1@nnrp1.dejanews.com>
In article <ebohlmanF5pMvx.7u6@netcom.com>,
Eric Bohlman <ebohlman@netcom.com> wrote:
> Jonathan Feinberg <jdf@pobox.com> wrote:
> : dturley@pobox.com writes:
>
> : > (Remembering that half the world is below average intelligence.)
>
> : I think you'll find that half the world is below *median*
> : intelligence. HTH!
>
> Since psychometricians have, for the last 75 years, assumed that any
> instrument that is a valid measurement of intelligence must give scores
> that follow a normal distribution (one of whose properties is symmetry,
> i.e. the mean and median are identical), his statement isn't that far off.
>
That assumes that the psychometricians have made a correct assumption. I
wouldn't assume that at all myself.
--
Don Roby
Figures often beguile me, particularly when I have the arranging of them
myself; in which case the remark attributed to Disraeli would often apply
with justice and force: "There are three kinds of lies: lies, damned lies and
statistics." - Autobiography of Mark Twain
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 19 Jan 1999 10:06:32 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <fl_aggie-1901991006320001@aggie.coaps.fsu.edu>
In article <7824gr$v01$1@nnrp1.dejanews.com>, droby@copyright.com wrote:
+ In article <ebohlmanF5pMvx.7u6@netcom.com>,
+ Eric Bohlman <ebohlman@netcom.com> wrote:
+ > Since psychometricians have, for the last 75 years, assumed that any
+ > instrument that is a valid measurement of intelligence must give scores
+ > that follow a normal distribution (one of whose properties is symmetry,
+ > i.e. the mean and median are identical), his statement isn't that far off.
+ That assumes that the psychometricians have made a correct assumption. I
+ wouldn't assume that at all myself.
Indeed. Back-of-the-envelope calculations would say that if they're right,
then there are as many geniuses as there are morons.
James - I'd postulate a X^2 distribution
------------------------------
Date: 19 Jan 1999 11:19:16 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Endian converter: Does anyone know of one?
Message-Id: <781pnk$jmp$2@en1.engelschall.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> krish_v@my-dejanews.com wrote:
>>Has anyone come across Perl code that can convert
>>binary files in Big-Endian format to little-Endian format ?
> Yes. See pack/unpack. "N" and "n" indicate Big Endian, long (4 bytes)
> and short (2 bytes) integer, respectively, "V" and "v" indicate Little
> Endian (long and short).
> Example: convert 4 bytes
>
> $littleendlong = pack("V", unpack("N", $bigendlong));
Another possibility is using the Bit::Vector module, which can handle
(and copy) chunks of bits of arbitrary size, including 8 bits (= 1 byte).
Wether pack/unpack or this module is preferrable depends on your problem.
See my signature for URLs where to find this module, in case you're
interested.
Good luck!
Yours,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software
http://www.perl.com/CPAN/authors/id/STBEY/ for Download)
New: Build'n'Play 2.1.0 (all-purpose Unix batch installation tool)
http://www.oreilly.de/catalog/perlmodger/bnp.html
------------------------------
Date: Tue, 19 Jan 1999 15:53:29 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: File Handle Elements as numeric values
Message-Id: <36A49C69.34B9CE5D@ngb.se>
Hi!
> How can you read an element from a file handle as a numeric value
> rather than a text value.
Just use them.
ie
open(FILE, "file.name") || die "Couldn't open 'file.name': $!\n";
while ($line = <FILE>){
@values = split(/\|/, $line);
$values[0] += 256;
print $values[0];
}
or whatever.
Staffan
------------------------------
Date: Tue, 19 Jan 1999 07:59:50 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: File Handle Elements as numeric values
Message-Id: <m43287.m5f.ln@magna.metronet.com>
Artoo (r2-d2@REMOVEbigfoot.com) wrote:
: How can you read an element from a file handle as a numeric value rather
: than a text value.
You don't need to.
: How can the file handle read any of the values from the array created as
: their numeric value so they can be manipulated numerically, rather than as
: text values which can not be manipulated numerically.
If you use a string where perl wants a number, perl will convert
the string into a number, and then perform the requested
operation.
$num = '10'; # string '10'
$product = $num * 2; # string '10' automatically converted to
# number 10, then used as operand
print "$product\n"; # prints 20
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 19 Jan 1999 13:45:51 GMT
From: richfunk@hotmail.com
Subject: Formatting in Perl
Message-Id: <7822ac$t0c$1@nnrp1.dejanews.com>
I am using an email subroutine which is called via
&Send_email($emailsubject, $emailbody, @recipients);
so far, I have only used $emailbody to include an unformatted text string. I
am now trying to include the details of an order form in $emailbody. As much
as possible, I want to format this text.
Is the Perl Format funtion the best/ only option ?
The following is in example of my format code. format EMAILFORMAT =
-----------------------------------------------------------------------------
--- -------------------------- Order Details:
Name: @<<<<<<<<<<<<<<<<<<<<<<<<<Cost centre: @<<<<<<<<<<<<<<<<<
$subs{name} , $subs{costcentre}
Phone: @<<<<<<<<<<<<<<<<<<<<<<<< job #: @<<<<<<<<<<<<<<<<<
$subs{phone}, $subs{ jobnumber }
.
How do i now assign this formatted text 4to the variable $emailbody ?
Any help or tips would be much appreciated......
Cheers,
Rich Funk.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 19 Jan 1999 12:58:29 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Formatting text ?
Message-Id: <781vhl$fn$1@gellyfish.btinternet.com>
On Tue, 19 Jan 1999 11:02:39 GMT wandr@my-dejanews.com wrote:
> I am currently using an email subroutine which I call using
> &Send_email($emailsubject, $emailbody, @recipients);
>
> So far, $emailbody has only been a text string which has not required
> formatting. I now need $emailbody to contain an order form with whch
> formatting is essential.
> Is by best/ only option to use the Perl Format function ?If so, could someone
> please provide me some tips on how to use it.
>
> The following is an example of my understanding of formatting.
>
> format EMAILFORMAT =
> -----------------------------------------------------------------------------
> --- -------------------------- Order Details:
>
> Name: @<<<<<<<<<<<<<<<<<<<<<<<<<Cost centre: @<<<<<<<<<<<<<<<<< $subs{name}
> , $subs{costcentre} Phone: @<<<<<<<<<<<<<<<<<<<<<<<< job #:
> @<<<<<<<<<<<<<<<<< $subs{phone}, $subs{ jobnumber } Fax:
> @<<<<<<<<<<<<<<<<<<<<<<<< Estimate: @<<<<<<<<<<<<<<<<<
> -----------------------------------------------------------------------------
> --- ----------------------------
>
> Can I simply use $emailbody = "EMAILFORMAT";
> Surely this would simply assign the string "EMAILFORMAT" to the variable ???
>
No you cant do that. I think the simplest way to do that would be to use
a 'here' document like:
$emailbody =<<MAILEND;
-----------------------------------------------------------------------------
Order Details:
Name: $subs{name} Cost centre: @$subs{costcentre}
Phone: $subs{phone } job #: $subs{ jobnumber }
Fax:
-----------------------------------------------------------------------------
MAILEND
I figure those funny ~Q things are just an artefact of your newsreaders
encoding.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 19 Jan 1999 08:12:54 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Formatting text ?
Message-Id: <6t3287.m5f.ln@magna.metronet.com>
wandr@my-dejanews.com wrote:
: I am currently using an email subroutine which I call using
: &Send_email($emailsubject, $emailbody, @recipients);
: So far, $emailbody has only been a text string which has not required
: formatting. I now need $emailbody to contain an order form with whch
: formatting is essential.
: Is by best/ only option to use the Perl Format function ?
No.
sprintf() can also be used.
sprintf() is documented in the 'perlfunc.pod' man page.
: If so, could someone
: please provide me some tips on how to use it.
-------------------
#!/usr/bin/perl -w
$subs{'~Qname~Q'} = 'name value';
$subs{'~Qcostcentre~Q'} = 'cost center value';
$emailbody = '-' x 80 . "\n"; # 80 hyphens
$emailbody .= sprintf "Name: %-26sCost centre: %-18s\n",
$subs{'~Qname~Q'}, $subs{'~Qcostcentre~Q'};
print $emailbody;
-------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 19 Jan 1999 14:43:52 -0000
From: "James Richardson" <richardsonja@logica.com>
Subject: Hand Coded XS - Attempting to Learn
Message-Id: <7825nr$jvb@romeo.logica.co.uk>
Hi,
I am trying to write a small perl extension, but not getting too far. I
think I am on the right track when I write the following, but it doesn't
work.
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
XS(jimbo)
{
dXSARGS;
if (items == 0) {
/*Return integer value 0*/
XSRETURN_IV(0);
}
/*Now check what we got given*/
if (items == 1) {
/*Just a string?*/
if ( SvPOK(ST(0))) {
/*P is a string*/
printf( "We got a string\n");
}
else if (SvIOK(ST(0))) {
printf( "We got an integer\n");
}
else if (SvNOK(ST(0))) {
printf ( " W e got a doublez\n");
}
}
XSRETURN_IV(1);
}
XS(boot_test_xs)
{
dXSARGS;
char* file = __FILE__;
XS_VERSION_BOOTCHECK ;
newXS("main::jimbo", jimbo, file);
ST(0) = &sv_yes;
XSRETURN(1
);
}
The program compiles correctly, but thats it...
Makefile.PL is (dodgy)
use ExtUtils::MakeMaker;
&WriteMakefile(
"LINKTYPE" => 'static',
'DISTNAME' => 'test',
'OBJECT' => 'test.o'
);
cssdev 53: perl Makefile.PL
Warning: Guessing NAME [test_xs] from current directory name.
Writing Makefile for test_xs
cssdev 54: make
[...]
cssdev 55: make perl
rm -rf ./blib/arch/auto/test_xs/test_xs.a
ar cr ./blib/arch/auto/test_xs/test_xs.a test.o && :
./blib/arch/auto/test_xs/test_xs.a
chmod 755 ./blib/arch/auto/test_xs/test_xs.a
Writing "Makefile.aperl" for this perl
Warning: Guessing NAME [test_xs] from current directory name.
Writing Makefile.aperl for test_xs
make -f Makefile.aperl perl
Writing ./perlmain.c
[...]
The perlmain.c has the line:
EXTERN_C void boot_test_xs _((CV* cv));
in it, so I would have hoped that I was defining a subroutine called
main::jimbo
any ideas please....
James Richardson
------------------------------
Date: Tue, 19 Jan 1999 15:52:14 +0100
From: "Willem" <spam@dikkelul.com>
Subject: Re: How to determine time?
Message-Id: <7826d7$rmo$1@dinkel.civ.utwente.nl>
Two options:
($sec, $min, $uur, $dag, $maand, $yr, $day2, $day3, $bla) =
localtime(time());
See man perlfunc -> localtime for exact parameters.
The other is (on unix) to use
$time = `/usr/bin/date`;
Good luck,
Willem
------------------------------
Date: Tue, 19 Jan 1999 14:59:00 GMT
From: matthew@Server.Network ()
Subject: Re: How to determine time?
Message-Id: <slrn7a977d.h6.matthew@Server.Network>
On Tue, 19 Jan 1999 13:15:27 GMT, info@netstyle.nl <info@netstyle.nl> wrote:
>Hi newsgroup,
>
>I would like to know how to put the time in a string variable.
>I know this:
>
>$tim= time;
[snip]
perldoc -f localtime
* $year += 1900 *
>thanks,
HTH!
>Michel
--Matthew
------------------------------
Date: Tue, 19 Jan 1999 14:48:22 GMT
From: richfunk@hotmail.com
Subject: Re: How to determine time?
Message-Id: <7825vi$8q$1@nnrp1.dejanews.com>
Use one of the following two perl funcions and pass it the value returned by
time.
...gmtime (timeval);
...localtime (timeval);
Rich,
email: richfunk@hotmail.com
In article <7820h8$rfl$1@nnrp1.dejanews.com>,
info@netstyle.nl wrote:
> Hi newsgroup,
>
> I would like to know how to put the time in a string variable.
> I know this:
>
> $tim= time;
>
> but this gives me the epoch-relative time and I do not want that.
> How to let $tim have the folowing content i.e.
> 19-01-1999/8.05PM
>
> ofcourse I want the actual hosstime instead of static stringcontent.
>
> thanks,
>
> Michel
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 19 Jan 1999 09:24:02 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to determine time?
Message-Id: <i28287.8of.ln@magna.metronet.com>
info@netstyle.nl wrote:
: I would like to know how to put the time in a string variable.
: How to let $tim have the folowing content i.e.
: 19-01-1999/8.05PM
perldoc -f localtime
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Jan 1999 15:14:24 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: modem access
Message-Id: <19990119101424.29736.00000235@ng127.aol.com>
Hi AJ:
>I am somewhat new to perl (especially on windows) and would like to know if
>any knows of any perl script/code that would allow me to read in a text file
>of phone/pager numbers, dial the number, leave a call back number, hang up
>and so forth and so on with each subsequent number.
Hmm...I don't know of anyone who has done this with a list of numbers,
but people HAVE used Win32::SerialPort to do it for single numbers.
The "subsequent number" problem is pretty simple - the key issues
involve detecting "BUSY" and handling other errors.
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Tue, 19 Jan 1999 15:15:50 +0100
From: "Black K" <blackk@dial.oleane.com>
Subject: Perl CGI Error while calling a C function after making an xs entension ?
Message-Id: <78247s$fea$1@minus.oleane.net>
Hello,
We want to call C functions (Library: libcm_mac.a, Headers: cm_mac.h ) from
Perl.
We used h2xs, changed the xs file to declare and modify the functions, ran
the Makefile.PL and then make.
The script generates a form. It runs well under the shell environment but
doesn't work when it is called by the browser as a cgi.
The cgi, the .a library, the .h, .pm, .so, files are in the same directory
When we run this script it stops when calling $for = $CICMac:.... and the
log is " Premature end of script headers".
We put a the cgi directory in "use lib" and in the PATH and PERL5LIB ENV
variable after testing each step one by one, but it stil does not work.
All directories and files have 755 or more permission.
Is there any security issue which would not allow a cgi to run an extension
? Is there anything we need to do in the Unix environment ? Is there any
other type of restriction ?
Thanks for your anwers to antalys@dial.oleane.com and cnlcontact@wanadoo.fr
PERL script:
#!/usr/local/bin/perl
use lib '/1/u3/c/h/channelb/public_html/CIC/cgi';
use ExtUtils::testlib;
use CICMac;
require "./cgi-lib.pl";
&ReadParse;
$ENV{'PATH'} = '/1/u3/c/h/channelb/public_html/CIC/cgi';
$ENV{'PERL5LIB'} = '/1/u3/c/h/channelb/public_html/CIC/cgi';
$tpe="6000002";
$societe="cnlcontact";
$URL_SERVEUR_CM="https://ssl.paiement.cic-banques.fr/test/paiement.cgi";
$VERSION = "1.2";
$montant = "420.00";
$reference = "12444";
$texte_libre = "texte libre";
$URL_SERVEUR_HOMEPAGE = " http://www.channelbridge.com/CIC/index.htm";
$URL_SERVEUR_OK = " http://www.channelbridge.com/CIC/succes.htm";
$URL_SERVEUR_ERR = " http://www.channelbridge.com/CIC/erreur.htm";
$langue = "frangais";
$societe = "cnlcontact";
$BOUTON_PAIEMENT = "Paiement par carte bancaire";
$formulaire = "";
$for = "test";
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<BODY BGCOLOR=\"#FFFFFF\">\n";
print "<H1>Test</H1>\n";
print "<hr>";
$for = &CICMac::CreerFCIC($URL_SERVEUR_CM,$VERSION,$tpe,$montant,
$reference,
$texte_libre,
$URL_SERVEUR_HOMEPAGE,
$URL_SERVEUR_OK,
$URL_SERVEUR_ERR,
$langue,
$societe,
$BOUTON_PAIEMENT,
$formulaire);
print "<H1>Test Fin</H1>\n";
print "</BODY>\n";
print "</HTML>\n";
.pm generated by the extension:
package CICMac;
use strict;
use Carp;
use vars qw($VERSION @ISA @EXPORT $AUTOLOAD);
require Exporter;
require DynaLoader;
require AutoLoader;
@ISA = qw(Exporter DynaLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw(
);
$VERSION = '0.01';
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
# XS function. If a constant is not found then control is passed
# to the AUTOLOAD in AutoLoader.
my $constname;
($constname = $AUTOLOAD) =~ s/.*:://;
my $val = constant($constname, @_ ? $_[0] : 0);
if ($! != 0) {
if ($! =~ /Invalid/) {
$AutoLoader::AUTOLOAD = $AUTOLOAD;
goto &AutoLoader::AUTOLOAD;
}
else {
croak "Your vendor has not defined CICMac macro $constname";
}
}
eval "sub $AUTOLOAD { $val }";
goto &$AUTOLOAD;
}
bootstrap CICMac $VERSION;
# Preloaded methods go here.
# Autoload methods go after =cut, and are processed by the autosplit
program.
1;
__END__
# Below is the stub of documentation for your module. You better edit it!
=head1 NAME
CICMac - Perl extension for blah blah blah
=head1 SYNOPSIS
use CICMac;
blah blah blah
=head1 DESCRIPTION
Stub documentation for CICMac was created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.
Blah blah blah.
=head1 AUTHOR
A. U. Thor, a.u.thor@a.galaxy.far.far.away
=head1 SEE ALSO
perl(1).
=cut
Thanks very much,
best regards,
Daniel BACH
------------------------------
Date: Tue, 19 Jan 1999 09:15:07 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl Criticism
Message-Id: <fl_aggie-1901990915070001@aggie.coaps.fsu.edu>
In article <m1hftooxep.fsf@halfdome.holdit.com>, merlyn@stonehenge.com
(Randal L. Schwartz) wrote:
+ >>>>> "I" == I R A Aggie <fl_aggie@thepentagon.com> writes:
+ I> + Daffy Duck is a celebrity...
+ I> Yeah, but he can't get a check cashed...
+ And he always gets stuck with a bill.
OH, THE HUMANITY!
+ use RimShot qw(ba dump dum!);
Oy!
James - ya can dress him up, but you can't take him anywhere... ;)
------------------------------
Date: Tue, 19 Jan 1999 10:35:47 -0500
From: Gino Cerro <gino@wpi.edu>
Subject: Perl to C++ converter?
Message-Id: <Pine.OSF.4.05.9901191034100.12596-100000@wpi.WPI.EDU>
Is there a script that converts Perl code to C++ code (for Unix/Linux)? I
thought I saw a listing for one a few weeks (while surfing some Perl web
pages) and cannot remember where.
Please include a private e-mail with response.
Thanks.
---------------------------
Gino Cerro -- gino@wpi.edu
http://www.wpi.edu/~gino
--------------------------
------------------------------
Date: Tue, 19 Jan 1999 15:24:22 +0100
From: "Ronald Martens" <rmartens@nmsmedia.nl>
Subject: Re: Perl Web browser problem
Message-Id: <7824ij$1cj$1@heracles.fw.cuci.nl>
>: I can run my perl script in telnet mode.
> Then you do not have a Perl problem.
Correct!
>: However when I want to run it in a browser
In a way of speaking, writing, reading...
> You cannot run perl in a browser (client).
Uh?
> Perl ain't got no server, so questions about servers do not
> belong in a Perl newsgroup.
You are very focussed!
> Try asking server configuration questions in a newsgroup that
> is about servers:
>
> comp.infosystems.www.servers.mac
> comp.infosystems.www.servers.misc
> comp.infosystems.www.servers.ms-windows
> comp.infosystems.www.servers.unix
Ok!
Ronald
------------------------------
Date: Tue, 19 Jan 1999 15:18:46 +0100
From: "Ronald Martens" <rmartens@nmsmedia.nl>
Subject: Re: Perl Web browser problem
Message-Id: <7824f7$1bm$1@heracles.fw.cuci.nl>
>I take this to mean that you have a shell account with an ISP, and
>you're using their web server, which they configured.
Yes, correct!
>If your script runs fine from the command line, but not through the
>browser, it's a huge clue that you are not dealing with a Perl problem.
>The problem is with the way your web server is configured, or it's a
>permission problem.
A bit of both, however I am not sure, the ISP's doc's were not conclusive.
However after five or more questions to the ISP suddenly The Perl script can
be called from within a browser ;-D and it runs fine.
It was a "environmental" problem !?!?
>All this and more can be found in the proper newsgroup(s) (not clpm).
>Just remember that CGI and Perl are not tied together. Just because
>you're having a CGI problem doesn't mean that you're having a Perl
>problem, especially if it's working correctly from the command line.
Thanks
Ronald.
------------------------------
Date: 19 Jan 1999 10:52:36 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Perl Web browser problem
Message-Id: <7829o4$242$1@panix.com>
In <77viu2$885$1@heracles.fw.cuci.nl> "Ronald Martens" <rmartens@nmsmedia.nl> writes:
>Does anyone has a clue?
I did, once.
>I can run my perl script in telnet mode.
>However when I want to run it in a browser I get a misconfiguration error. I
>set the MOD 777 for testing,
>use standard $|=1; used STDOUT and...
...and you forgot to include your code for us to see what's broken.
--
Clay Irving
clay@panix.com
------------------------------
Date: Tue, 19 Jan 1999 09:08:34 -0500
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: Running Perl scripts for Macs
Message-Id: <dwilgaREMOVE-1901990908350001@wilga.mtholyoke.edu>
> Does anyone know that if a script is able to run in a Windows
> environment, can it also be run in a Mac environment? Is there any major
> differences (ie. with Regular Expressions, special characters,
> functions) in the actual scripts itself.
Probably the biggest thing you'll have to worry about is path separators.
Instead of '/' or '\', Macs use ':'. The syntax rules for where to put the
':' are also a bit odd if you're used to Unix or PCs. There is a README
file that comes with MacPerl that describes how it works.
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: 19 Jan 1999 12:39:07 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Send Signal when perl exit ???
Message-Id: <781udb$f7$1@gellyfish.btinternet.com>
On 19 Jan 1999 06:36:46 GMT root wrote:
> i m writing two script that working together by sending each other signals..
>
> the problem is that when one script terminate (exit,die), the other don't
> know and still stay running in memory...
>
> so can i send signals to others when my perl program exit or die ?
>
Yeas that is eminently doable - you should find most of what you want
in the perlipc and perlvar manpages.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 19 Jan 1999 08:20:24 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: split not working...
Message-Id: <8b4287.m5f.ln@magna.metronet.com>
Scott Craig (scott.craig@moh.hnet.bc.ca) wrote:
: Keith Woodworth wrote:
: > @_ = grep(/$user/,@_);
: The special variable $_ was last used as an iterator for the list passed to
: the grep, so it should contain the last line of (the original value of) @_
: at this point.
No it shouldn't.
grep() local()izes its $_ variable:
----------------------
#!/usr/bin/perl -w
@_ = qw(one two three four);
$_ = 'foobar';
@_ = grep /two/, @_;
print "\$_ is '$_'\n";
----------------------
prints 'foobar', not 'four'...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4687
**************************************