[6831] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 456 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 9 11:17:19 1997

Date: Fri, 9 May 97 08:00:24 -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           Fri, 9 May 1997     Volume: 8 Number: 456

Today's topics:
     [Q] program execution (Carl Joel Kuzmich)
     Re: [Q] program execution <a.aitken@unl.ac.uk>
     Re: [Q] program execution (Tad McClellan)
     Re: [Q] Which Perl book next (Magnus Bodin)
     DB access with Perl (Paul Vermette)
     Re: DB access with Perl <a.aitken@unl.ac.uk>
     Re: Drawing a graph? (Michael Schuerig)
     Re: Drawing a graph? (Nathan V. Patwardhan)
     FTP using LWP <schajer@dircon.co.uk>
     Re: FTP using LWP (Nathan V. Patwardhan)
     Hide my code? <"atlantide@wanadoo.fr"@wanadoo.fr>
     Re: Hide my code? <santiago@gambito.com>
     Re: Hide my code? (Nathan V. Patwardhan)
     Re: How can I email with Perl on NT using Blat <allenjs@nic.techops.lmco.com>
     Re: htpasswd & PERL (Magnus Bodin)
     Integration between Perl and Java <danielem@iol.it>
     Re: join and references <fawcett@nynexst.com>
     Re: MacPerl question (Chris Nandor)
     Minimum perl installation (John Sheehy)
     Re: New Perl programmer in need of tutorials (Kyzer)
     Re: possible typo warning <eglamkowski@hotmail.com>
     Re: quoting a separator for split() <allenjs@nic.techops.lmco.com>
     Re: Regular Expression/Associative Array Bug??? (David Alan Black)
     Re: Regular Expression/Associative Array Bug??? (Tad McClellan)
     Re: scalar holds compiled code <a.aitken@unl.ac.uk>
     Re: Script runs fine from shell, but browser doesn't re (Kyzer)
     Re: Sending e-mail from within a perl script - help (Clay Irving)
     Re: Something I'm missing <abennett@stonehill.edu>
     SUID on Webservers? <jm+@andrew.cmu.edu>
     Re: system () won't execute the called program. <merlyn@stonehenge.com>
     Re: url detection in a string <a.aitken@unl.ac.uk>
     Re: Win32 Perl <wade@demographics.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 9 May 1997 12:11:00 GMT
From: cjk@omedsrvb.omed.pitt.edu (Carl Joel Kuzmich)
Subject: [Q] program execution
Message-Id: <5kv48k$f6j@usenet.srv.cis.pitt.edu>


Hi

I have starting learing perl and confused with a little program I wrote.
I bought the O'Reily mouse book and type in an example pgm, code
snippet:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<HTML> \n";
print "<HEAD> \n";
print "<TITLE> "xxxxxxxxxxxxxxxx",  </TITLE> \n";
print </HEAD> \n";
print "<BODY> \n";
print "Server software:  ", $ENV{'SERVER_SOFTWARE'}, "<BR>", "\n";
print "</BODY> \n";
print "</HTML> \n";
exit (0);

The above gives me a server error???? However, when I modify the code to
the following:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "<TITLE>A test program</TITLE>";
print "Server software:    ", $ENV{'SERVER_SOFTWARE'}, "<BR>";
exit (0);

It works???????? Can anyone tell me why????? I would really love to have
the difference pointed out to me. It seems as though if the first
example in from the O'Reily book that it should work???? And and all
comments will be greatly appreciated.


-- 
Carl Joel Kuzmich 412.648.1099 | Love is a better teacher than duty |
University of Pittsburgh       |                  - Albert Einstein |
Office of Medical Education
Pittsburgh, PA  15261


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

Date: Fri, 09 May 1997 13:21:59 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: [Q] program execution
Message-Id: <337316E7.7E35@unl.ac.uk>

Carl Joel Kuzmich wrote:
> 
> Hi
> 
> I have starting learing perl and confused with a little program I wrote.
> I bought the O'Reily mouse book and type in an example pgm, code
> snippet:
> 
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "<HTML> \n";
> print "<HEAD> \n";
> print "<TITLE> "xxxxxxxxxxxxxxxx",  </TITLE> \n";

This is wrong.  You are treating this as a list *and* a single string. 
It should be:

print "<title>", "xxxxxxx", "</TITLE>", "\n";		# as a list
print "<title>xxx...</title>\n";			# as a single string

If you want to print quotes inside strings you must escape them thus:

print "<a href=\"http://www.unl.ac.uk/alastair/\">alastair</a>\n";

> print </HEAD> \n";
> print "<BODY> \n";
> print "Server software:  ", $ENV{'SERVER_SOFTWARE'}, "<BR>", "\n";

That looks like a better list - plain strings are easier to handle and
shorter:

print "Server software:  $ENV{'SERVER_SOFTWARE'}<BR>\n";

Perl will interpolate the scalar value automatically in double quoted
strings but not single quoted.

Alastair.


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

Date: Fri, 9 May 1997 07:48:49 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: [Q] program execution
Message-Id: <hf6vk5.6j.ln@localhost>

Alastair Aitken (a.aitken@unl.ac.uk) wrote:
: Carl Joel Kuzmich wrote:
: > 
: > I have starting learing perl and confused with a little program I wrote.
: > I bought the O'Reily mouse book and type in an example pgm, code
: > snippet:
: > 
: > #!/usr/bin/perl
: > print "Content-type: text/html\n\n";
: > print "<HTML> \n";
: > print "<HEAD> \n";
: > print "<TITLE> "xxxxxxxxxxxxxxxx",  </TITLE> \n";

: This is wrong.  You are treating this as a list *and* a single string. 
: It should be:

: print "<title>", "xxxxxxx", "</TITLE>", "\n";		# as a list
: print "<title>xxx...</title>\n";			# as a single string

: If you want to print quotes inside strings you must escape them thus:
                                                 ^^^^^^^^^^^
: print "<a href=\"http://www.unl.ac.uk/alastair/\">alastair</a>\n";


You *can* (not must) escape them that way.

You must disambiguate them, but, as usual, TMTOWTDI:

1)
print qq(<a href="http://www.unl.ac.uk/alastair/">alastair</a>\n);

2)
print '<a href="http://www.unl.ac.uk/alastair/">alastair</a>', "\n";

3)
print<<ENDHTML;
<a href="http://www.unl.ac.uk/alastair/">alastair</a>
ENDHTML


[ snip ]


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Fri, 09 May 1997 13:28:06 GMT
From: Magnus.Bodin@tychonides.se (Magnus Bodin)
Subject: Re: [Q] Which Perl book next
Message-Id: <337525e0.160936163@news1.telenordia.se>

gnat@frii.com wrote:

>My favourite is Tom Boutell's "CGI Programming in C & Perl"
>(http://www.boutell.com/cgibook/) which is well written by a very
>smart guy.  The FAQ has a section on perl books, and mentions some
>perl/cgi books:
>  http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq2/Perl_Boks.html
>

yes. And if you really want to learn perl as well as cgi, then go for
the llama book. It's a lightweight introduction before having the
camel as reference. The llama does not explore much in objects,
packages and hairy stuff.


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

Date: 9 May 1997 11:40:49 GMT
From: prv@beaver.formalsys.ca (Paul Vermette)
Subject: DB access with Perl
Message-Id: <5kv2g1$9pc$1@garnet.nbnet.nb.ca>

I am looking for any product that will allow me
to connect to any database using perl

I am trying to construct a list of them so that
I can evaluate them

Please don't bother mentioning dbPerl or DBI I 
already know about those <g>




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

Date: Fri, 09 May 1997 13:11:44 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: DB access with Perl
Message-Id: <33731480.7AD8@unl.ac.uk>

Paul Vermette wrote:
> 
> I am looking for any product that will allow me
> to connect to any database using perl
> 
> I am trying to construct a list of them so that
> I can evaluate them
> 
> Please don't bother mentioning dbPerl or DBI I
> already know about those <g>

sybperl		# connecting to sybase, non-sybase product
web.sql		# connection to sybase, sybase product
oraperl		# connecting to oracle, non-oracle product

I think there is also a perl interface to msql (miniSQL server) but
don't quote me on that.

Alastair.


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

Date: Fri, 9 May 1997 15:09:45 +0100
From: uzs90z@uni-bonn.de (Michael Schuerig)
Subject: Re: Drawing a graph?
Message-Id: <1997050915094542258@rhrz-ts2-p2.rhrz.uni-bonn.de>

Nathan V. Patwardhan <nvp@shore.net> wrote:

> Michael Schuerig (uzs90z@uni-bonn.de) wrote:
> 
> : I'm looking for a module that draws a graph for me. I only want to input
> : nodes (with labels) and edges (with labels) and have the module do
> : everything else. Is there such a thing?
> 
> Yes.  Check CPAN for the Graph modules - I think there's one called GIFGraph
> which might do what you want.

That's not what I had meant. I want to draw graphs, not charts. And I
don't even want to draw myself, I want the module to do the hard layout
work.

Michael

---
Michael Schuerig           Nothing helps a bad mood like spreading it.
mailto:uzs90z@uni-bonn.de                                     -Calvin
http://www.uni-bonn.de/~uzs90z/


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

Date: 9 May 1997 13:58:06 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Drawing a graph?
Message-Id: <5kvahe$qif@fridge-nf0.shore.net>

Michael Schuerig (uzs90z@uni-bonn.de) wrote:

: That's not what I had meant. I want to draw graphs, not charts. And I
: don't even want to draw myself, I want the module to do the hard layout
: work.

Oh, then I think you're looking for a drafting firm, which should be 
listed in your local phone directory!  Hope this helps!  :-)

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Tue, 06 May 1997 17:27:20 +0000
From: Alex Schajer <schajer@dircon.co.uk>
Subject: FTP using LWP
Message-Id: <336F69F8.167E@dircon.co.uk>

I know it's a bit crude but at the moment I'm using LWP::Simple and
getstore to get things from one machine to another. It is good in asmuch
as it returns RC (return code) but fails as it is not really ftp - it
takes things from the document path but files elsewhere cannot be
retrieved.

I read somewhere about net::ftp. Is this worthwhile? The most important
thing is verification of transfer. And is there good documentation
available!!

Thanks for your help,

Alex - please reply directly as my newsreader is dodgy.


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

Date: 9 May 1997 13:55:38 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: FTP using LWP
Message-Id: <5kvacq$qif@fridge-nf0.shore.net>

Alex Schajer (schajer@dircon.co.uk) wrote:

: I read somewhere about net::ftp. Is this worthwhile? The most important
: thing is verification of transfer. And is there good documentation
: available!!

Yep - libnet is excellent.  Net::FTP is well-documented internally,
and the functions are well-defined.  Since you're running LWP, you
might have already installed libnet.

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Fri, 09 May 1997 12:08:53 +0200
From: ATLANTIDE <"atlantide@wanadoo.fr"@wanadoo.fr>
Subject: Hide my code?
Message-Id: <5kutcn$km1@hetre.wanadoo.fr>

Hello,

How can I hide my code for a Perl program. I'd like to write Perl
programs but i don't someone to change them. Like in C, an Exe program
is not "uptatable" directly. Has Perl this utility ?

Thanks for your answer

Regards

PC
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=
ATLANTIDE                                            ATLANTIDE Rennes
Technoptle Brest Iroise                    Technopole Rennes Atalante
CP n02                               80, Avenue des Buttes de Coesmes
29608 BREST Cedex                                        35700 Rennes
FRANCE                                                         FRANCE
Tel.: 33 (0)2 98.05.43.21                   Tel.: 33 (0)2 99.84.15.84
Fax.: 33 (0)2 98.05.20.34       	    Fax.: 33 (0)2 99.84.15.85
e-mail: atlantide@wanadoo.fr                    e-mail: atl35@iway.fr


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

Date: 9 May 1997 11:27:58 GMT
From: "Santiago Alvarez Rojo" <santiago@gambito.com>
Subject: Re: Hide my code?
Message-Id: <01bc5c6b$fe84bfa0$7131a8c0@sg059pcs>

Are you asking for a perl compiler?

+------------------------------------------------------------------+
| Santiago Alvarez Rojo                                            |
|    santiago@gambito.com                                          |
|    http://www.gambito.com/santiago                               |
|                                                                  |
| PGP public-key: http://gambito.com/santiago/pgp.txt              |
|   fingerprint = D2 BB 9F DD 48 84 9F 5B  80 41 50 D2 28 12 1C 59 |
+------------------------------------------------------------------+

ATLANTIDE <"atlantide@wanadoo.fr"@wanadoo.fr> escribis en artmculo
<5kutcn$km1@hetre.wanadoo.fr>...
> Hello,
> 
> How can I hide my code for a Perl program. I'd like to write Perl
> programs but i don't someone to change them. Like in C, an Exe program
> is not "uptatable" directly. Has Perl this utility ?
> 
> Thanks for your answer
> 
> Regards
> 
> PC
> -- 
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=
> ATLANTIDE                                            ATLANTIDE Rennes
> Technoptle Brest Iroise                    Technopole Rennes Atalante
> CP n02                               80, Avenue des Buttes de Coesmes
> 29608 BREST Cedex                                        35700 Rennes
> FRANCE                                                         FRANCE
> Tel.: 33 (0)2 98.05.43.21                   Tel.: 33 (0)2 99.84.15.84
> Fax.: 33 (0)2 98.05.20.34       	    Fax.: 33 (0)2 99.84.15.85
> e-mail: atlantide@wanadoo.fr                    e-mail: atl35@iway.fr
> 


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

Date: 9 May 1997 14:00:55 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Hide my code?
Message-Id: <5kvamn$qif@fridge-nf0.shore.net>

ATLANTIDE ("atlantide@wanadoo.fr"@wanadoo.fr) wrote:

: How can I hide my code for a Perl program. I'd like to write Perl
: programs but i don't someone to change them. Like in C, an Exe program
: is not "uptatable" directly. Has Perl this utility ?

Yes and no.  There's a compiler in Alpha, available from CPAN - you'll
have to read the documentation to see if it does what you want.

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Thu, 08 May 1997 17:59:52 -0700
From: Jay Allen <allenjs@nic.techops.lmco.com>
Subject: Re: How can I email with Perl on NT using Blat
Message-Id: <33727708.4174@nic.techops.lmco.com>

:Two Points,
: 1. Make sure the /temp directory exists.

	It does.

: 2. I either use \\ or / but not // as windows directory spaces.

	I'm using \\...

:  my $tempfile =  '/temp/' . time . "$$" . '.tmp';

:  if ( open( TEMPFILE, ">$tempfile" ) ) {
:      print TEMPFILE $output; # or whatever you want to mail
:      close( TEMPFILE );
:      system "d:\\directory\\blat.exe $tempfile -t $toaddress -q"; #
: email
:      unlink $tempfile;
:  }
:  else {
:      die "cannot create temporary file ($!)";
:  }

	Tried this...

: Make sure that the web server user ID is allowed to run
: BLAT, and to write the temporary file(s) to whatever
: location you decide to use.

	It can.

	So why won't it work!!! :)  Here's the deal.  Before I used the -q
flag, I redirected the output of blat to a file.  The web browser is
waiting for reply from host, and I think blat is trying to work. 
However, in that output file, there isn't the usual "Sending to blah
blah, Sender is set at blah blah blah..." (without the -q flag mind
you...).  There is nothing, yet the file is created.

	Oh, one more thing, I tried the exact same call to blat on the command
line, and it works...  Yet, it hangs forever on the web server....

	Please let me know if you all will take a look at my script.  I'll send
it along if you say so.  Thanks!

  -j-
---------
Jay Allen
allenjs@nic.techops.lmco.com
ICYRA-Internet Coordinator
Lockheed-Martin - Web Page Lead
The Maxim Group - Sr. Programmer/Analyst
(w) (310) 727-1086
(h) (562) 433-7727


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

Date: Fri, 09 May 1997 12:59:14 GMT
From: Magnus.Bodin@tychonides.se (Magnus Bodin)
Subject: Re: htpasswd & PERL
Message-Id: <33730f68.155184563@news1.telenordia.se>


>here is the step by step (sorry that i can't provide source):
>
>* get a user name and a password
>
>* ensure that the user name is unique (for new ones - a bit different
>if you want to change an existing password but i won't go into that)
>
>* choose a salt and crypt() the password with it.
>
>* concatenate the user name and the encrypted password with a colon.
>
>* append that to the htpasswd file.
>
>-- 
>brian d foy                              <URL:http://computerdog.com>                       
>unsolicited commercial email is not appreciated

And here's some source sample:

# usage: &append_pass(<filename>,<user>,<pass>);
#
sub append_pass {
	($file,$user,$pwd)=@_;

	$salt=&saltchar+&saltchar;
  $cryptpwd=crypt($pwd,$salt);

	open(FILE,">>$file");
	print FILE "$user:$cryptpwd\n";
	close(FILE);
}	

# returns a "random" saltchar
sub saltchar {
	# salt should consists of [A-Za-z0-9./] 
  # saltchar is by the way kinda joke for swedes: 
  # salt tumblers is called saltkar..

	$rc=rand(62);
	if ($rc<25) { $rc+=65; }     #  0-24 goes   A-Z
	elsif ($rc<50) { $rc+=72; }  # 25-49 goes   a-z 
	else { $rc-=4; }             # 50-61 goes ./0-9
	$rc;
}
	
example:

&append_pass('.htaccess','reinar','xyzzy');

or whatever..


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

Date: 9 May 1997 14:48:48 GMT
From: "Daniele Maraschi" <danielem@iol.it>
Subject: Integration between Perl and Java
Message-Id: <01bc5c87$0de0ade0$0e052dc3@einstein>

There is someone that could tell me if he knows some projects
about the Perl and Java integration ??
Thank you in advance !!


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

Date: 09 May 1997 08:04:42 -0400
From: Tom Fawcett <fawcett@nynexst.com>
Subject: Re: join and references
Message-Id: <8jvi4sg8bp.fsf@nynexst.com>

chopps@merit.edu (Christian E. Hopps) writes:
> I'm trying to join a reference with some other text.  It appears
> that the data being referenced goes away when the only reference
> to it is within the joined object.
> 
> Can someone explain why the following program does not do what is
> expected?  It looks like a bug to me however I am willing to
> believe that I have misunderstood (or failed to grasp) something.

When you ask perl to turn a reference into a string, perl produces a
printed representation (eg, "ARRAY(0xb9308)").  These characters are not
the same as a reference.  

-Tom


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

Date: Fri, 09 May 1997 09:42:51 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: MacPerl question
Message-Id: <pudge-ya02408000R0905970942510001@news.idt.net>

In article <336F4367.6DB1@nt.com>, Erik_Perkins@nt.com wrote:

#how do i open an application from within MacPerl and feed it
#(repeatedly) a whole file as its input?

Try this.  You need MacPerl 5.1.1 or higher.

    #!perl
    #This script can be used to open any AppleEvent-aware application
    #and then open files into that app.  The example is with SoundApp.
    #You just need to change the $appid (get that with ResEdit or 
    #something) and the $dir with the files.
    
    use Mac::AppleEvents;
    use Mac::Processes;
    use Mac::MoreFiles(%Application);
    
    $appid = 'SCPL';  #id for SoundApp
    $dir   = 'PowerPump:Desktop Folder:Down : NDocs:ESPN sounds';
    
    #launch application  and bring to front
    my(%Launch);
    tie %Launch, LaunchParam;
    $Launch{launchControlFlags} = launchContinue+launchNoFileFlags;
    $Launch{launchAppSpec}     = $Application{$appid};
    LaunchApplication(\%Launch) or die $^E;
    
    #open directory and send Apple Events to app telling it to open
    #specified files
    opendir (D,$dir) || die "Doh!: $!\n";
    foreach $file (sort readdir(D)) {
        $evt =
AEBuildAppleEvent('aevt','odoc',typeApplSignature,$appid,0,0,'') || die
$^E;
        AEPutParam($evt, '----', 'TEXT', "$dir:$file");
        AESend($evt,kAEWaitReply) || die $^E;
    }
    closedir(D);
    __END__

--
Chris Nandor                 pudge@pobox.com                 http://pudge.net/
%PGPKey=('B76E72AD',[1024,'08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6'])
#=============================================================================
I wish I had a Kryptonite cross, because then you could keep both Dracula AND
Superman away.
                --Jack Handey
#=============================================================================


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

Date: Fri, 09 May 97 09:44:23 GMT
From: jsheehy@trintech.com (John Sheehy)
Subject: Minimum perl installation
Message-Id: <5kurvo$e7b$1@nuacht.iol.ie>

Hello,

I've written a simple perl script that is intended to run on many sites. Most 
of these sites don't need a full perl installation.

Is it sufficient to supply the script and perl executable only. I've tested 
this locally and that seems to be the case. I don't require any of 
the additional perl libraries and use only the barest minimum of perl's 
funtionality.

Are there any issues I should be aware of here?

John.


John Sheehy - Systems Engineer                  
----------------------------------------------                 
Trintech (Manufacturing) Ltd

Telephone: +353 1 295 6766
Facsimile: +353 1 295 4735
WWW: http://www.trintech.com

Many are saved from sin by being so inept at it.

Mignon McLaughlin
 



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

Date: 9 May 1997 09:11:02 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: New Perl programmer in need of tutorials
Message-Id: <5kupn6$rid@info.abdn.ac.uk>

When Katharine Osborne met comp.lang.perl.misc....:
: If anybody knows of any online tutorials on getting started with Perl
: please email me.  It would be especially helpful if they were slanted
: from C\C++ or Java, I've only had the barest minimum exposure to shell
: programming.  Also please don't ask me to read the FAQ's from this
: newsgroup, I've been down that road already.

 ..and you'll have read the excellent examples of how to use perl to solve
common problems, then.

However, the perl manuals (free with perl) contain an excellent
object-oriented perl code tutorial (perltoot), and also there is the perltrap
manpage which shows the main 'differences' between perl syntax and C syntax
(also shell, sed and awk syntax)

and the perlre manpage gives excellent information about Regular Expressions,
something which perl excells at.

In fact, all the manpages are good. And free, I might add.
Once you've read all that, you'll be a cracking good perl coder.

However, for even more knownledge, you want to read the Far More Than You've
Ever Wanted To Know (About Perl) tutorials on _everything_ about particular
perl subjects; http://www.perl.com/CPAN/doc/FMTYEWTK/

and you can gain from other people's experience by going to the same address
but /CPAN/scripts/  where you'll find 1000s of scripts, unlike Matt's
Script Archive where you'll only find a few dozen scripts (that don't run
when you perl -w them :)

--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac   |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com  |University or AUCC, thankfully.***** |always!

-- 
Random sig of the day:
"Cows can vary in length by up to one metre" - Open University


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

Date: Fri, 09 May 1997 09:47:24 -0400
From: the count <eglamkowski@hotmail.com>
Subject: Re: possible typo warning
Message-Id: <33732AEC.469E@hotmail.com>

Tad McClellan wrote:
> the count (eglamkowski@hotmail.com) wrote:
> : this may be a newbie-ish question, but i am getting a possible typo
> : warning and have no idea what is causing it.  it has the unfortunate
> : result of leaving the variables in question with a value of undef.
>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^             ^^^^^^^^^^^^^^^^^^^^^
> You have the cause and the effect reversed. The fact that they are
> undef is what is causing the error messages.

actually, i found that the values were getting filled, but as you point
out below, they weren't being used anywhere else in the program.
(the array from which they were extracted was being used, however...)

> : i have never seen this warning before, and there is nothing in the
> : "Programming Perl" book about it (chapter 9 is a whole chapter on
> : nothing
> : but diagnostic messages, and this one isn't in there).
> 
> I assume you have the 2nd edition of the Camel, which is updated
> to perl 5.

upper right corner: "2nd Edition Covers Perl 5"  :)

> You are using perl 4, yes?

yup, 4.036 for dos

> Are $caseID and $endOfWindow used at least one other time somewhere
> in your program? If a variable is used only once, perl guesses that
> it might be a typo since there isn't much point in remembering something
> in a variable if you're never going to use it...

that's it. 
thanks :)

-- 
   "The gods themselves struggle in vain against stupidity." - Schiller


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

Date: Thu, 08 May 1997 17:52:25 -0700
From: Jay Allen <allenjs@nic.techops.lmco.com>
To: Michael Mellinger <melling@panix2.panix.com>
Subject: Re: quoting a separator for split()
Message-Id: <33727549.1B08@nic.techops.lmco.com>

Posted and sent....

Michael Mellinger wrote:

> Perhaps there is a better way to maintain a flat file database in Perl?

	Perhaps, but I did the same thing and used 2 colons in a row (::) as my
field delimiter.  With what I was doing, it would have been very unusual
for someone to enter that.  Of course, it's easy to check for...
Maybe you can do ~~??  Who knows...

  -j-
---------
Jay Allen
allenjs@nic.techops.lmco.com
ICYRA-Internet Coordinator
Lockheed-Martin - Web Page Lead
The Maxim Group - Sr. Programmer/Analyst
(w) (310) 727-1086
(h) (562) 433-7727


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

Date: 9 May 1997 02:59:52 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Regular Expression/Associative Array Bug???
Message-Id: <5ku3v8$3q3@pirate.shu.edu>

Hello -

merick@xmission.com (Mont Erickson) writes:

>Can someone tell me if this is a bug in Perl5.002 or if this is
>intentional?

(abbreviated code from original)

>Example 1:

>while(<FILE>) {
>	/pattern(.+);/;
>	$assoc_arr{$1} = 1;
>}

>Example 2:

>while(<FILE>) {
>	/pattern(d+);/;
>	$assoc_arr{$1} = 1;
>}

>Example 1 will produce multiple entries for the same key.

>Example 2 will produce only one entry for each key.  Why is this???  I
>would think both examples would produce the same results (one entry
>per key).

Each hash key corresponds to a single scalar value; there's no such
thing as a one-to-many key-value relationship in a hash.

I'm not sure what your printed output looks like, but I would theorize:
that the lines you are reading in contain multiple numbers; that in
Example 1 you are seeing multiple numbers printed out, and assuming that
this means there are multiple values per key (when in fact there is only
one value and it happens to be a string which contains multiple
numerical expressions, such as "123 456 789"); and that you actually
meant (\d+) rather than (d+) in Example 2.

Assuming my guesses are right, nothing unexpected is happening.  (.+) is
returning all the characters following /pattern/, and (\d+) is returning
whatever sequence of one-or-more-digits is found after /pattern/.

If my guesses are wrong, then (at least for me to understand the
question) you'd have to provide some sample input data and
output.

David Black
dblack@icarus.shu.edu



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

Date: Fri, 9 May 1997 07:55:55 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Regular Expression/Associative Array Bug???
Message-Id: <rs6vk5.6j.ln@localhost>

Mont Erickson (merick@xmission.com) wrote:
: Can someone tell me if this is a bug in Perl5.002 or if this is
: intentional?

: Example 1 will produce multiple entries for the same key.

: Example 1:
: -----------------

: open(FILE,"filename");

: while(<FILE>) {
: 	/pattern(.+);/;
: 	$assoc_arr{$1} = 1;


Q: What will be the value in $1 if the pattern did *not* match?

A: either undef, or the value of the *previous* match...



if (/pattern(.+);/)
   {$assoc_arr{$1} = 1}
else
   {warn "Hey! The pattern did not match for input line number $."}


Or, if it is OK for the pattern to not match sometimes:

$assoc_arr{$1} = 1 if /pattern(.+);/;



--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Fri, 09 May 1997 11:32:31 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: scalar holds compiled code
Message-Id: <3372FD3F.7E10@unl.ac.uk>

Chipmunk wrote:
> 
> In article <33704E48.63FA@unl.ac.uk>
> Alastair Aitken <a.aitken@unl.ac.uk> writes:
> 
> > $stuff = 'mv cp al';
> > `$stuff`;                      # note - this is not perl code, its a simple UNIX move
> > command.
> >
> > Which also worked.  Either you are not making your problem clear enough
> > or you are not doing enough of your own testing.
> 
> It's still not what he wants to do.
> 
> I think he made his problem plenty clear enough.  You just haven't
> grasped it yet.
> 
> He has some compiled C code in a scalar variable.  How does he execute
> it?
> 
> It's not Perl code, it's not a shell command.  It is compiled C code.
> 
> Everybody got that?

Sure :-)

Well,  if its in a scalar then perl sees the contents of the file - for
example:

$exe = `cat /usr/bin/mv`;

puts a piece of runnable code into a scalar at which point backticking
causes:

"Can't exec "ELF": No such file or directory ..."

Either write the runnable code back to disk or start exploring the
perlxs tutorial which is in the documentation but not, I just discovered
in my man pages.  Hmm ..

Oh - from the head of the documentation:

XS is a language used to create an extension interface between Perl and
some C library which one wishes to
use with Perl. The XS interface is combined with the library to create a
new library which can be linked to
Perl. An XSUB is a function in the XS language and is the core component
of the Perl application interface. 

Closer?

Alastair.


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

Date: 9 May 1997 09:13:45 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: Script runs fine from shell, but browser doesn't receive variables ::SIGH::
Message-Id: <5kups9$rid@info.abdn.ac.uk>

When Tad McClellan met comp.lang.perl.misc....:
: : CGI::SIGH
: I thought it was a JAPH kinda thing:
: So I Go Hacking?
Sometimes It Gets (Horrible, Hard, Heavy, Huge, Hot)
:)

--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac   |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com  |University or AUCC, thankfully.***** |always!

-- 
Random sig of the day:
"Blue neon electric hippopotamus flickering daintily in the esoteric skies of
my mind while  tripping out on an illegal substance  I recently consumed at a
rave in  Peterhead but  I honestly don't  remember the dealer at all nice  Mr
Policeman and please remove these nasty handcuffs because they are hurting my
wrists amongst other parts of my anatomy." (Working title)


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

Date: 9 May 1997 10:16:03 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Sending e-mail from within a perl script - help
Message-Id: <5kvbj3$9g2@panix.com>

In <5kt52t$f8u$1@nuacht.iol.ie> jsheehy@trintech.com (John Sheehy) writes:

>I'm writing a simple perl script that generates a set of e-mail messages from 
>an input file.

>For each assembled message I call the routine SendMessage below.

>For some unknown reason (at least to me) /bin/mail starts reading from 
>standard input. This results in the script hanging and waiting for keyboard 
>input. I have verified this by sending a message to myself. I also replaced 
>/bin/mail with the cat command and watched the lines bounce back at me as I 
>typed.

>What am I doing wrong?

Forgetting about Perl Modules? 

>sub SendMessage
>{
>        open(MAILPIPE, "|/bin/mail -s \"Overdue Notification\" $_[0]" ) || die 
>"
>Can't open pipe to /bin/mail !\n";
>        print MAILPIPE "\nOverdue item(s) :- \n\n";
>        print MAILPIPE @Message;
>        print MAILPIPE "\nPlease return at your earliest convenience.\n";
>        close MAILPIPE;
>}

>Is there an alternative to this method? Perhaps
>open(MAILPIPE, "|telnet mailhost 25");

I prefer Mail::Tools <http://www.perl.org/CPAN/modules/by-module/Mail/>:

require Mail::Send; 

$msg = new Mail::Send;
$msg = new Mail::Send Subject=>'Overdue Notification', 
  To=>$bad_person, cc=>'jsheehy@trintech.com';
$fh = $msg->open;

print $fh "\nOverdue item(s) : \n\n";

foreach $line(@Message) {
  print $fh "$line\n";
}

print $fh "\nPlease return at your earliest convenience.\n";

$fh->close;         # complete the message and send it

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: Fri, 09 May 1997 09:47:33 +0100
From: Aaron Bennett <abennett@stonehill.edu>
Subject: Re: Something I'm missing
Message-Id: <3372E4A2.7AF6@stonehill.edu>

Thanks to all for the help and clarification.

I've learned two things here:

	1.	\t{0} is a dumb idea :)
	2.	There's More Than One Way to Do It.

Anyhow, with some help and inspiration, I came up with this:



while ($textline = <INPUT>) {
	if ($textline =~ /^[^\t]*$/) { 	# match any text besides a tab
		$textline = "<TR><TD><EM>" . $textline . "</EM></TD></TR>"; 
		} else {
			$textline =~ s/([^\t]+(\t|\n))/<TD>$1<\/TD>/g; # match between tabs
			$textline = "<TR>" . $textline . "</TR>";
			}		
	chomp ($textline);
	print OUTPUT $textline . "\n";
	}

That take this:

Accelerated Courses - 1997

Summer Session I

Course No.		Course Title							Dates		Times			Instructor
SC194			The Human Environment (GS)			5/19-5/23	9am-4:30pm		P. Beisheim
BA105			Intro. to Computers for Business		6/2-6/6		9am-4:30pm		R. Wilcox
CJ319/SO319	Victimology							6/9-6/13		9am-4:30pm		D. LeClair
FA321			On the Go:  Art in Boston Museums	6/16-6/10	9am-4:30pm		C. Calo
EN326			American Film						6/23-6/27	9am-4:30pm		R. Goulet

And produces this:
<TABLE>
<TR><TD><EM>Accelerated Courses - 1997
</EM></TD></TR>
<TR><TD><EM>
</EM></TD></TR>
<TR><TD><EM>Summer Session I
</EM></TD></TR>
<TR><TD><EM>
</EM></TD></TR>
<TR><TD>Course No.	</TD>	<TD>Course Title	</TD>						<TD>Dates	</TD>
<TD>Times	</TD>		<TD>Instructor
</TD></TR>
<TR><TD>SC194	</TD>		<TD>The Human Environment (GS)	</TD>		<TD>5/19-5/23
</TD><TD>9am-4:30pm	</TD>	<TD>P. Beisheim
</TD></TR>
<TR><TD>BA105	</TD>		<TD>Intro. to Computers for Business	</TD>
<TD>6/2-6/6	</TD>	<TD>9am-4:30pm	</TD>	<TD>R. Wilcox
</TD></TR>
<TR><TD>CJ319/SO319	</TD><TD>Victimology	</TD>						<TD>6/9-6/13	</TD>
<TD>9am-4:30pm	</TD>	<TD>D. LeClair
</TD></TR>
<TR><TD>FA321	</TD>		<TD>On the Go:  Art in Boston Museums
</TD><TD>6/16-6/10	</TD><TD>9am-4:30pm	</TD>	<TD>C. Calo
</TD></TR>
<TR><TD>EN326	</TD>		<TD>American Film	</TD>					<TD>6/23-6/27
</TD><TD>9am-4:30pm	</TD>	<TD>R. Goulet
</TD></TR>
</TABLE>

Which works fine and will save me tons and tons of work in the future.

I can't really find a good way to say thanks for your help to everyone
except to say, "Thanks!"

	- Aaron Bennett.
-- 
|	Aaron Bennett, 	Internet Services Coordinator,
|	Stonehill College Department of Academic Computing
| 	http://www.stonehill.edu 
|			"The most precious things remain unseen."


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

Date: Fri,  9 May 1997 03:55:11 -0400
From: Jason C Miller <jm+@andrew.cmu.edu>
Subject: SUID on Webservers?
Message-Id: <QnQhVTe00YUu16M1g0@andrew.cmu.edu>


I've written a WWW-based program in perl that allows users to maintain
their own password and edit them from a browser.

In theory, the program works under this model:
1. you file called "password" which is a UNIX crypt() user/password list
   it is only writeable by the user "foobar"
2. you have a program called "updatepw.cgi" which allows the file "password"
   to be edited because it runs from the Webserver as suid("foobar").

I'm implementing this for a number of clients under many times of server
and perl configurations.  Some of them work right off.  Others need to
run from suidperl.  Still others don't work at all (the suid never
happens).

Can anyone let me know which cases prevent perl programs and or perl
versions from running as setuid and does anyone know if there are
workarounds to force a suid to happen for this purpose?
Also, of course, does anyone know of a better, different way to approach
this problem?  You can safely assume there will not be standard
databases, platforms, or webservers throughout my adventures.  So any
ideas have to be _portable_.

You're comments, ideas, and help are most appreciated!

Many thanks,
Jason Miller




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

Date: 09 May 1997 07:19:27 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: a.aitken@unl.ac.uk
Subject: Re: system () won't execute the called program.
Message-Id: <8cyb9ozq1c.fsf@gadget.cscaper.com>

>>>>> "Alastair" == Alastair Aitken <a.aitken@unl.ac.uk> writes:

Alastair> I thought this too when I saw it.  Someone (Randall?) has
Alastair> already posted that system returns false for success and
Alastair> true for fail, open() returns true for success and false for
Alastair> failure and backticks return the ouptut of the command.
Alastair> exec() does not return at all but closes the calling script
Alastair> prior to execing.

Well, I've never *posted* that... but it sounds like something I wrote
into my two books, Learning Perl and Programming Perl. :-)

Also, exec() *can* return if it's a failed exec that is being handled
internally (as opposed to calling a /bin/sh first because the command
is too complicated):

	$ perl -e '$ret = exec "bogus"; die "failed exec: $ret"'
	failed exec: 0 at -e line 1.
	$ perl -e '$ret = exec "bogus; "; die "failed exec: $ret"'
	sh: bogus: not found

Note that the "return" code of an internally-handled exec is always 0,
because if it succeeds, it doesn't return.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 480 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Fri, 09 May 1997 10:58:30 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: url detection in a string
Message-Id: <3372F546.4BFB@unl.ac.uk>

Sascha Kerschhofer wrote:

> $test = "look at http://info.com/mor.html for further information";
> &findurl($test);
> 
> $test should now be: "look at <A
> HREF="http://info.com/more.html">http://info.com/more.html</A> for further
> information"
> 
> i tried with the following:
> 
> sub findurl {
>   $_ =~ s/(.*)(\shttp://.*\s)(.*)/$1 <A HREF="$2">$2</A> $3/g
> }
> but this doesnt work.

This does:

#! /usr/local/bin/perl -w

require 5.003;
use strict;

my ($test)

$test = "look at http://info.com/mor.cgi?test1=1&test2=2 for further
information";
&findurl($test);
print "$test\n";
exit 0;

sub findurl {
    $test = s#"|\\##g;
    $test =~ s#(.*)\s(http://.*?)\s(.*)#$1 <A HREF="$2">$2</A> $3#g;
}

The first substitution (using the '#' character to separate the elements
of the 's' function) removes all escape characters and double quote -
you could take this as far as you need.  The second line makes an href
out of the http://... in $test.  the '?' in the regexp is for non-greedy
matching (ie: stop matching asap).  I tried this with a simple query
type url of the form above and it coped ok.

Alastair.


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

Date: Fri, 09 May 1997 09:37:18 -0400
From: Wade Leftwich <wade@demographics.com>
To: jon_brule@nt.com
Subject: Re: Win32 Perl
Message-Id: <3373288E.28EF@demographics.com>

If you're talking about CGI, the answer is yes. The Activeware
distribution includes perlis.dll, which runs under ISAPI (supported by
MS IIS and O'Reilly Website).

Jon Brule wrote:
> 
> Good Afternoon,
> 
> Does anyone know if it is possible to execute a Win32 PERL script using
> a DLL call instead of using the convential method of running "perl
> scriptname"?
> 
> Thanks.
> 
> Jon Brule
> jon_brule@nt.com


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

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

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