[6953] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 578 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 5 22:07:14 1997

Date: Thu, 5 Jun 97 19:00:26 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 5 Jun 1997     Volume: 8 Number: 578

Today's topics:
     Re: any editor for perl? (Ron Olsen)
     Applets in Perl <amerar@unsu.com>
     Re: Atomic file create or fail if already existing (R Bradley)
     Re: Atomic file create or fail if already existing (Jot Powers)
     Re: Beginning Books on Perl (Faust Gertz)
     Re: Beginning Books on Perl <sibsib@hotmail.com>
     Re: Code examples: right justify text? (Fred Elbel)
     CORBA Perl mapping? (Yiu Pang)
     Re: Decoding of the 'Zafir' language :) (Abigail)
     Re: Error in openning a file ... (Jot Powers)
     File locking <flash@webfresco.com>
     Re: Finding string length <jerrym@ibmoto.com>
     Re: Finding string length <ajohnson@gpu.srv.ualberta.ca>
     HELP: Where is this anti-rounding error from?!! <micsaund@holly.ColoState.EDU>
     Re: inconsistent opendir behaviour in Perl for win32 <wm_n00@tarrcity.demon.co.uk>
     IRC Module Interest (Daniel)
     Output to HTML page (Graham Daniell)
     Output to HTML page (Graham Daniell)
     perl simulated 'enter' key <rferr@voicenet.com>
     perlxs questions <jces@hotwired.com>
     Re: Reading Comma delimited, Quoted String records <jlopez@sprynet.com>
     Re: RegExp tutorial suggestions? (James Hanlon)
     Re: Synchronizing output from system command? (Tad McClellan)
     Re: Telnet <ray@icix.net>
     Re: What can '\G' be used for in regexps ? (Ilya Zakharevich)
     Works in Shell, not as cgi (Xran)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 6 Jun 1997 01:14:38 GMT
From: ronolsen@lucent.com (Ron Olsen)
Subject: Re: any editor for perl?
Message-Id: <EBBy4E.J54@drnews.dr.lucent.com>

> Matthew H. Gerlach
> For me, my needs are best met with vi.

Very likely they'd be far better met with vim.

-- 
	Ron Olsen
	ronolsen@lucent.com
	Boulder Colorado


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

Date: Thu, 05 Jun 1997 15:44:19 -0500
From: Arthur Merar <amerar@unsu.com>
Subject: Applets in Perl
Message-Id: <33972523.2EA1@unsu.com>

Hello, I am writing my first PERL script for my homepage.  The script
will accept some data from the user and pass that data to an applet
which will run.

Can I execute an applet from within a Perl script?  If so, how do I do
this?

Thank you,

Arthur
amerar@unsu.com


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

Date: 5 Jun 1997 23:15:28 GMT
From: rick@rentec.com (R Bradley)
Subject: Re: Atomic file create or fail if already existing
Message-Id: <5n7hag$sga@puma.rentec.com>

Jot Powers (jot@tmp.medtronic.com) wrote:
: In article <5n479t$6b4@puma.rentec.com>, rick@rentec.com (R Bradley) writes:
: >Leonard Megliola (lmegliol@inertia.acs.uci.edu) wrote:
: >: I need an atomic operation which will create a new file if it
: >: doesn't exists, but fail if the file already does exist.
: >
: >If you're on Unix you can man open(2) and look at O_EXCL and O_CREAT.
: >The open in the POSIX module should behave in the same way.
: To the best of my knowledge, it is really not possible to do atomic
: file operations over NFS.

Then if a unique filename is needed... you could use
base filename, pid, IP address of machine where process runs, 
timestamp (to second) to generate the filename.  Assuming IP addresses
are unique, the machine can't reboot in less than a second, and 
the same application can't be run with the same PID within the same
second (probably reasonable on the average Unix system). 

Rick


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

Date: 6 Jun 1997 00:20:08 GMT
From: jot@tmp.medtronic.com (Jot Powers)
Subject: Re: Atomic file create or fail if already existing
Message-Id: <5n7l3o$sr8$1@gazette.corp.medtronic.com>

In article <5n7hag$sga@puma.rentec.com>, rick@rentec.com (R Bradley) writes:
>Jot Powers (jot@tmp.medtronic.com) wrote:
>: In article <5n479t$6b4@puma.rentec.com>, rick@rentec.com (R Bradley) writes:
>: >Leonard Megliola (lmegliol@inertia.acs.uci.edu) wrote:
>: >: I need an atomic operation which will create a new file if it
>: >: doesn't exists, but fail if the file already does exist.
>: >
>: >If you're on Unix you can man open(2) and look at O_EXCL and O_CREAT.
>: >The open in the POSIX module should behave in the same way.
>: To the best of my knowledge, it is really not possible to do atomic
>: file operations over NFS.
>
>Then if a unique filename is needed... you could use
>base filename, pid, IP address of machine where process runs, 
>timestamp (to second) to generate the filename.  Assuming IP addresses
>are unique, the machine can't reboot in less than a second, and 
>the same application can't be run with the same PID within the same
>second (probably reasonable on the average Unix system). 

Or POSIX::tmpnam

node127% perl -de 1
 
Loading DB routines from perl5db.pl version 1
Emacs support available.
 
Enter h or `h h' for help.
 
main::(-e:1):   1
  DB<1> use POSIX
 
  DB<2> $tempname = POSIX::tmpnam();
 
  DB<3> p $tempname
/var/tmp/aaaa003uH


Then again, I haven't looked at the POSIX module to see how it would work at
creating tempnames for NFS.

-Jot


-- 
Jot Powers  jot@tmp.medtronic.com
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."




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

Date: Thu, 05 Jun 1997 22:43:13 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Beginning Books on Perl
Message-Id: <33973fac.6165605@news.wwa.com>

On Thu, 05 Jun 1997 16:12:31 -0600, bill_leber@hotmail.com wrote:

>Any suggestions for a starter book on perl.  I am
>familiar with other programming languages.

Didi you read the FAQ?  If you had, here is what you would have found,
(with minor modifications).

>A number books on Perl and/or CGI programming are available. A few of these are good, some are ok, but many aren't worth
>your money. Tom Christiansen maintains a list of these books, some with extensive reviews, at
>http://www.perl.com/perl/critiques/index.html
>
>The incontestably definitive reference book on Perl, written by the creator of Perl and his apostles, is now in its second edition
>and fourth printing. Note that O'Reilly books are color-coded: turquoise (some would call it teal) covers indicate perl5
>coverage, while magenta (some would call it pink) covers indicate perl4 only. Check the cover color before you buy! 
>
>    Programming Perl (the "Camel Book"):
>        Authors: Larry Wall, Tom Christiansen, and Randal Schwartz
>        ISBN 1-56592-149-6      (English)
>        ISBN 4-89052-384-7      (Japanese)
>        (French and German translations in progress)
>
>What follows is a list of the books that the FAQ authors found personally useful. Your mileage may (but, we hope, probably
>won't) vary. 
>
>If you're already a hard-core systems programmer, then the Camel Book just might suffice for you to learn Perl from. But if
>you're not, check out the ``Llama Book''. It currently doesn't cover perl5, but the 2nd edition is nearly done and should be out
>by summer 97: 
>
>    Learning Perl (the Llama Book):
>        Author: Randal Schwartz, with intro by Larry Wall
>        ISBN 1-56592-042-2      (English)
>        ISBN 4-89502-678-1      (Japanese)
>        ISBN 2-84177-005-2      (French)
>        ISBN 3-930673-08-8      (German)
>
>Another stand-out book in the turquoise O'Reilly Perl line is the ``Hip Owls'' book. It covers regular expressions inside and
>out, with quite a bit devoted exclusively to Perl: 
>
>    Mastering Regular Expressions (the Cute Owls Book):
>        Author: Jeffrey Friedl
>        ISBN 1-56592-257-3
>
>You can order any of these books from O'Reilly & Associates, 1-800-998-9938. Local/overseas is 1-707-829-0515. If you
>can locate an O'Reilly order form, you can also fax to 1-707-829-0104. See http://www.ora.com/ on the Web. 
>
>Recommended Perl books that are not from O'Reilly are the following: 
>
>   Cross-Platform Perl, (for Unix and Windows NT)
>       Author: Eric F. Johnson
>       ISBN: 1-55851-483-X
>
>   How to Set up and Maintain a World Wide Web Site, (2nd edition)
>        Author: Lincoln Stein, M.D., Ph.D.
>        ISBN: 0-201-63462-7
>
>   CGI Programming in C & Perl,
>        Author: Thomas Boutell
>        ISBN: 0-201-42219-0
>
>Note that some of these address specific application areas (e.g. the Web) and are not general-purpose programming books. 

Hope that helps.

Streben nach Wahrheit

Faust Gertz
Philosopher at Large


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

Date: Thu, 05 Jun 1997 19:11:21 -0400
From: Scott Blanksteen <sibsib@hotmail.com>
Subject: Re: Beginning Books on Perl
Message-Id: <33974799.8997DF8A@hotmail.com>

bill_leber@hotmail.com wrote:
> Any suggestions for a starter book on perl.  I am
> familiar with other programming languages.

man perlbook

or try the Perl FAQ at 

<http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq.html>

Scott

-- 
Scott I. Blanksteen
sib (at) worldnet (dot) att (dot) net


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

Date: Thu, 05 Jun 1997 23:06:35 GMT
From: frelbel@N0SPAMcsn.net (Fred Elbel)
Subject: Re: Code examples: right justify text?
Message-Id: <33974411.38947769@news-2.csn.net>



> > In Fred Elbel <frelbel@N0SPAMcsn.net> wrote:
> >I'm about to design a routine to right justify text paragraphs, but
> >perhaps it's already been done :)    I checked various archives and
> >haven't found anything yet.
 

On 5 Jun 1997 16:16:12 GMT, I-hate-cyber-promo@man.ac.uk (A. Deckers)
wrote:

> Does Text::Wrap not meet your requirements?
>  <URL:http://www.perl.com/CPAN/modules/by-module/Text/>

Indeed it might.  I did find it and downloaded it after my original
post.  I'll take a look at it.  Obviously, I missed it the first time
around, so I appreciate your suggestion.


>...I'm not going to spend time de-munging your address so I can
> cc you a copy of this post. Is there some reason why you can't filter
> incoming mail to get rid of spam, like most other cluefull people do?


I don't blame you on the unmunging thing.  Yet I got 30 or so spams
from postings this week and last.  Nanam (news.admin.net-abuse.misc)
and other abuse groups seem to be grepped more than others.  Yes, I do
filter, and I *think* I have a clue, but not all the answers.

Thanks again for your help,
Fred
--  Fred Elbel  frelbel@N0SPAMcsn.net 
--    To e-mail: delete N0SPAM in my return address
--  How to eliminate junk mail and spam: 
--    http://www.csn.net/~felbel/jnkmail.html 



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

Date: 5 Jun 1997 23:58:56 GMT
From: robpang@cs.Stanford.EDU (Yiu Pang)
Subject: CORBA Perl mapping?
Message-Id: <5n7js0$ir5$1@Radon.Stanford.EDU>

Hi everyone,

I am currently looking for CORBA Perl mapping and I have found one done by
Bart Schuller.  His is quite good.  Besides his mapping, is there any other
mapping available for consideration?

Thanks a bunch!

Robert

--
=========================================================================
 Robert Pang             | Life is like a tennis match, you cannot
 (510)494-9095           *   win without serving.     -- anonymous
 robpang@cs.stanford.edu |
=========================================================================


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

Date: Thu, 5 Jun 1997 22:36:55 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Decoding of the 'Zafir' language :)
Message-Id: <EBBqtJ.K0M@nonexistent.com>

Mike Stok (mike@stok.co.uk) wrote on 1374 September 1993 in
<URL: news:5n6our$37e@news-central.tiac.net>:
++ In article <33963973.24813610@news.seanet.com>,
++ Tim Gim Yee <tgy@chocobo.org> wrote:
++ 
++ >Is it because I'm still using 5.003?  In any case, explicitly adding
++ >$_ did the trick:
++ >
++ >print map {ucfirst lc reverse $_} split;
++ 
++ No, reverse doesn'h have a default argument (well, none is mentioned in
++ the 2nd edition of programming perl or the online docs for 5.004 - the
++ functions which do take $_ as a default usually have something like "If
++ LIST is omitted [does somehting to] $_ ..." in the description.)

Cut & Paste from my screen:

18:30:39 [abigail@betelgeuse] abigail) perl5.004 -wl
use strict;
$_ = "Gnillor No eht Roolf Gnihgual Dna Gniracs Eht Tac"; $, = " ";
print map {ucfirst lc reverse;} split;
__END__
Rolling On The Floor Laughing And Scaring The Cat

18:30:54 [abigail@betelgeuse] abigail) perl5.003 -wl
use strict;
$_ = "Gnillor No eht Roolf Gnihgual Dna Gniracs Eht Tac"; $, = " ";
print map {ucfirst lc reverse;} split;
__END__
Cat        

Undocumented feature?


Abigail
-- 
perl5.004 -wMMath::BigInt -e'$=new Math::BigInt+qq;$$783$[$%9889$47$|88768$596577669$%$5$3364$[$$$|838747$[8889739$%$|$673$%$98$76777$=56;;$=$]*(q.25..($=@))=>do{print+chr$%$;$/=$}while$!=$'


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

Date: 5 Jun 1997 22:53:07 GMT
From: jot@tmp.medtronic.com (Jot Powers)
Subject: Re: Error in openning a file ...
Message-Id: <5n7g0j$r5b$1@gazette.corp.medtronic.com>

[*snip*]

Comments:

1) You included sample information!

>
>#!/usr/local/bin/perl  -w
						^^^
2) Great choice!

>
>open (Quotes, "quotes_friends") || die $!; 
>@QUOTES = <Quotes>;
>srand;
>$QUOTE = rand @QUOTES;
>
>system "cat /$QUOTES[$QUOTE]  >  /quote.txt";


3) You didn't include the output of perl -v

Now that, aside, here is what I did when I went into the debugger (notice
that /tmp/xx isn't your stuff, but you wanted a random line, so any file
would work.)

node127% perl -de 1
 
Loading DB routines from perl5db.pl version 1
Emacs support available.
 
Enter h or `h h' for help.
 
main::(-e:1):   1
  DB<1> open (FILE,'/tmp/xx') or die "$!\n";
 
  DB<2> @stuff = <FILE>;
 
  DB<3> srand
 
  DB<4> $stuff = rand @stuff
 
  DB<5> p $stuff
2.268310546875

  This should be your clue that something is terribly wrong.  The value
of $stuff is 2.2XXX.

Your next line is an attempt to access $stuff[2.xxxx].  A fractional index
to an array isn't going to work. 

So, what's the problem?  Your understanding of rand() is off.

node127% man perlfunc
Reformatting page.  Wait... done
 ...
     rand EXPR
 
     rand    Returns a random fractional number between 0 and the
             value of EXPR.  (EXPR should be positive.)  If EXPR
             is omitted, returns a value between 0 and 1.
             Automatically calls srand() unless srand() has
             already been called.  See also srand().

Notice, it says EXPR not ARRAY.  So, you want to change that and
you need to round the result (see the FAQ on rounding)

-Jot

-- 
Jot Powers  jot@tmp.medtronic.com
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."




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

Date: Thu, 05 Jun 1997 20:36:51 -0400
From: Gordon Hunt <flash@webfresco.com>
Subject: File locking
Message-Id: <33975BA3.2181@webfresco.com>

Can anyone help me with file locking under Solaris.  flock() doesn't
work.  If anyone has some sample code using fcntl() I would appreciate
it.

Thanks
-- 
Gordon Hunt  |  flash@webfresco.com


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

Date: Thu, 05 Jun 1997 13:16:25 -0500
From: Jerry Monsen <jerrym@ibmoto.com>
Subject: Re: Finding string length
Message-Id: <33970279.3F54@ibmoto.com>

Chipmunk wrote:
> 
> In article <Pine.OSF.3.96.970604191007.5593B-100000@alf2.tcd.ie>
> Kieran Tully <tullyk@tcd.ie> writes:
> 
> > How can I find the length of a string (or more particularly a line) in
> > Perl ?
> 
> $i = -1;
> $i++ while (defined substr($string, $i+1, 1));
> $length = $i;
> 
> Chipmunk
Um, this is a little easier:

$length = length($string);

Jerry


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

Date: Thu, 05 Jun 1997 15:45:15 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
To: Chipmunk <Ronald.J.Kimball@dartmouth.edu>
Subject: Re: Finding string length
Message-Id: <3397255B.54511F86@gpu.srv.ualberta.ca>

Chipmunk wrote:
> 
> In article <Pine.OSF.3.96.970604191007.5593B-100000@alf2.tcd.ie>
> Kieran Tully <tullyk@tcd.ie> writes:
> 
> > How can I find the length of a string (or more particularly a line) in
> > Perl ?
> 
> $i = -1;
> $i++ while (defined substr($string, $i+1, 1));
> $length = $i;
> 
> Chipmunk

oh no... :-)

$length=rindex($string,"");

andrew


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

Date: 5 Jun 1997 13:20:09 -0600
From: Michael Saunders <micsaund@holly.ColoState.EDU>
Subject: HELP: Where is this anti-rounding error from?!!
Message-Id: <5n73h9$aok@holly.ColoState.EDU>

Hello!

I am working on a program (pretty simple) and I am having trouble
with numbers getting "un-rounded."  The easiest way to explain this
is with some code/output:

	    $xpos = ((($x * $xstep) + $xoffset) + $xorig);
	    $ypos = ((($y * $ystep) + $yoffset) + $yorig);

where:
	$x and $y are generated by a "for" loop and should be integers

	$xstep and $ystep are user entered values from <STDIN>

	$xoffset and $yoffset are user entered values from <STDIN>

	$xorig and $yorig are floating point numbers from a file

To generate the following output code, the following values were used:

	$x = 0
	$y = 0
	$xstep = 100
	$ystep = 100
	$xoffset = 10
	$yoffset = 10
	$xorig and $yorig are given in the output

Here's some of the output:

PAD:10 (0,0) (985.5,2152.6999999999998)  ORIG (975.5,2142.7)
PAD:11 (0,0) (985.5,1952.7)  ORIG (975.5,1942.7)
PAD:21 (0,0) (2203.6999999999998,992)  ORIG (2193.7,982.0)

For this ouput, the desired returned value would be the Xorig
plus 10.  The same goes for the Yorig.

As you can see, in the PAD10 example, the first (X) number
is correct (975.5 + 10 = 985.5), but the second (Y) number
has been "un-rounded" from 2152.7 to 2152.6999999999998.

The PAD21 example is the same, except for the X and Y errors
have swapped places.

The PAD11 result is entirely correct and what I want.

Can someone help me fix and explain why this "un-rounding" is
happening (particularily in such a simple program)?  

Your help is much appreciated!

Mike
micsaund@holly.colostate.edu



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

Date: Fri, 6 Jun 1997 00:56:29 +0100
From: Wm <wm_n00@tarrcity.demon.co.uk>
Subject: Re: inconsistent opendir behaviour in Perl for win32
Message-Id: <3OjWZUAtI1lzEwL7@tarrcity.demon.co.uk>

Wed, 4 Jun 1997 12:31:26 <Pine.GSO.3.96.970604122349.12995E-
100000@kelly.teleport.com>
Tom Phoenix <rootbeer@teleport.com> posted...

>On Wed, 4 Jun 1997, Simon Oosthoek wrote:
>
>> The uppercase and  the "/" for the "\"  make no difference...
>> This problem is so illogical, it looks more and more like a bug to me.
>
>Maybe it is. But let's try a test to be sure. Does the output of this make
>any sense? Hope this helps!
>
>    #!perl
>    @dirs = qw(d: d:/ d:/. d:/.. 
>              D: D:/ D:/. D:/..  );    # add or change as needed
>    for $dir (@dirs) {
>       print "Checking on '$dir'...\n";
>       unless (-d $dir) {
>           print "  -d says false!\n\n";
>           next;
>       }
>       print "  -d says true...\n";
>       unless (opendir DIR, $dir) {
>           print "  but opendir can't open it: $!\n\n";
>           next;
>       }
>       print "  and opendir can open it...\n";
>       @files = readdir(DIR);
>       $count = @files;
>       print "  and it has $count items in it.\n\n";
>       closedir DIR;
>    }
>

Hmmn.  I tried this using build 306 on Win95 (having changed D to C and
getting rid of the ... after "Checking on '$dir'" as Win95 uses ... as
two directories up the tree) and received the ff:

-- start output --

Checking on 'c:'
  -d says false!

Checking on 'c:/'
  -d says true...
  but opendir can't open it: No such file or directory

Checking on 'c:/.'
  -d says true...
  and opendir can open it...
  and it has 49 items in it.

Checking on 'c:/..'
  -d says true...
  and opendir can open it...
  and it has 49 items in it.

Checking on 'C:'
  -d says false!

Checking on 'C:/'
  -d says true...
  but opendir can't open it: No such file or directory

Checking on 'C:/.'
  -d says true...
  and opendir can open it...
  and it has 49 items in it.

Checking on 'C:/..'
  -d says true...
  and opendir can open it...
  and it has 49 items in it.

-- end output --

However it also appears to me that using .. and . from the top of a DOS-
type directory may be misleading so I tried again with "tmp/" placed
immediately after [Cc]:/ and rx'd:

-- start output --
Checking on 'c:tmp'
  -d says false!

Checking on 'c:/tmp'
  -d says true...
  and opendir can open it...
  and it has 46 items in it.

Checking on 'c:/tmp/.'
  -d says true...
  and opendir can open it...
  and it has 46 items in it.

Checking on 'c:/tmp/..'
  -d says true...
  and opendir can open it...
  and it has 49 items in it.

Checking on 'C:tmp'
  -d says false!

Checking on 'C:/tmp'
  -d says true...
  and opendir can open it...
  and it has 46 items in it.

Checking on 'C:/tmp/.'
  -d says true...
  and opendir can open it...
  and it has 46 items in it.

Checking on 'C:/tmp/..'
  -d says true...
  and opendir can open it...
  and it has 49 items in it.

-- end output --

Just to be clear there are 49 items in the root of my C: drive (not
counting . and ..) and 46 in my tmp directory *including* . and ..

The case of the drive letter does not appear to be significant but the
working of opendir at root level and subdirectory level vs -d does
change.  Whether or not this should be the case I am unable to say.

HTH

-- 
Wm ... did you know?  My spell checker wants tarrcity to be atrocity.


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

Date: 5 Jun 1997 09:01:45 GMT
From: RW1haWwgbWUgYXQ6IGRhbmllbEBjY28ubmV0Cg@nospam.org (Daniel)
Subject: IRC Module Interest
Message-Id: <slrn5pd007.qpl@cco.net>
Keywords: irc perl module

Just wanted to know if there is any interest in a perl IRC module, I see
a placeholder in the CPAN module list, but with no reply from the contact,
I have decided to write my own. 

I currently have a number of basic IRC functions implemented through a OO
interace. I hope to expand it to cover everything in RFC1459, and even
write an entire server in perl.

Email me if you would like a copy of the module, I'd appreciate any
suggestions for improving it. Instructions for decoding my email address
are below.

#!/usr/bin/perl -- ## decode my email address to prevent spam. (C) DFS
$_=<>;tr|A-Za-z0-9+/| -_|;print unpack "u",chr(24+length).$_

Save this to a file, and run like so:

echo RW1haWwgbWUgYXQ6IGRhbmllbEBjY28ubmV0Cg | ./decode

Assuming you saved the above code snippet to "decode".

Daniel



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

Date: Wed, 04 Jun 1997 22:59:18 GMT
From: gdaniell@wt.com.au (Graham Daniell)
Subject: Output to HTML page
Message-Id: <3395f335.2940400@news.wt.com.au>

Hi,
(I am sending this message again as it did not seem to get posted
properly yesterday)
I am an absolute beginner with PERL, trying to learn it and discover
how it works.  I have the book " Intriduction to CGI/Perl" by Brenner
& Aoki.  In it they give an example of a Perl program as follows:
---------------------------
#!/usr/ucb/perl


print "Content-type: text/html\n\n";

print "<html>\n";
print "<head>\n";
print "<title>Hello World with Perl</title>\n;
print "</head>\n";
print "<body>\n";
print "<h1>Hello World</h1>\n";
print "</body>\n";
print "</html>\n";
------------------------
 I have typed this in as ptest.cgi, and done chmod 777 ptest.cgi on
it.  My question is: ...
How do I call this script from a HTML page in order to get it to
return the "Howdy World" to the browser?

Any help will be much appreciated.

Graham Daniell
Perth, Western Australia
gdaniell@wt.com.au


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

Date: Wed, 04 Jun 1997 10:46:04 GMT
From: gdaniell@wt.com.au (Graham Daniell)
Subject: Output to HTML page
Message-Id: <339543c4.9249819@news.wt.com.au>

Hi,

I am an absolute beginner with PERL, trying to learn it and discover
how it works.  I have the book " Intriduction to CGI/Perl" by Brenner
& Aoki.  In it they give an example of a Perl program as follows:
---------------------------
#!/usr/ucb/perl

print "Content-type: text/html\n\n";

print "<html>\n";
print "<head>\n";
print "<title>Hello World with Perl</title>\n;
print "</head>\n";
print "<body>\n";
print "<h1>Hello World</h1>\n";
print "</body>\n";
print "</html>\n";
------------------------
 I have typed this in as ptest.cgi, and done chmod 777 ptest.cgi on
it.  My question is: ...
How do I call this script from a HTML page in order to get it to
return the "Howdy World" to the browser?

Any help will be much appreciated.

Graham Daniell
Perth, Western Australia
gdaniell@wt.com.au


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

Date: 5 Jun 1997 23:52:10 GMT
From: "rferr" <rferr@voicenet.com>
Subject: perl simulated 'enter' key
Message-Id: <01bc720c$90c2f0c0$578667cf@rferr.voicenet.com>

i am writing a perl script in dos. is it possible to have the script
simulate the
'enter' key being hit ?

thanks.


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

Date: Thu, 05 Jun 1997 15:22:13 -0700
From: Jon Slenk <jces@hotwired.com>
Subject: perlxs questions
Message-Id: <33973C15.4EB3@hotwired.com>

i'm trying to use perlxs ("well, there's your problem" - click & clack)
to leverage off a big system that's got a c interface. i've gone through
the perlxs and perlxstut docs (which, i might say, aren't all that
clear) and still have questions (i'm going to try and look at some other
perl mods that use perlxs, also); if someone can give me a clue about
this stuff, that sure would be nice! even if it's "hey, silly, look at
this (unlike the rest) useful faq that everyone but you knows about:
<url>."

1) the system i'm using gives example c code that does stuff like:

	struct ToolkitThing tkThing;
	Toolkit_InitializeThing( &tkThing );

so my question is, how do i deal with creating the structure in perl?
like, i was originally thinking that i could just translate those lines
into perl, with the Toolkit_InitializeThing call going through perlxs.
now, i'm starting to think that i want to wrap the whole thing (in
general, as much c code as possilbe) into one perlxs call so i don't
have to deal with quandries like creating the strange struct in perl
itself. or something.

2) the system has a whole slew of .h files that i guess i need to run
through h2xs. i can't seem to get h2xs to process more than one .h file
at a time. is that really how it's supposed to work? i mean, do i run it
for each one and then somehow merge the results? or can i have it munge
the whole set of include files at once (oh please)?

hi,
-Jon.


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

Date: 5 Jun 1997 23:01:54 GMT
From: "John Lopez" <jlopez@sprynet.com>
Subject: Re: Reading Comma delimited, Quoted String records
Message-Id: <01bc7203$72355f20$2ec1afce@spry011108>

Interesting - the Perl Faq I accessed must be old.  It recommended:
[begin code snippet]
 @new = ();
     push(@new, $+) while $text =~ m{
         "([^\"\\]*(?:\\.[^\"\\]*)*)",?  # groups the phrase inside the
quotes
       | ([^,]+),?
       | ,
     }gx;
     push(@new, undef) if substr($text,-1,1) eq ',';
[end code snippet]

And worse yet, silly me has been using a routine I wrote myself.  It works,
but I would be interested in getting it ripped apart by the true perl users
out here...

[begin my snippet]
sub unquote
{
    my ($string) = shift (@_); #Copy formal parameters.
    my ($delim) = shift (@_); #Delimiter to use (default comma)
    my (@parameters) = (); #Clear parameters
    
    $delim = "," if $delim eq '';
    while ( $string )
    {
        if ( $string =~ /^"(.*?)"$delim/ ) #First check for a quoted string
        {
            push (@parameters, $1); #Sub pattern 1, the stuff between the
quotes.
            $string = $'; # $` . $&  . $' is the 3 parts of a pattern match
(before, match, after)
        }
        elsif ( $string =~ /^(.*?)$delim/ ) #If not quoted, copy to comma
        {
            push (@parameters, $1);
            $string = $';
        }
        else  #Otherwise, last item in record.
        {
            push (@parameters, $string);
            $string = "";
        }
    }
    return @parameters
[end snippet]

This code shows I started as a C programmer - my perl is structured very
much like my C.  I would appreciate an analysis of where this would fail
(as it works with the data set we use here, but I have not TRIED to break
it...)  I would love an explanation of the first snippets use of regular
expressions.  My brain hurt just looking at it.



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

Date: 5 Jun 1997 17:49:17 -0500
From: tcubed@MCS.COM (James Hanlon)
Subject: Re: RegExp tutorial suggestions?
Message-Id: <5n7fpd$log$1@Mars.mcs.net>

In article <33858332.11B6@synnet.com>, Tom Lynch  <toml@synnet.com> wrote:
:Jason A. Soloff wrote:
:> 
:> Hi all..
:> 
:> Does anyone know of a good regexp tutorial or FAQ online?
:> Doesn't have to be incredibly perl heavy, just explain how to
:> set up and use the regexps...
:> 
:> Thanks,
:> 
:> Jason
:I think  you want to get the O'Reilly Book Mastering Regular Expressions
:by Jeffrey E.F. Friedl take a look at the Web page at:
:
:	http://enterprise.ic.gc.ca/~jfriedl/regex/
:

Seconding that, I used to think I was a regex buff, almost a regex wizard.
No more. It's Jeffrey Friedl, he has authored the definitive work on
regular expressions, with a big chapter on Perl regex's. Buy this book,
and entertain your friends for hours on the performance implications of
implementing a regex engine as a nondeterministic finite state automaton.


Jim Hanlon
tcubed@mcs.com





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

Date: Thu, 5 Jun 1997 15:33:55 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Synchronizing output from system command?
Message-Id: <jr77n5.ooa.ln@localhost>

I hate spam! (alweiner@presstar.com.net) wrote:
: The following program:

:   print "This should print first\n";
:   system("echo \"this should print second\"");

: produces:
:   this should print second
:   this should print first


: How do you synchronize the output in perl so that the results of a 
: system command appear in the same logical order as the calling code?


search for 'flush' in the Perl man pages or FAQ...


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


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

Date: Thu, 05 Jun 1997 14:54:34 -0400
From: Ramon Castillo <ray@icix.net>
Subject: Re: Telnet
Message-Id: <33970B6A.E12@icix.net>

I've been using Comm.pl to telnet a box executing some commands and
works fine just like expect even I accessed a router succefully as well.


RC


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

Date: 5 Jun 1997 22:12:48 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: What can '\G' be used for in regexps ?
Message-Id: <5n7dl0$np7$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Eike Grote 
<eike.grote@theo.phy.uni-bayreuth.de>],
who wrote in article <3393DC25.41C6@theo.phy.uni-bayreuth.de>:
> but the output is
> 
>    1 - x
>    2 - x
>    3 - x
> 
> Code (Perl 5.003, IRIX):
> 
>     #!/usr/local/bin/perl -w
> 
>     $a = 'x---1a--2b--3c';
> 
>     while($a =~ /\d/g)
>     {
>         print "$& - ";
>         $a =~ /\G\w/;
>         print "$&\n";
>     }

You guessed right: Currently \G without a /g modifier is broken.  This
may be fixed some time soon, but since the usability of this
combination is questionable, the round tuits will probably go to
something else.

Ilya


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

Date: 6 Jun 1997 01:05:45 GMT
From: xran@aol.com (Xran)
Subject: Works in Shell, not as cgi
Message-Id: <19970606010500.VAA07357@ladder02.news.aol.com>

I'm trying to send input to Maple running on a UNIX Solaris machine and
want to pipe the output to a WEB page.

The Perl code below works from the Shell and returns Maple's standard
headers as well as the value of 7! - which is the input in this case.

However, when run via a cgi call from the browser, Maple's header
information gets retuned but NOT the value of 7!

I assume it's a buffering problem of some kind - but WHAT?

I've tried selecting handles and setting $| =1 on them but to no avail.
Any suggestions??? 

BTW we are using Apache if that's significant.

==================
#!/usr/local/bin/perl
require "cgi-lib.pl";
use IPC::Open2;

$|=1;
$Maple = "/usr/local/bin/maple";

$pid = open2('OUTPUT','INPUT','/usr/local/bin/maple');


print INPUT "7!;\n";




print &PrintHeader;
print "<HTML><HEAD><TITLE>TESTING</TITLE></HEAD><BODY>\n";

while (<OUTPUT>){
print "<BR>$_";
}
print "</BODY>\n";
print "</HTML>\n";



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

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

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