[7913] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1538 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 26 21:07:58 1997

Date: Fri, 26 Dec 97 18: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           Fri, 26 Dec 1997     Volume: 8 Number: 1538

Today's topics:
     Re: Automatically POST (psullivan)
     Re: Automatically POST <shadowweb@worsdall.demon.co.uk>
     cgi que devuelve un grafico gif <nicolasr@arrakis.es>
     Finding the TITLE to a HTML page (psullivan)
     Re: How do I pass objects from Perl to Javascript? (Tushar Samant)
     Re: How to check files exists and if it does then? <shadowweb@worsdall.demon.co.uk>
     How to sort a set of records ? (Andreas Mischke)
     Re: How to sort a set of records ? <bowlin@sirius.com>
     How would you do this... <cboget@apdi.net>
     Installing Perl on Solaris - Problem <andrew@boothman.easynet.co.uk.NOSPAM>
     Mysterious FileHandle + fork() behavior; possible Perl  <achen@nssdc.gsfc.nasa.gov>
     Re: Newbie Question on Win32::Registry (John M. Dlugosz)
     Re: Newbie Question on Win32::Registry <glennb@matrixtech.com>
     Perl & MS-Word <ggressel@attmail.com>
     Re: Perl & MS-Word (Jan Dubois)
     perl on a mac? (Chris)
     Re: perl on a mac? (brian d foy)
     Re: perl XStut and XSUBS (Mike Stok)
     Powered by Servlets <kwilliams@qqworld.com>
     Re: Powered by Servlets (brian d foy)
     Re: server misconfig (Tad McClellan)
     Re: setuid question (Kerry Schwab)
     Re: setuid question <shadowweb@worsdall.demon.co.uk>
     Re: Substitute variables when reading file <#@qz.to>
     Re: Teaching programing (Josh Kortbein)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 27 Dec 97 00:54:01 GMT
From: psullivan@stlnet.com (psullivan)
Subject: Re: Automatically POST
Message-Id: <681jvo$t8g$1@news.stlnet.com>

>I was in need of whipping together some code in
>preferably perl which will basically assign values
>to variables and then automatically posting it to a
>DLL using <FORM METHOD "POST etc... etc.. to
>a specific ACTION without having the user manually
>press a submit button?

If you want someone to enter in information and have it sent in automatically, 
then you can't in perl. You need the user to actually press the submit button. 
Javascript/Java is probably your best bet, so take a look at that. If you want 
to have your own pre-set variables and have those sent in every time that 
someone hits your page, then you can use an image--reference the src as your 
cgi command (cgi-bin/foo.pl). Then again you would have to do this using GET, 
not POST, and it would only work if the person actually loaded the image 
(which only happens roughly 3/4 of the time). 

Patrick Sullivan


------------------------------

Date: Sat, 27 Dec 1997 01:21:32 +0000
From: Mark Worsdall <shadowweb@worsdall.demon.co.uk>
Subject: Re: Automatically POST
Message-Id: <dTpakmAcgFp0Ewzz@worsdall.demon.co.uk>

In article <comdog-ya02408000R2512971710270001@news.panix.com>, brian d
foy <comdog@computerdog.com> writes
>In article <Ix1$sFAo9no0Ew7d@worsdall.demon.co.uk>, Mark Worsdall <shadowweb@wor
>sdall.demon.co.uk> wrote:
>
>>In article <67t3e5$o7m$1@postern.mbnet.mb.ca>, Sunny Bhuller
>><psx001@autobahn.mb.ca> writes
>
[snip]
>>>a specific ACTION without having the user manually
>>>press a submit button?
>
>>You can't unless SSI or calling script as an image like a gif or jpg,
>>ofcourse this will not work if user has images turned off.
>
>"can't" is a rather strong word.  perhaps you meant that in the
>first person since it is not true in general. :)
>
True, I meant in the confines of perl (this group), I presume he asked
the same in javascript and got a different answer:-)
-- 
Mark Worsdall (Webmaster) - WEB site:- http://www.shadow.org.uk
Shadow:- webmaster@shadow.org.uk    
Home  :- shadowweb@worsdall.demon.co.uk
Any opinion given is my own personal belief...


------------------------------

Date: 27 Dec 97 01:16:39 GMT
From: "NICOLAS" <nicolasr@arrakis.es>
Subject: cgi que devuelve un grafico gif
Message-Id: <01bd1265$bd65bc80$3b4c05c3@xxx>

Agradecerma que alguien me aclarase las siguientes dudas ( a ser posible en
espaqol):

1-?Cual seria el codigo Perl de un CGI para que en la salida devuelva un
grafico Gif?

2- ?Como hacer que un CGI se autoejecute al cargar una pagina WEB? He
probado mediante los comandos SSI pero no acepta parametros. Por ejemplo:

<--#EXEC CGI="cgi-bin/archivo.cgi" -->     Funciona perfectamente, pero
<--#EXEC CGI="cgi-bin/archivo.cgi?parametro" --> No funciona
Mi pregunta es: como conseguir que se ejecute el CGI pasando el parametro?

3- ?Se puede desde un Javascript hacer una llamada a un CGI ?

Gracias por la ayuda y feliz navidad
Nicolas Rodrmguez
nicolasr@arrakis.es



------------------------------

Date: Sat, 27 Dec 97 00:59:57 GMT
From: psullivan@stlnet.com (psullivan)
Subject: Finding the TITLE to a HTML page
Message-Id: <681kas$t8g$2@news.stlnet.com>

How would I find the title from a html file? I tried...

open(HTML,$htmlfile);
@html = <HTML>;
close(HTML);

foreach $line (@html) {
        if ($line =~ /title/i) {
                $html_title = $line;
        }
}

and then I would take out the <title> and </title> tags, but it returns a 
blank $html_line variable. It looks fine to me, but is there another way of 
finding the title without having to resort to use calls? (i.e. the HTML:: 
ones, if such one exists). I would like to keep it as portable as possible. 
Thanks.

Patrick Sullivan


------------------------------

Date: 26 Dec 1997 17:22:27 -0600
From: scribble@tekka.wwa.com (Tushar Samant)
Subject: Re: How do I pass objects from Perl to Javascript?
Message-Id: <681e7j$8bi@tekka.wwa.com>

spectd@horus.sara.nl writes:
>I am creating nascent documents from a textbase created using CGI.pm
>and wish to transfer the data to Javascript objects in an efficient
>way. Does anyone have any suggestions?
>
>I am doing it in a very long-winded fashion at the moment by creating
>text strings in Perl which replace placeholders in my html document.
>This is fine for a limited application, but I would like to do it in a
>more general way by passing a CGI.pm object to the Javascript.

Maybe I don't understand the situation, but what's long-winded about
this? CGI.pm implements a Perl class, it IS Perl's job to present it
to someone else. Can Javascript manipulate a Perl object's storage
format better than Perl? I doubt it.

More generally, if you want to send an object over to N**tscape who
does his Javascript thing -- you will anyway have to represent it
textually somehow. Someone has to work for a functioning interchange;
so who should bear the bigger responsibility? I don't think there is
a dilemma there -- it's whoever has superior textual powers -- Perl,
hands down...

The mewling runt gets the bigger portion -- Javascript should be given
the easier job. Perl should go so far as to emit Javascript code ready
to be sourced by N**scape or whoever...

Maybe you are talking about creating more compact Javascript source --
you have to ask why that's preferable to just a sequence of assignments.



------------------------------

Date: Sat, 27 Dec 1997 01:19:18 +0000
From: Mark Worsdall <shadowweb@worsdall.demon.co.uk>
Subject: Re: How to check files exists and if it does then?
Message-Id: <izbVMiAWeFp0Ew3G@worsdall.demon.co.uk>

In article <3oIg6aAhFun0EwUX@worsdall.demon.co.uk>, Mark Worsdall
<shadowweb@worsdall.demon.co.uk> writes
>Hi, I need to be able to check if a file exists and if it does then
>append an 'a' unless that exists, in which case I will append a 'b'
>unless that exists etc etc etc.

I thankyou all for the help. I now have the script working fine.
-- 
Mark Worsdall (Webmaster) - WEB site:- http://www.shadow.org.uk
Shadow:- webmaster@shadow.org.uk    
Home  :- shadowweb@worsdall.demon.co.uk
Any opinion given is my own personal belief...


------------------------------

Date: Fri, 26 Dec 1997 20:09:10 GMT
From: mischke@neuss.netsurf.de (Andreas Mischke)
Subject: How to sort a set of records ?
Message-Id: <34a4017a.30425709@newsserv.neuss.netsurf.de>

Hi there,

I'm a bit confused about complex data structures in Perl 5.
I'm trying to sort a set of records by one field of the records:

$recordset = {
	string => $string,
	number => $number,
};
#fill recordset with test data
$recordset[0]->{string}="name1";$recordset[0]->{number}="4";
$recordset[1]->{string}="name2";$recordset[1]->{number}="2";
$recordset[2]->{string}="name3";$recordset[2]->{number}="1";
$recordset[3]->{string}="name4";$recordset[3]->{number}="5";

#sorting by field 'number'
@recordset = sort { $number{$a} <=> $number{$b} } @recordset;

#output of sorted recordset
for ($x=0;$x<=$#recordset;$x++){
	print "String$x: $recordset[$x]->{string}  ";
	print "Number$x: $recordset[$x]->{number}\n";
}

This doesn't work. How can this be done ?

Regards,

Andreas Mischke
email: mischke@neuss.netsurf.de


------------------------------

Date: Fri, 26 Dec 1997 12:54:28 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: mischke@neuss.netsurf.de
Subject: Re: How to sort a set of records ?
Message-Id: <34A41984.9F27118B@sirius.com>

Andreas Mischke wrote:
> 
> Hi there,
> 
> I'm a bit confused about complex data structures in Perl 5.
> I'm trying to sort a set of records by one field of the records:
> ...

Try this:

$recordset[0]->{string}="name1"; $recordset[0]->{number}="4";
$recordset[1]->{string}="name2"; $recordset[1]->{number}="2";
$recordset[2]->{string}="name3"; $recordset[2]->{number}="1";
$recordset[3]->{string}="name4"; $recordset[3]->{number}="5";

#sorting by field 'number'
@recordset = sort { $a->{number} <=> $b->{number} } @recordset;

#output of sorted recordset

foreach( @recordset) {
        print "String: $_->{string}\n";
        print "Number: $_->{number}\n\n";
}


HTH - Jim Bowlin


------------------------------

Date: Fri, 26 Dec 1997 17:09:49 -0500
From: "Sorrow" <cboget@apdi.net>
Subject: How would you do this...
Message-Id: <681a4r$1f5$1@news2.cais.com>

I'm running a perl script on a text file where each line
looks like this:

LINENUM=DATA1 <space> DATA2 <space> DATA3 <newline>

and what it is supposed to do is sort the information
in the original text file based on DATA2 and write it
out to a new, sorted, text file.
The following is what I came up with.
I'm very new to perl and I'm certain that I am doing
things the hard way.  By seeing how any of you would
have done this task, it lets me learn from my mistakes.

while(<>) {
  s/[^\.]+=//;
  @info = split( /\s/, $_ );
  if( $info[1] == 1 ) {
    push( @goodlist, join( ' ', $info[0], $info[1], $info[2] ));
  } else {
    push( @badlist, join( ' ', $info[0], $info[1], $info[2] ));
  }
}
open( OUTFILE, ">nbsort.txt" ) || die( $! );
foreach $infoline (@goodlist) {
  print OUTFILE "$infoline\n";
}
foreach $infoline (@badlist) {
  print OUTFILE "$infoline\n";
}
close( OUTFILE );


Thank you for your help and your insight.

Chris




------------------------------

Date: Thu, 25 Dec 1997 21:47:24 -0000
From: "Andrew Boothman" <andrew@boothman.easynet.co.uk.NOSPAM>
Subject: Installing Perl on Solaris - Problem
Message-Id: <681dfm$7up$1@apple.news.easynet.net>

Hi All!

A Solaris box is currently running perl 5.001, but the most recent version
of CGI.pm needs a newer version so I'm going to install whatever the newest
is (5.004_something-or-other).

The problem is that the Solaris machine is running some 'mission critical'
perl scripts that we can't afford to have any downtime on. So I would like
to install perl in a different place, and leave the current installation
totally untouched.

Is this possible?

Thanks 4 your help!

(I do have root access to the machine)

--
Andrew Boothman : andrew@boothman.easynet.co.uk.NOSPAM
http://easyweb.easynet.co.uk/~boothman/andrew/
http://www.linlithgowac.wlothian.sch.uk
(PGP Key Available)
Remove .NOSPAM from e-mail address to send





------------------------------

Date: Fri, 26 Dec 1997 16:23:17 -0500
From: Allen Chen <achen@nssdc.gsfc.nasa.gov>
Subject: Mysterious FileHandle + fork() behavior; possible Perl bug?
Message-Id: <Pine.OSF.3.95.971226153513.715B-100000@nssdc.gsfc.nasa.gov>

Hi everyone,

I am writing (what I thought would be) a simple Perl program that opens
and reads a list ($LIST) of files.  For each file in the list, a
subroutine is called to do some processing.  In order to speed this task
up, I start up MAXKIDS=20 children, one for each of the first 20 files in
the list.  As each child dies, another child is started up to process the
next file in the list.

The problem is that after I added the forking code, I noticed some very
strange behavior.  Sometimes (usually, but not always), the parent process
seems to get into some kind of loop.  Instead of exiting after it reaches
the end of the list, it starts reading the list from the beginning again.
It usually does not make it to the end of the list before it starts to
loop.

After I added some code to check the position of the FileHandle
(FileHandle::getpos), I'd see that the pointer would suddenly jump from a
normal value like "276" to the other extreme of long integers like
"4294959549".  Although the value was strange, it would still be in the
right position in the file (not exactly, but at least somewhere on the
right line).  However, it seemed that this 32-bit position would
eventually wrap back to 0, thus setting the file pointer back to the
beginning of the file!

Am I doing something wrong or could this possibly be a bug in Perl?
I am using Perl 5.004 on both Solaris 2.5.1 and Digital UNIX 4.0.

Here are the relevant parts of the code (simplified):

---------------------------------------------------------------------
 ...
my $LIST = new FileHandle $ARGV[0], "r";

# Start up MAXKIDS kids
for ($i=0;$i<$MAXKIDS;$i++) {
  &startKid;
}

# As each kid dies, start another one as long as there are files to check.
while (!(eof $LIST)) {
  wait();
  &startKid;
}

exit (0);     # all done

#######################################################################
# startKid
# This forks off a child process which checks the next file.
sub startKid {

  $hfile=<$LIST>;       # get the filename of next file to process
  chop $hfile;

  $pid=fork();
  if ($pid==0) {        # child
     checkFile($hfile); # this calls the sub that processes the file,
                        # but this seems irrelevant as the problem
                        # exists even when this is commented out.
     exit(0);
  } else {
    return $pid;        # parent
  }

} #sub startKid

 ...
---------------------------------------------------------------------

Thanks very much and happy holidays,
-Allen

Allen Chen   /   Systems Programmer    /   Hughes STX Corporation  ////
SSDOO Software, Systems / International Solar-Terrestrial Physics /////
e-mail: achen@nssdc.gsfc.nasa.gov   /     voice: (301) 286-7376  //////



------------------------------

Date: Fri, 26 Dec 1997 19:30:27 GMT
From: jdlugosz@airmail.net (John M. Dlugosz)
Subject: Re: Newbie Question on Win32::Registry
Message-Id: <02B85111DF8E9369.926424720446985A.FEACDC7E8E50130D@library-proxy.airnews.net>

On Fri, 26 Dec 1997 12:27:15 -0500, "Glenn Blinckmann, MCSE"
<glennb@matrixtech.com> wrote:

>I'm just starting to learn Perl and I am having problems with the following
>lines:
>
>TEST:;
>
>$Key = "SYSTEM\CurrentControlSet\Services\MSExchangeDS\Parameters";

Escape out the backslashes.
Here is a similar program I did to test out registry manipulation:

#!/usr/bin/perl -w

use Win32::Registry;
use strict ('vars', 'refs', 'subs');

my $handle;
$main::HKEY_LOCAL_MACHINE->Open("Software\\Inso\\Quick View
Plus\\CurrentVersion\\Plugins\\Acrobat",$handle) || die $!;
my @list;
$handle->GetKeys (\@list);
print ("keys are: @list\n");
my %vals;
$handle->GetValues (\%vals);
my ($key,$value);
while (($key,$value) = each %vals) {
   my ($name, $type, $val)=@$value;
   print "key=\"$key\",  type=\"$type\", value=\"$val\"\n";
   }


my @unused=   #kill warnings
   (\&Win32::Registry::pack, \&Win32::WinError::pack);





------------------------------

Date: Fri, 26 Dec 1997 15:37:19 -0500
From: "Glenn Blinckmann, MCSE" <glennb@matrixtech.com>
Subject: Re: Newbie Question on Win32::Registry
Message-Id: <6814i3$eav@ecuador.earthlink.net>

Thanks! I didn't even think about the backslashes being special characters.

--
Glenn Blinckmann, MCSE
Matrix Technologies, Inc.
mailto:glennb@matrixtech.com
http://www.matrixtech.com

John M. Dlugosz wrote in message
<02B85111DF8E9369.926424720446985A.FEACDC7E8E50130D@library-proxy.airnews.ne
t>...
On Fri, 26 Dec 1997 12:27:15 -0500, "Glenn Blinckmann, MCSE"
<glennb@matrixtech.com> wrote:

>I'm just starting to learn Perl and I am having problems with the following
>lines:
>
>TEST:;
>
>$Key = "SYSTEM\CurrentControlSet\Services\MSExchangeDS\Parameters";

Escape out the backslashes.
Here is a similar program I did to test out registry manipulation:

#!/usr/bin/perl -w

use Win32::Registry;
use strict ('vars', 'refs', 'subs');

my $handle;
$main::HKEY_LOCAL_MACHINE->Open("Software\\Inso\\Quick View
Plus\\CurrentVersion\\Plugins\\Acrobat",$handle) || die $!;
my @list;
$handle->GetKeys (\@list);
print ("keys are: @list\n");
my %vals;
$handle->GetValues (\%vals);
my ($key,$value);
while (($key,$value) = each %vals) {
   my ($name, $type, $val)=@$value;
   print "key=\"$key\",  type=\"$type\", value=\"$val\"\n";
   }


my @unused=   #kill warnings
   (\&Win32::Registry::pack, \&Win32::WinError::pack);






------------------------------

Date: 26 Dec 1997 21:09:09 GMT
From: "Gary Gressel" <ggressel@attmail.com>
Subject: Perl & MS-Word
Message-Id: <01bd1242$3496c700$3610c287@mo3980_ws16054>

I'm using Perl to create documents in Microsoft Word.  I've been using Perl
to program Excel & Word for over a year so I'm pretty confident I have the
VisualBasic->Perl translation down.  All is working well except for two
annoying problems.  Thought perhaps someone else has ran into the same
things in either Perl or VB.

The most annoying is that as I add text (doesn't matter if it is character
at a time or a string of text) using something like:
  $out->TypeText("The text to add");    # Out is equiv to
Application->Selection
I get the text OK on Word but I also get a weird character appended to my
text.  It prints as a small box in Word.  If I turn on hidden characters
the box changes to a small "y" character with two dots above it.  Does
anyone know how to get rid of this add-on?  The only way I've figured out
how to get rid of it is to do a:
  $out->MoveLeft(1,1,1);
  $out->TypeText(" ");
after each output.  Certainly that isn't pretty and it really slows things
down--plus it doesn't do me any good if it is the last character of a
document as the last statement, as you might expect, creates another box by
itself also.  I've tried adding some special characters after my text (like
the good ole' \0 for C language) but nothing seems to affect this appended
character.

The second problem doesn't happen all of the time--so I imagine once I can
replicate it regularly I'll fix the problem.  But until then... I'm having
problems creating (reliably) hidden text.  I issue a
  $out->Font->{'Hidden'} = 1;
followed by my outputted text and then finish with
  $out->Font->{'Hidden'} = 0;

Now, that type of setup works great (reliably) for Bolding and any other
Font attribute, except Hidden.  Has anyone had difficulties with the Hidden
attribute before?  It's a great thing to use for debugging since I can hide
lots of  information inside the document.  That is, until it shows up as
not hidden!

Thanks in advance!
Gary Gressel
ggressel@att.com


------------------------------

Date: Fri, 26 Dec 1997 23:54:09 +0100
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Perl & MS-Word
Message-Id: <34a534d8.46759646@news2.ibm.net>

[mailed and posted]

"Gary Gressel" <ggressel@attmail.com> wrote:

>The most annoying is that as I add text (doesn't matter if it is character
>at a time or a string of text) using something like:
>  $out->TypeText("The text to add");    # Out is equiv to
>Application->Selection
>I get the text OK on Word but I also get a weird character appended to my
>text.  It prints as a small box in Word.  If I turn on hidden characters
>the box changes to a small "y" character with two dots above it.  Does
>anyone know how to get rid of this add-on?  The only way I've figured out
>how to get rid of it is to do a:
>  $out->MoveLeft(1,1,1);
>  $out->TypeText(" ");
>after each output.  Certainly that isn't pretty and it really slows things
>down--plus it doesn't do me any good if it is the last character of a
>document as the last statement, as you might expect, creates another box by
>itself also.  I've tried adding some special characters after my text (like
>the good ole' \0 for C language) but nothing seems to affect this appended
>character.
>
>The second problem doesn't happen all of the time--so I imagine once I can
>replicate it regularly I'll fix the problem.  But until then... I'm having
>problems creating (reliably) hidden text.  I issue a
>  $out->Font->{'Hidden'} = 1;
>followed by my outputted text and then finish with
>  $out->Font->{'Hidden'} = 0;

I cannot reproduce your problems. The following code works for me as
expected with Perl 5.004_04, OLE from libwin32-0.09 and Word 8 from
Office 97.

-Jan


use strict;
use Win32::OLE;
 
my $word = Win32::OLE->new('Word.Application', 'Quit') or die;
$word->{Visible} = 1;
$word->Documents->Add;
my $out = $word->Application->Selection;

$out->TypeText("Line 1\nLine 2\n");
$out->Font->{Hidden} = 1;
$out->TypeText("Line 3\nLine 4\n");
$out->Font->{Hidden} = 0;
$out->TypeText("Line 5\nLine 6\n");



------------------------------

Date: Fri, 26 Dec 1997 15:03:57 -0800
From: goatholl@sonic.net (Chris)
Subject: perl on a mac?
Message-Id: <goatholl-2612971503570001@d69.pm9.sonic.net>

How do I get ahold of a program to run and compile perl on a macintosh?
(performa 630cd)
I want to learn how to use perl to write simple cgi scripts to use with
web pages, where do I start???
thanks, and happy holidays  - Karen


------------------------------

Date: Fri, 26 Dec 1997 20:00:13 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl on a mac?
Message-Id: <comdog-2612972000130001@news.panix.com>

In article <goatholl-2612971503570001@d69.pm9.sonic.net>, goatholl@sonic.net (Chris) wrote:

> How do I get ahold of a program to run and compile perl on a macintosh?
> (performa 630cd)
> I want to learn how to use perl to write simple cgi scripts to use with
> web pages, where do I start???


you want MacPerl, available from CPAN.

[1]
Comprehensive Perl Archive Network
available through <URL:http://www.perl.com>

-- 
brian d foy                                 <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm


------------------------------

Date: 26 Dec 1997 20:34:18 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: perl XStut and XSUBS
Message-Id: <681luq$vk$1@stok.co.uk>

In article <883134988.349634564@dejanews.com>,  <tommiy@pronet.net.au> wrote:
>Can someone please point me in the direction of a XS tutorial that
>actually works? If I follow whats in the man pages it doesn't function at
>all. In fact it doesn't suceed in even doing the first example and since
>the rest are built on it I can't get past step 1. If I do EXACTLY what is
>in the man perlxstut pages I get the following when running make on
>Mytest.

[...]

>Can anyone help out here? Tell me whats wrong with the man page, or how
>to fix what is happening? This is my first foray into perl XS and it
>isn't going anywhere!

You might want to get and build a more recent perl (e.g. 5.004_04) and
install it in /usr/local/bin etc. so that you still have the original
distribution to use too.  I have just cut & pasted the first example from
the perlxstut man page and it seems to work fine on my system (RH 5.0)

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


------------------------------

Date: Fri, 26 Dec 1997 15:46:30 -0800
From: Ken Williams <kwilliams@qqworld.com>
Subject: Powered by Servlets
Message-Id: <34A441D6.73AE@qqworld.com>

Entire site beautifully powered by Java Servlets,
http://www.qqworld.com


------------------------------

Date: Fri, 26 Dec 1997 19:58:29 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Powered by Servlets
Message-Id: <comdog-2612971958290001@news.panix.com>

In article <34A441D6.73AE@qqworld.com>, kwilliams@qqworld.com wrote:

> Entire site beautifully powered by Java Servlets,
> http://www.qqworld.com

how about a site powered by mod_perl?
http://www.dejanews.com

-- 
brian d foy                                 <http://computerdog.com>
would feel guilty about using the products of a company that makes
ethnic slurs at trade shows.


------------------------------

Date: Fri, 26 Dec 1997 13:16:47 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: server misconfig
Message-Id: <vqv086.532.ln@localhost>

Barbara Riviezzo (sflower@cyberportal.net) wrote:
: Hello!  I am trying to get a PERL script to run, and it works fine on
: the server, at the command prompt.  However, when I try to run it
: through a web browser, it tells me:

: Internal Server Error


You are much more likely to get an answer to a server question
in a server newsgroup.

Try one of:

   comp.infosystems.www.servers.mac
   comp.infosystems.www.servers.misc
   comp.infosystems.www.servers.ms-windows
   comp.infosystems.www.servers.unix



You may also get some help from seeing the Perl FAQ, part 9 
(even though it is not a Perl question, it is a CGI question):

   "My CGI script runs from the command line but not the browser.  
    Can you help me fix it?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 26 Dec 1997 18:34:48 -0700
From: kschwab@nyx.net (Kerry Schwab)
Subject: Re: setuid question
Message-Id: <681lvo$m96$1@nyx10.nyx.net>

In article <34A37B21.62C3C0CA@isty-info.uvsq.fr>,
Nicolas Pomarede  <pomarede@isty-info.uvsq.fr> wrote:
>Hello,
>I have a script which is used to connect to some distant
>machine using a modem. This script needs to be run as root,
>so when you login root and run it, it works perfectly.
>But I'd like to make it easier to use for anyone, so I put
>a setuid bit. But now, it complains when started :
>
>Insecure dependency in `` while running setuid at
>/etc/ppp/nconnect.pl.ttyC1 line 206.
>

This means that "tainted" data is being passed to the shell.
In other words, you are allowing arbitrary untrusted folks
to perhaps run shell commands as the setuid user.

>
>where line 206 looks like :
>
>$res = `nslookup $Dest`;
>
>I tried to set $PATH correctly, but it didn't work.
>note that $Dest come from $ARGV[ 1 ], so perhaps it's why it
>doesn't work ?
>

Right, $Dest is derived from $ARGV (which is user supplied).
This makes it "tainted". You still need to have a secure PATH,
but this isn't your immediate problem.


>I didn't find any real solution in the perl security man page,
>so if you have any clue, please send it to me.
>

I'm quite sure the perlsec manpage does address this.
There's three things you need to do:

1) Outside of perls complaints, for security reasons, you need
    find a way to get shell metachars and other muck out of
    $Dest.  This *is* in the perlsec manpage.

2) Figure out how to make $Dest untainted, so that perl will let
   you use it.  This is also in the perlsec manpage.

3) Explore safer methods of passing your args.  Look for the
   following sentence in the perlsec manpage:

   " Here's a way to do backticks reasonably safely. "

You may also want to see if setuid is the only way to go here.
Sometimes there's a better solution. At least not running setuid
root. Perhaps the modems could be owned by group "uucp" and set
group readable/writable ?  

--
Kerry

>Thanks in advance
>
>
>----
>
>Nicolas Pomare
>pomarede@isty-info.uvsq.fr




------------------------------

Date: Sat, 27 Dec 1997 01:42:47 +0000
From: Mark Worsdall <shadowweb@worsdall.demon.co.uk>
Subject: Re: setuid question
Message-Id: <LjLfIuAX0Fp0Ewzi@worsdall.demon.co.uk>

>   * when calling the shell, you should probably use the full path
>   to executables.  imagine someone munging the PATH and getting some
>   other nslookup to run!  i always set $ENV{'PATH'} = '' in any setuid
>   scripts.
>
Do you always set $ENV{'PATH'} = '' before you call anything, ie.
external program or r/w datafile, or do you just do this once in the
script?
-- 
Mark Worsdall (Webmaster) - WEB site:- http://www.shadow.org.uk
Shadow:- webmaster@shadow.org.uk    
Home  :- shadowweb@worsdall.demon.co.uk
Any opinion given is my own personal belief...


------------------------------

Date: 26 Dec 1997 20:32:45 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: Substitute variables when reading file
Message-Id: <qz$9712261442@qz.little-neck.ny.us>
Keywords: from just another new york perl hacker

brian d foy <comdog@computerdog.com> wrote:
> In article <883022885.754122753@dejanews.com>, neal@valinet.com wrote:
> >I have a Perl program which opens up a text file, and in this text file
> >there are $variables.  How can I get Perl to map these
> >$variables without explicity mapping each one.
> sounds like you want eval().

Maybe not. Does he want all of the \things to be interpolated too?

>    #!/usr/bin/perl -w
>    use strict;
>    
>    my $city = q|new york|; #it's not just mine though
>    my $text = q|just another $city perl hacker|;
>    
>    #see the perlfunc man page or the blue camel for details
>    eval( "\$text = qq|$text|" );

As someone else pointed out, if $text has a | in it, strange things
will happen.

Here's what I use in one of my scripts:

* All variables are surrounded by "%%" at the start and end, and
  do not have % in the name.
* While reading the lines in, I do this:
	s/%%([^%]+)%%/${$1}/g;

For something more complicated you could use:

	#!/usr/bin/perl 

	$ny="pm";
	@p=( js => "just some" );
	%m=( ph => "perl hackers"); 

	while(<DATA>) {
	    s/%%(\w+)([^%]*)%%/qq,"\$$1$2",/eeg;
	    print;
	}

	__DATA__
	This is $ny=%%ny%%.
	 $P = %%p[1]%% &&
	 $M = %%m{ph}%% =>
	    %%p[1]%% new york %%m{ph}%%

And if you insist on using $ to indicate variables, maybe you'd
like something such as:

	s/\${([^}]+)}|\$(\w+)/defined($1)?"\$$1":"\$$2"/eeg

Which will even allow you to put {} around variable names.

Elijah
------
eeg: not just for brain surgeons


------------------------------

Date: 26 Dec 1997 20:38:47 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Teaching programing
Message-Id: <6814kn$8kb$1@news.iastate.edu>

Boring personal history:

I started screwing around with Applesoft BASIC on an Apple ][+ somewhere
around fourth grade - mostly learning from Apple's excellent programming
tutorials, documentation, etc.

Around the same time, I also learned a bit about Logo at school, though
we were more turtle-graphics oriented than anything else.

I eventually started being ambitious and writing silly text-adventure
programs, etc., in BASIC - in retrospect, I'd have to say that my code
was horrible, by my now-kind-of-high standards.

I did more BASIC programming up until 9th grade, along the way writing
much more complicated stuff, eventually involving some strange
graphics package (which I can't remember the name of) that let you
perform animation. I never did finish that game. :)

I started in on the "real" programming my freshman year of high school,
learning Pascal on Apple IIgses running, I think, LightPascal or something
like that. We used Dale and Weems' _Pascal_ as the text, and I think
it was an excellent text - easy to read, easy to understand, etc. We moved
up, in a matter of months, to Think Pascal on our school's first, brand-new
Macs, four IIsis.

I cannot emphasize enough how useful it was to learn Pascal - that,
plus the fine material in Dale and Weems' text, got me actually writing
well-structured, well-scoped code, even if I did occasionally abuse
the ability to have long variable names (even, in one instance, something
like VariableThatIsUsedToCheckWhetherTheUserWantsToGoOnOrNot - a stupid
Boolean!). The things others in this newsgroup have said about the 
effectiveness of Pascal as a teaching languages are EXTREMELY valid.

That same year, we also started learning FORTRAN (77), which I do not 
recommend to anyone. For all the crap BASIC takes, it doesn't seem to 
generate as much bad code as FORTRAN. My university still actually offers 
two versions of the intro engineering course, one using C and one using 
FORTRAN!!!

I got into C (is that anything like getting into B & D?) a while later, 
while still in high school, and haven't used Pascal a whole lot since then.
I find C far more obfuscated than Pascal - unneccessarily so. I like, 
though, that it puts me closer to the machine level - I had a few 
headaches trying to learn about pointers and bit-level stuff, etc., in 
Pascal. I still don't like C a whole lot, but I use it for things like
numerical analysis projects, etc., because it works fairly well.

Sure seems stupid to have to use 50 standard libraries to do anything 
useful, though.

I was fortunate enough to take my university's intro-level comp sci. 
class for majors (though I'm not one) when they still taught it in 
Scheme, a few years back. I already knew and understood every concept 
they intended to teach us, so it was really sort of a fun little exercise 
in syntax-learning - and Scheme doesn't have much of it!

I think Scheme functioned beautifully as a teaching language, and I found 
it interesting to play with. It seemed as if it got in the way, 
syntax-wise, even less than Pascal did when being used to teach 
programming concepts. True, Pascal complained a lot, but fixing your 
syntactical errors was a fairly mechanical process.

Unfortunately, I don't know if the class as a whole (or on the average, 
whatever) ever figured out why they were learning Scheme instead of 
Visual Basic or Java or something trendy like that. That's a shame, 
because everything they REALLY needed to learn was there.

Sometime after picking up C, but before Perl, I also started exploring 
C++. Without being ultimately qualified to do so, I say that it's an 
abomination - too difficult to use, too difficult to understand, etc.
And this isn't coming from someone with no programming experience or
with a lack of facility for abstract reasoning - I understand, in
large part, the concepts associated with OO programming. But why
does it have to be such a bitch to implement them in C++? Sure, if
I sat down and woodshedded, I could do it, but why bother if I don't
need it to make money?

Regardless, I'm currently working on a small-to-middlin' C++ application 
for the Mac with a comp. sci. major friend of mine - I'm handling more of 
the mathematical side (fractals and arbitrary-length numbers, eh?). Maybe 
that D & S I mentioned earlier really applies here! I guess part of the 
reason that I agreed to work on it is that it will be, tangentially, a 
way to pick up some more C++. But I'm still not liking it. :)

I started with Perl about a year and a half ago upon starting a job with 
a local ISP. Perl rocks. As others have said, it lets me do what I want 
without getting in the way (very much). Its syntax is sometimes confusing 
but usually interesting and fun to work with. And I'd never been able to 
handle text so well since learning Perl. Now, in addition to work uses 
(munging text meant for web pages, writing CGIs, etc.), I use it for 
little projects wherever I can, like forming a concordance of words for 
titles in my CD database, automatically generating a web page for my CDs, 
etc.

There's also been some dabbling with Applescript and Frontier in my past, 
as well as FileMaker Pro's obtusely designed scripting language and SQL, 
but nothing really substantial.

So, what do I recommend? Pascal, or maybe Scheme, then some straight C. 
Perl is an excellent language, but it is weird, so I guess it depends on 
your students/kids whether or not you want to put Perl before C, run it 
concurrently, or after.

Josh

--
____________________________________________________________________________
Mr. Sparkle:    Get out of my way, all of you. This is no place for loafers.
                Join me or die. Can you do any less?
Japanese women: What a brave corporate logo!
                I accept the challenge of "Mr. Sparkle."



------------------------------

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 1538
**************************************

home help back first fref pref prev next nref lref last post