[6379] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 24 14:27:19 1997

Date: Mon, 24 Feb 97 11:00:23 -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           Mon, 24 Feb 1997     Volume: 8 Number: 4

Today's topics:
     Re: Appending to the start of a File? <dbenhur@egames.com>
     Re: C-style preprocessing for a newbie... <seay@absyss.fr>
     Re: CGI.pm and perl to C compiler again (Malcolm Beattie)
     Re: e5 (Russell Leach {78830})
     Re: Fixed digits of float random number? (Jan Schipmolder)
     floating point -> hex ?? <ssmith@nine.com>
     Re: forward Url (Nathan V. Patwardhan)
     Re: futur de perl et java-script <twpierce+usenet@mail.bsd.uchicago.edu>
     Re: futur de perl et java-script <seay@absyss.fr>
     Re: gdbm on AIX (Mike Heins)
     Help with Perl and Window95 <puzzled@cris.com>
     Re: Help with Perl and Window95 (Nathan V. Patwardhan)
     Re: How to override "open" function correctly (Honza Pazdziora)
     Re: html -> text <juenke@itt-sc.de>
     Re: Leading zero in print format <dbenhur@egames.com>
     Libwww, Simple.pm and env_proxy.al? @INC trouble. (Scott Meyer)
     Re: Libwww, Simple.pm and env_proxy.al? @INC trouble. <aas@bergen.sn.no>
     Links Related To comp.lang.perl.misc - FREE ACCESS links@m2c.com
     Msql (mv)
     Re: Msql (Nathan V. Patwardhan)
     Re: Multi-line processing (Nathan V. Patwardhan)
     Re: Multi-line processing (Honza Pazdziora)
     Perl and Snobol (Ben Fairbank)
     Re: Perl on Windows 95 <puzzled@cris.com>
     Re: Random Temp File in Perl 5.002 (Jot Powers)
     Re: Random Temp File in Perl 5.002 <rootbeer@teleport.com>
     Re: Regular Expression - Always seems simple/I always f <dbenhur@egames.com>
     Re: Regular Expression question <riekhof@primenet.com>
     Re: Regular Expression question <dbenhur@egames.com>
     reinstall perl <steveg@metrosol.demon.co.uk>
     Re: reinstall perl (Nathan V. Patwardhan)
     Re: split() matches, but returns no values <dbenhur@egames.com>
     Re: syntax check when embedding perl code in a (large)  <rootbeer@teleport.com>
     Re: Time-efficiency question <dbenhur@egames.com>
     Where is FAQ? <dmills@riag.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Sun, 23 Feb 1997 10:35:44 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Guy Saner <gs@iscon.demon.co.uk>
Subject: Re: Appending to the start of a File?
Message-Id: <33108E00.753B@egames.com>

Guy Saner wrote:
> On Sun, 23 Feb 1997 07:34:54 -0600, tadmc@flash.net (Tad McClellan) wrote:
> >#!/usr/bin/perl -pi.bak
> >
> >BEGIN { $x="line to add\n" }; ($x,$_)=($_,$x)
> 
> The CGI script I'm using is quite large and needs to append
> data to the front of different files. Is there a way to go without the
> "-pi.bak", so I can use it as a subroutine.

Hey Guy, at some point you have to do a little work yourself
you know.  

Break open your Camel to pg.332 and you'll see the template
which is a strict equivalent of what -pi wraps around
the one liner.  (You could have found this yourself by
checking the index for -i.)  Copy this into your program 
and insert Tad's line in the loop, wrap appropriate subroutine 
interface around the loop and viola, you have it running in 
your CGI.


--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-



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

Date: Tue, 25 Feb 1997 01:11:05 +0000
From: Douglas Seay <seay@absyss.fr>
To: Steven Kapp <skapp@kodak.com>
Subject: Re: C-style preprocessing for a newbie...
Message-Id: <33123C29.442F@absyss.fr>

Steven Kapp wrote:
> 
> Hi,
> 
>         I would like to use Perl to expand a C-style macro "IFDEBUG(x)" to
> "x".  I have looked in the FAQ and CPAN but have not found anything that
> does just this.  Also, as I am relatively new to Perl, I am not sure if
> I have found some regexp code which does this but I did not recognize
> it.
> 
>                                                         Steve
>                                                         skapp@kodak.com


why are you thinking macro?  that isn't perl-think, that is C-think.
what are you trying to gain?  the big advantages of C's macros are
that they don't use types and that they are done by the preprocessor.
perl neither has a preprocessor or a hang-up about types (within
reason).

usually that ends up

	if ( $debug )
		{ your code goes here; }

or perhaps

	&do_something() if ( $debug );

or a similar varation using using "if" or "unless".

oh yeah, RegExps are not at all the right tool for this job.  you
just want to modify the flow of control, not the value of variables.

doug seay
seay@absyss.fr


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

Date: 24 Feb 1997 17:32:25 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: CGI.pm and perl to C compiler again
Message-Id: <5esjb9$d8f@news.ox.ac.uk>

In article <330DFD41.5E8D@micron.net>,
David Runyan  <drunyan@micron.net> wrote:
>I'm trying to use Malcom Beattie's Alpha 3 compiler to create a binary
>executable on Solaris 2.5 from a perl script which contains reference
>to CGI.pm.  Followed Malcom's suggestion of using the -u switch to
>include the CGI module [ Re: Using CGI.pm with the perl to C compiler,
>to Alan Gutierrez, 1997/01/13 ] with these commands:
>
>    perl -OM=C,-uCGI,-ofoo.c foo.pl
>    perl cc_harness -O2 -ofoo foo.c
>
>This produced 10 of these warnings:
>
>    foo.c:3278: warning: initialization from incompatible pointer type
>
>Running foo caused these errors:
>
>   Undefined subroutine CGI::read_from _cmdline at /.../CGI.pm
>   line 499, <ERR> chunk 28.
>   Bad free() ignored, <ERR> chunk 28.
>   Bad free() ignored, <ERR> chunk 28.
>      <same error repeated 200+ times>
>   Segmentation Fault (core dump)
>
>Has anyone been successful at compiling perl to C with CGI.pm?
>Any idea what I may be missing?

Does CGI.pm use the AutoLoader or some other similar trick based
on AUTOLOAD? If so, you'll probably have to tickle the subs into
loading themselves at compile-time somehow. For subs which can be
safely called at any time, adding in a BEGIN { } section to your
program which calls them (and thus persuades AutoLoader or other
AUTOLOAD-user to load them in) *may* do the trick. The AutoLoader
and other AUTOLOAD tricks really do run counter to the whole idea
of compiling.

>Please also reply via email.  Haven't had time to be as faithful to
>this news group as I would like.

Sorry, that's a bit difficult at the moment.

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee


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

Date: 24 Feb 1997 18:12:03 GMT
From: rfl@localhost.enet.dec.com (Russell Leach {78830})
Subject: Re: e5
Message-Id: <5esllj$80u@swlab1.msd.ray.com>


Hit!

You sunk my battleship!


-- 
-----------------------------------------------------
"Don't anthropomorphize computers.  They hate that."
-----------------------------------------------------
*  Russ Leach  * awhfy@tiac.net * rfl@swl.msd.ray.com




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

Date: 24 Feb 1997 17:16:26 GMT
From: schip@lmsc.lockheed.com (Jan Schipmolder)
Subject: Re: Fixed digits of float random number?
Message-Id: <5esida$4on@butch.lmsc.lockheed.com>

Alex Kulbe (s_akulbe@rzw4.rz.uni-ulm.de) wrote:
: Hello,
: 
: I'am looking for a random number generator that produces a fixed
: length of digits after the decimalpoint of a float number.

I tried this about ten times and it works for me:

perl -e 'srand($$);printf "%1.3f\n", rand()'

--
jan.b.schipmolder@lmco.com


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

Date: 24 Feb 1997 17:17:31 GMT
From: Steve Smith <ssmith@nine.com>
Subject: floating point -> hex ??
Message-Id: <5esifb$cjo@news-central.tiac.net>

I would like to represent a single precision floating-point value as
a hexidecimal number (ie 8-bit hex), but I'm not having any luck.

I've tried 
 1)  sprintf ("%x", $num)
 2)  various tries with unpack 

Is there a trick to using unpack?  It's yielding unexpected results....
Also, it only yields a 1-bit hex number for some reason....

Any thoughts or suggestions would be greatly appreciated.

Sincerely,
Steve Smith
<ssmith@nine.com>



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

Date: 24 Feb 1997 17:07:56 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: forward Url
Message-Id: <5eshtc$bam@fridge-nf0.shore.net>

Russ Verner (russ@eastland.net) wrote:
: I was looking for a cgi script that would let you forward someone to a new
: url.  

Sounds like a job for comp.infosystems.www.authoring.cgi and the
archives at http://www.dejanews.com.  This is not a Perl question - it's
a CGI question.

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


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

Date: Mon, 24 Feb 1997 17:07:52 GMT
From: Tim Pierce <twpierce+usenet@mail.bsd.uchicago.edu>
Subject: Re: futur de perl et java-script
Message-Id: <E64A94.8uE@midway.uchicago.edu>

In article <slrn5h3cve.ktu.bet@onyx.interactive.net>,
Bennett Todd <bet@nospam.interactive.net> wrote:

>On Mon, 24 Feb 1997 05:19:47 GMT, Tim Pierce <twpierce+usenet@mail.bsd.uchicago.edu> wrote:
>
>>Surely you don't define operational success as
>>``being able to communicate with Americans?''
>
>Where do you get the idea
>that english is some kind of private, secret code for communication between
>Americans?

On the net, the ``English-only'' call amounts to ``talk
American.''  Return to Tom's plea that English is the most common
language in the world.  Now look at some recent Internet
demographics to see how many sites are U.S.-based.  You don't
think that's a coincidence, do you?  English didn't become the
dominant language on the net by accident.

Tom is smarter than this, so I don't understand where the
isolationist stance came from.

>There are heirarchies dedicated to
>discussions in various languages. In fact, my news server claims to know about
>an fr.comp.lang.perl --- and posting a note in english there wouldn't be
>particularly gracious. You ought to assume that people are reading
>comp.lang.perl and not fr.comp.lang.perl iff they aren't interested in
>french-language postings.

Indeed!  You are correct: there are, in fact, hierarchies which
are expressly devoted to monolingual discussion.  ``comp'',
however, is not one of them.

You want to go start an en.* hierarchy for English Firsters, be my
guest!  In the meantime, I have missed the ``no furriners need
apply'' sign on the front door.  Had I known, I would not have
soiled your linens with my mongrel heritage.

>Use USENET effectively.

This from someone with a dorky ``nospam'' return address?  Har!
Har!

Posts in foreign languages are not likely to be of much interest
to me, but they may motivate me to learn something.  The same is
not likely to be true of English questions about MS-DOG, or NT, or
ODBC, subjects about which I know little and do not wish to know
more.  Insisting that the rest of the world cater to lazy American
interests is the stupid and rude bit here; cut it out.

-- 
Support the Hawaii Equal Rights Marriage Project: call 1-900-97-MARRY ($5/call)


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

Date: Tue, 25 Feb 1997 01:36:50 +0000
From: Douglas Seay <seay@absyss.fr>
Subject: Re: futur de perl et java-script
Message-Id: <33124232.1140@absyss.fr>

I've never met Dominique, but I'd bet that she didn't post in
english because she doesn't speak it all that well (the French
to take a foreign language, but can chose what they want and it
isn't always english).  If you understand the questions and feel
like replying, do so in the language of your choice.

I do not see "fr.comp.lang.perl" on either newsfeed that I use.
There is "fr.comp.lang" and even "fr.comp.lang.java", but I do
not see anything for perl in french.  Should the francophones
be condemned to some lingustic ghetto?

I do think it behoves all posters to use whatever language is
most understood by the readers, just to increase the chance
that someone will understand and reply.  Banning the use of
non-english language posts isn't right.


doug seay
seay@absyss.fr


PS - tchrist, I liked your polyglot posting.  It would be too
time consuming to read stuff like that all the time, but it
was entertaining.


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

Date: 24 Feb 1997 17:12:51 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: gdbm on AIX
Message-Id: <5esi6j$q7@vixen.cso.uiuc.edu>

Peter.van.der.Wekken (P.C.vanderWekken@siep.shell.com) wrote:
: Does anyone of you have problems with gdbm on AIX.
: 
: I have:
: This is perl, version 5.003 with EMBED
:         built under aix at Feb 24 1997 12:04:45
:         + suidperl security patch
: 
: Copyright 1987-1996, Larry Wall
: 
: and during 'make test' all goes fine but
: 
: lib/gdbm.......FAILED on test 5
: 

Try linking GDBM_File in statically -- all the rest of the
extensions can remain dynamic, if you wish.  This is prompted
for in the Configure script, but it is easy to edit config.sh
when you are given the chance to do so.

-- 
Regards,                                                      ___       ___
Mike Heins     [mailed and posted]  http://www.iac.net/~mikeh|_ _|____ |_ _|
                                    Internet Robotics         | ||  _ \ | |
This post reflects the              Oxford, OH  45056         | || |_) || | 
opinion of my employer.             <mikeh@iac.net>          |___|  _ <|___|
                                    513.523.7621 FAX 7501        |_| \_\   


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

Date: Mon, 24 Feb 1997 12:33:52 -0500
From: Peter Holtan <puzzled@cris.com>
Subject: Help with Perl and Window95
Message-Id: <3311D100.C01@cris.com>

Hello everyone

I hope someone could advise me as to how I can handle this problem.

When I work on a perl script I write it in a text editor, FTP it to my
site, use Netscape to check it out, debug it, FTP it again, and repeat
the process over and over; meanwhile my phone is busy for hours.

Is there a way I can view my websites in Netscape using Windows95 and
make Windows
execute a cgi script (if present) and return the results to Netscape? 
Just like being on-line but without tying up the phone.

I have the Red Hat distribution of LINUX and have lots of problems with
it, but that is
another news group and besides it doesnt offer all of the resources I
already have
available in Windows95.  Unless, is there a way to quickly switch
between LINUX and
Windows95?

Oh, by the way I am looking for users groups or clubs in the
Philadelphia area for website programmers, cgi programmers and linux
users.

Thank you,
Peter Holtan
puzzled@cris.com


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

Date: 24 Feb 1997 18:00:28 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Help with Perl and Window95
Message-Id: <5eskvs$ed7@fridge-nf0.shore.net>

Peter Holtan (puzzled@cris.com) wrote:

: Is there a way I can view my websites in Netscape using Windows95 and
: make Windows execute a cgi script (if present) and return the results 
: to Netscape? 

You'll have to:
(1) install a server and run it locally (get omnihttpd).
(2) re-direct any further questions not-related-to-the-Perl-language
    to appropriate newsgroups.

Hope this helps!

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


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

Date: Mon, 24 Feb 1997 17:52:03 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: How to override "open" function correctly
Message-Id: <adelton.856806723@aisa.fi.muni.cz>

Cedar Milazzo <cedar.w.milazzo@boeing.com> writes:

> Can anyone tell me how to override the "open()" function correctly?
> I'd like to have a function called open which prepends a path to a 
> filename, then calls the regular open with the new filename.  I have the
> function which prepends the path defined as open now, but I can't make
> the second part (calling the builtin open) work.  Any ideas?

Camel book page 289 says that the original versions of the built-in
functions are always accessible via the CORE pseudopackage (eg.
CORE::chdir()).

Hope this is it.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Mon, 24 Feb 1997 18:00:58 +0100
From: Manfred Juenke <juenke@itt-sc.de>
Subject: Re: html -> text
Message-Id: <3311C94A.FDE@itt-sc.de>

LWP could be my friend if HTML::FormatText would support tables!


-- 
Dipl.-Ing. Manfred Juenke
http://www.itt-sc.de | mailto:juenke@itt-sc.de
Tel: +49 761 5172853 | ITT Intermetall
Fax: +49 761 5172880 | Hans-Bunte-Str. 19, D-79108 Freiburg


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

Date: Sun, 23 Feb 1997 20:12:13 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Michael Sadd <sadd@msc.cornell.edu>
Subject: Re: Leading zero in print format
Message-Id: <3311151D.6869@egames.com>

Michael Sadd wrote:
> Did you get any responses explaining how best to do this?
> I suppose one could strip off the zero with s//, but one
> would think there would be a format for what you want...
> 
> $temp=sprintf "%.3f\n",0.2345;
> $temp =~ s/0(\.\d+)$/$1/;

careful.  Your substitution will turn 10.234 into 1.234
Perhaps not what you expected?

try:     s/^0(\.\d+)$/$1/;
or just: s/^0\././;
or if you want to allow for negative values: 
         s/^(-?)0\./$1./;

--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-




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

Date: Mon, 24 Feb 1997 18:44:51 +0100
From: Meyer@algonet.se (Scott Meyer)
Subject: Libwww, Simple.pm and env_proxy.al? @INC trouble.
Message-Id: <Meyer-ya02408000R2402971844510001@news.algonet.se>

I'm getting an error message I don't understand when
I try to use the the Libwww-perl collection of Perl modules 
that I've installed in my home directory.

I'm trying to get a webpage using LWP::Simple
with these lines:

  #!/usr/local/bin/perl

  use lib "/home/meyer/public_html/cgi-bin/lib";
  use LWP::Simple;
  $content = get("http://www.sn.no/");
  print "$content";
  exit;

This is the message I get when compilation fails:

   Can't locate auto/LWP/UserAgent/env_proxy.al in @INC at /home/meyer/public
   _html/cgi-bin/lib/LWP/Simple.pm line 158
   BEGIN failed--compilation aborted at simple_test.pl line 4.

There is no directory named auto or file named env_proxy.al in
the distributed modules. Neither are they mentioned in Simple.pm
, so what makes perl look for them?

Does this mean that there is something wrong with the way the modules
were installed?

Best regards,
Scott, perl beginner.


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

Date: 24 Feb 1997 19:12:57 +0100
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: Libwww, Simple.pm and env_proxy.al? @INC trouble.
Message-Id: <h67zijcnq.fsf@bergen.sn.no>

Meyer@algonet.se (Scott Meyer) writes:

> This is the message I get when compilation fails:
> 
>    Can't locate auto/LWP/UserAgent/env_proxy.al in @INC at /home/meyer/public
>    _html/cgi-bin/lib/LWP/Simple.pm line 158
>    BEGIN failed--compilation aborted at simple_test.pl line 4.
> 
> There is no directory named auto or file named env_proxy.al in
> the distributed modules. Neither are they mentioned in Simple.pm
> , so what makes perl look for them?
> 
> Does this mean that there is something wrong with the way the modules
> were installed?

Yes.  You should install the library by running the command 'make install'.
It will generate and install all *.al files for you.

-- 
Gisle Aas <aas@sn.no>


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

Date: Mon, 24 Feb 97 15:32:37 GMT
From: links@m2c.com
Subject: Links Related To comp.lang.perl.misc - FREE ACCESS
Message-Id: <5esc2l$6e6@paraguay.earthlink.net>

For Free Access To Links Related To comp.lang.perl.misc Set Your Web Browser 
To:

http://www.m2c.com/links/compute.htm

Courtesy Of Surfing Links By M2C

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

Sponsored by Robo Surfer - Your Own Personal Internet Robot

Download Your Free Demo Today!
http://www.robosurfer.com


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

Date: 24 Feb 1997 17:10:57 GMT
From: nobody@nowhere.com (mv)
Subject: Msql
Message-Id: <nobody-2402971209250001@pa1dsp19.rsw.infi.net>

Can someone tell me where I can get "Msql" to use with MacPerl?
please email me.
Thanks!!

montyvan@swfla.infi.net


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

Date: 24 Feb 1997 17:32:26 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Msql
Message-Id: <5esjba$bam@fridge-nf0.shore.net>

mv (nobody@nowhere.com) wrote:
: Can someone tell me where I can get "Msql" to use with MacPerl?
: please email me.

I didn't know there was a port of Msql for Macs.  :-)
Check: http://hughes.com.au.  You might also check out mysql.

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


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

Date: 24 Feb 1997 17:30:22 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Multi-line processing
Message-Id: <5esj7e$bam@fridge-nf0.shore.net>

Daniel Mills (dmills@riag.com) wrote:
: How would I set up the following example to strip out all comments from
: a C program including those that extend over multiple lines of the input?
: I can't seem to make /m modifier work.

There are some excellent examples in the clpm archives at
http://www.dejanews.com.

You might also check out section 4.27 of the FAQ, which reads "4.27) How do 
I use a regular expression to strip C style comments from a file?" :-)

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


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

Date: Mon, 24 Feb 1997 17:39:27 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Multi-line processing
Message-Id: <adelton.856805967@aisa.fi.muni.cz>

Daniel Mills <dmills@riag.com> writes:

> Hello,
> How would I set up the following example to strip out all comments from
> a C program including those that extend over multiple lines of the input?
> I can't seem to make /m modifier work.
> 
> open(FILEIN,'program.c');
> while(<FILEIN>){
> 	if(/(\*)(.*?)(\*)/){
> 		$comment_buf = $2;
> 	}
> }

This is answered in Perl FAQ 4.27.

But few comments to your example: You need to set the input record
separator to nothing (undef actually). In the example as written
above the <FILEIN> operator reads the file line by line.
Try putting undef $/; before you read the file. Then you do not need
the while loop.

Also, ///s modifier would be better here, since you only need
perl to match \n via . (dot). And, the if statement will only get you
the first occurence, try the match in list context. You will also need
to change the regexp to match /* and */ but not 3 * 4 * 5: m!/\*(.*?)\*/!s.
But see the FAQ for complete solution.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 24 Feb 1997 17:10:06 GMT
From: baf@texas.net (Ben Fairbank)
Subject: Perl and Snobol
Message-Id: <5esi1e$t2b@news3.texas.net>

I have an off-list (probably not relevant enough to post) question for 
anyone who is equally at ease in Perl and Snobol.  Any takers>

Ben Fairbank
baf@texas.net



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

Date: Mon, 24 Feb 1997 12:57:06 -0500
From: Peter Holtan <puzzled@cris.com>
Subject: Re: Perl on Windows 95
Message-Id: <3311D671.4B9A@cris.com>

Hank,

I have the same question as Mark did.  Please excuse me if my question
sounds stupid, but I am very new to this.  Where can I get a server? Is
there a good one that you would suggest that I could download for free? 
I hope I could get a server for Windows95, I have LINUX but I have too
many problems with it and X runs so damn slow.

Thank you,
Peter Holtan
puzzled@cris.com


Hank LeMieux wrote:
> 
> Mark,
> 
> You wrote,
> > I would like to also see how it works by loading the page into Netscape
> > locally and then running the script (like it would on a server).  Is
> > this possible.  When I tried clicking on the button that calls the
> > script nothing happened.
> 
> Well, here are two options:
> 
> 1)Use Netscape's File|Open command to directly open the script.  When
> netscape says it doesn't know what to do with the file, tell it to open
> it with the script interpreter (ie: if you're using perl, tell it to use
> perl.exe as the helper.) All this will do is have Netscape open the perl
> command window and run the script every time you open a .pl file. This
> won't emulate what the script will do on the server.
> 
> 2) Install a server on your machine and run it locally.  That's how I
> test my scripts.
> 
> Hank
> --
> 
> Hank LeMieux
> Freelance Web Design/JavaScript/CGI
> Santa Fe, NM, USA
> (505) 986-8166
> http://members.aol.com/HankW


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

Date: 24 Feb 1997 16:48:21 GMT
From: jot.mar97@tmp.medtronic.com (Jot Powers)
Subject: Re: Random Temp File in Perl 5.002
Message-Id: <5esgol$eca@gazette.medtronic.com>

In article <33109eb7.3091020@news.alt.net>, mwt@cyberg8t.com (Mark Thompson) writes:
>Hi,
>
>I need to make a random temporary file, sortof like tmpnam() in C.
>Does Perl offer this functionality?  If not, any suggestions on how to
>implement something like this?

If you are on a posix compliant system, try:

use POSIX;

$tempfile = POSIX::tmpnam();

And away you go.

(main::(-e:1):   1
  DB<1> use POSIX
 
  DB<2> $tempfile = POSIX::tmpnam();
 
  DB<3> p $tempfile
/var/tmp/aaaa003nS
)
-- 
Jot Powers  jot.mar97@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: Mon, 24 Feb 1997 10:27:18 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Tad McClellan <tadmc@flash.net>
Subject: Re: Random Temp File in Perl 5.002
Message-Id: <Pine.GSO.3.95q.970224102643.22067H-100000@kelly.teleport.com>

On Sun, 23 Feb 1997, Tad McClellan wrote:

> for ($num=0; -e "/tmp/file.$num"; $num++) {}

This seems very vulnerable to a concurrency problem. Why not include $$ in
there somewhere?

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sun, 23 Feb 1997 11:04:28 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Laurel Shimer <autopen@quake.net>
Subject: Re: Regular Expression - Always seems simple/I always fight 'em
Message-Id: <331094BC.64D@egames.com>

Laurel Shimer wrote:
> Note: I should have been more explicit about my desires - I wanted to be
> sure that the value I was checking was entirely numeric. This is made
> ------------------------ Regexp methods that work ------
[snip]
> print "METHOD 2 \n";
> if (($checkit =~  /^\D+$/)) { print "$checkit is not a digit \n"}
> else { print "$checkit is a digit\n"; }

This one isn't correct, Laurel.

Think about what it says if $checkit = "abc4xyz"

The expression you want using \D is:
  print "not a number" if ($checkit =~ /\D/); # if any non-digits found

--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-



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

Date: 24 Feb 1997 11:13:01 -0700
From: Darrel Riekhof <riekhof@primenet.com>
Subject: Re: Regular Expression question
Message-Id: <3311E69B.231D@primenet.com>

Thanks for the help.

> There is your problem. If $_='';, then it would _still_ match.
snip
> Perl doesn't really match the longest possible string (maybe Jeffrey
> will jump in here?).

This seems inconsistent.  I tested it on (a)* and (a*), and each one
returned 'a' in $1.  I would have thought (a*) would match '' the
last time.

Then I tried (a*)* and $1 had ''.  Finally I tried (a)** and got a
nesting error.

Is there a source that explicitly states how perl5 behaves in these
situations?  IMO, the most logical behavior would be for any 
expression inside parens with a global asterisk, (<expr>*), to return
'' in its backref.  But, this is not the behavior for (a*).  It only
seems to be the case for (((<expr>)(<expr>)...)*)

-- 
Darrel Riekhof
CONNECT! Corporation
Visit http://www.connectcorp.com
darrel.riekhof@connectcorp.com


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

Date: Sun, 23 Feb 1997 16:27:52 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: riekhof@primenet.com
Subject: Re: Regular Expression question
Message-Id: <3310E088.40CD@egames.com>

Darrel Riekhof wrote:
> What is the correct output for
> ((a*)(b*))* Input: abbbababb?
> 
> I recently installed the win32 perl5 package and am unsure if
> it's giving me correct output.  It matches the above, but says
> $1, $2, and $3 are all empty.  Here's the perl code I used to
> test it (I'm a newbie Perl programmer, as you can tell from
> this code):
> 
>    $_=abbbababb;
>    if (/((a*)(b*))*/) {
[snip]
> 
> Seems to me like $1 should have "abbbababb", $2 "a", and $3 "bb"
> if it's doing a maximal match.  Could someone explain what's
> going on?

  * means ZERO or more.  The quickest and easiest match for
a pat* regexp is the null string.  That's what you got.
Try using + for ONE or more.  See this example:

   $_="abbbababb";
   if (/(((a+)(b+))+)/) {
      print "Matched: _='$_', 1='$1', 2='$2', 3='$3', 4='$4'\n";
   }

which prints:
Matched: _='abbbababb', 1='abbbababb', 2='abb', 3='a', 4='bb'

Note that I added an extra pair of parens to surround the
final +.  $2 got the final match of ((a+)(b+)), $1 got the 
whole thing

HTH
--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-



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

Date: Mon, 24 Feb 1997 17:16:18 +0000
From: Steve Gailey <steveg@metrosol.demon.co.uk>
Subject: reinstall perl
Message-Id: <3311CCE2.1A07@metrosol.demon.co.uk>

Is it possible to recompile perl and reinstall it without disturbing the
existing
CPAN modules which are installed. IE can I rebuild the core modules and
reinstall them?

Steve
    
------------------------------------------------------------------------
     Steve.Gailey@nomura.co.uk                    Nomura
London              
    
------------------------------------------------------------------------
     The views expressed herein do not necessarily reflect the views of
Nomura  
     International plc and cannot be relied upon by any other party.
Nomura     
     International plc is a member of the London Stock Exchange and is 
     regulated by The Securitites and Futures Authority
    
----------------------------------------------------------------------


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

Date: 24 Feb 1997 17:33:59 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: reinstall perl
Message-Id: <5esje7$bam@fridge-nf0.shore.net>

Steve Gailey (steveg@metrosol.demon.co.uk) wrote:
: Is it possible to recompile perl and reinstall it without disturbing the
: existing

I'd suggest installing CPAN.pm and taking it from there.  It'll give you
a whole, new perspective on CPANs and Perl.  :-)  It was like listening
to Black Sabbath and seeing God at the same time - woah!

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


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

Date: Sun, 23 Feb 1997 15:36:35 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Daniel Macks <dmacks@netspace.org>
Subject: Re: split() matches, but returns no values
Message-Id: <3310D483.39F3@egames.com>

Bill Cowan wrote:
> Daniel Macks wrote:
> > Example (perl 5.002)
> >   @foo = split( ':', 'this:one:seems:normal' ));
> >   @bar = split( ':', ':::fine' ));
> >   @ack = split( ':', ':::' ));
> > gives
> >   @foo = ( 'this', 'one', 'seems', 'normal' );
> >   @bar = ( undef, undef, undef, 'fine' );
> >   @ack = ();
> > Why doesn't @ack=(undef,undef,undef,undef)?
> > The number of fields varies (and could be zero) so I can't think of a
> > simple way to just define an all-undef array of the correct length.
> > Any elegant ways to get all the undefs?
> You may need to have special case logic for this (or when you have
> trailing empty fields).  Probably based on "if scalar(@ack) == ...".

Bill's explanation of why you don't get all the fields (split
without LIMIT trims trailing null fields) is correct.

Here's two simple solutions to get all the fields without 
knowing how many there are ahead of time:
  @res = split(/:/, $str . ':x');	# add some junk to end
  pop @res;	# throwaway the last field

this might be faster:
  @res = split(/:/, $str, ($str=~tr/://)+1 );

HTH
--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-




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

Date: Mon, 24 Feb 1997 10:47:42 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jim Fondren <nomail@imaji.net>
Subject: Re: syntax check when embedding perl code in a (large) here document
Message-Id: <Pine.GSO.3.95q.970224103141.22067I-100000@kelly.teleport.com>

On Sun, 23 Feb 1997, Jim Fondren wrote:

> I've learned to use the expression: 
> 
>    @{[$any_perl_expression_returning_a_scalar]}
> 
> inside of large here documents to avoid the clumsy necessity of
> closing and re-opening the here document. 

That's a useful construct. But did you realize that the expression inside
is evaluated in a list context? Nothing wrong with that, if that's what
you want. (You can return a list of items, and they'll normally be
included, separated by spaces, in the string.) If you would prefer a
scalar context (and since you mentioned a scalar, I suspect that you
might) this works.

    ${ \ some_scalar_expression }

Since backslash has fairly high precedence, it's normal to require
parentheses around the expression.

    "The value of pi is ${ \ ( 4 * atan2(1,1) ) }\n"

> A problem I've noticed on those rare occasions when I maek a typo is
> that the perl interpreter won't be able to call out the physical line
> of a syntax error in the file if the error is embedded in the here
> document.  The line indicated is the line using the <<"FOO" syntax.

This is a problem which (as I understand things) is one which the perl
maintainers would like to fix, but haven't gotten around to doing, and
aren't likely to fix any time soon. Dang. By the time Perl has caught the
error, there's no easy way to find out what line had the original code,
except perhaps vaguely ("between lines 11 and 19"). 

On the other hand, it's not too hard to debug these. If nothing else,
backwhack all of the embedded $ and @ signs but one, and use 'perl -c' to
see what it tells you. Hope this helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sun, 23 Feb 1997 15:58:56 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Sara Young <syoung@actcom.co.il>
Subject: Re: Time-efficiency question
Message-Id: <3310D9C0.79DB@egames.com>

Sara Young wrote:
> The question is this: what is the most time-efficient way to do this?

This question is almost always best answered by coding both
techniques and using Benchmark.pm to see how fast the
alternatives are

> 2. open(FILE, $file);
>    @fileLines = <FILE>;
>    $fileString = join(" ",@fileLines);
>    $fileString =~ s/<!-- data1 here -->/something/;
>    $fileString =~ s/<!-- data2 here -->/something else/;
>    print "$fileString";
> 
> I have a feeling that #2 is faster, but I don't know how costly the join
> is, and how costly it is to do a substitution on a long string.

You can avoid the join altogether, change the two lines after
the open to:

{  local $/ = undef;   # undefine input_record_seperator
   $fileString = <FILE>;	#shlurp up the whole file
}

Oh, and you should use a g suffix on your s/// ops if they
can occur more than once in a file.

Oh, and always,always,always check for the success of your
open call:  open(...) or die(...);

If you have a lot of these kinds of substitutions, you might
want to set up a table driven mechanism to do your replaces instead
of a long string of s/// statements:

%subst_table = (
   name1 => 'replace1',
   name2 => 'replace2',
   ...
   nameN => 'replaceN',
);

$fileString =~ s/<!-- subst=(\w+) -->/$subst_table{$1}/ge;

(this pattern expects 'subst=' before the name of the string
to be substituted to avoid catching normal HTML comments)

HTH
--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-



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

Date: Mon, 24 Feb 1997 13:11:23 -0800
From: Daniel Mills <dmills@riag.com>
Subject: Where is FAQ?
Message-Id: <331203FB.479@riag.com>

I'm new to the group and would like to know how to get to the FAQ

Thanks.
Dan.
-- 
------------------------------------------------
The opinions expressed here are those of the author only.
------------------------------------------------


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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

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