[9646] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3240 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 24 01:07:11 1998

Date: Thu, 23 Jul 98 22:00:21 -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, 23 Jul 1998     Volume: 8 Number: 3240

Today's topics:
    Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos <TerryLCora@worldnet.att.net>
    Re: changing default shell for system() <zenin@bawdycaste.org>
    Re: Converting complex hash's to a comperable SQL objec (Martien Verbruggen)
    Re: Database help for newbie <TerryLCora@worldnet.att.net>
        delete fiel after a certain date (Anthony Luke Nelson)
    Re: Expanding $1 in a variable substitution (Tad McClellan)
        GMTIME darrensw@pacbell.net
    Re: HELP - MS personal web server and cgi (nobody)
        how do you extract information from a cgi page? <domv@addme.com>
    Re: Is Perl Year 1999 Compliant??? (Andre L.)
    Re: Is Perl Year 1999 Compliant??? (Ilya Zakharevich)
    Re: Javascript History -1 (Need the Perl equivalent) <jon@unknown.com>
    Re: modifying a text file (Martien Verbruggen)
        Net::Telnet <hbmus009@csun.edu>
        newbie Q2: do 'script.pl?parm1=xxxx'; <joe@halbrook.com>
        newbie Q: self-calling script? <joe@halbrook.com>
    Re: parsing question (Martien Verbruggen)
    Re: parsing question <uri@sysarch.com>
    Re: Perl Beautifier Home Page (Sam Holden)
    Re: Perl Beautifier Home Page (Kenneth Herron)
        Question: Oraperl on Windows NT? (I-Fei Tsai)
    Re: Returning values from a child process (Andrew M. Langmead)
    Re: sprintf and decimals (Martien Verbruggen)
    Re: sprintf and decimals (Larry Rosler)
        substitution code query - how much can it really do? <elssa09@nospam.callisto.si.usherb.ca>
        threads in perl <arolfe@genome.wi.mit.edu>
    Re: Using 2 d Arrays in Perl 4 (Mike Stok)
    Re: using s/// (Tad McClellan)
        What's the most efficient regex to force NOT matching a <mmoreno@cas.org>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 23 Jul 1998 22:35:52 -0400
From: "Terry Cora" <TerryLCora@worldnet.att.net>
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <6p8ru0$skv@bgtnsc03.worldnet.att.net>

Great mini-FAQ, sorry for my off tipic post.

gnat@frii.com wrote in message ...
<snip>
>
>9. The latest version of the "Camel Book" ("Programming Perl"),
>updated for version 5.003, is available from your bookstore or from
>http://www.ora.com/

Great book!! BTW you can save $7.99 off the $39.95 cover price and help
support a great free cgi mail list that specializes in Perl by ordering it,
or several other programming books through http://www.jann.com/Perl/ (use
the link to go to Amazon.com and order from there - must use the above link
in order to help support the list though).

>
>10. Remember, USENET newsgroups are based on the idea of mutual aid.
>USENET only works if we put as much into it as we get out of it.  Good
>luck with your Perl work.


Hopefully, I have given some other newbies an extra $8.00 to spend toward
paying someone to make their scripts correct.

>-Nathan Torkington, Perl mini-FAQ maintainer
>--




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

Date: 24 Jul 1998 01:28:15 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: changing default shell for system()
Message-Id: <901244290.14654@thrush.omix.com>

Alexandros Labrinidis <labrinid@cs.umd.edu> wrote:
:  I'd like to change the shell that system() spawns to execute its
: arguments. For some reason, although $ENV{'SHELL'} is tcsh, perl
: sticks with sh for system(). Any ideas? 

	You'd do well to stick with sh; csh has some major limitations
	for programming use that can not be overcome.  But, of course,
	as always TMTOWTDI:

	system ("csh -c 'commands'");

	May I ask why you wish to call csh vs sh?  I'd be extremely
	supprised if there wasn't a better way to do it with sh.
-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 24 Jul 1998 03:41:36 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Converting complex hash's to a comperable SQL object database in Perl?
Message-Id: <6p8vpg$1jo$3@nswpull.telstra.net>

[changed newsgroups
	alt.perl dud, removed
	compl.lang.perl.modules wrong, removed
	bit.listserv.sqlinfo offtopic, removed
	microsoft.public.sqlserver.programming won't post to ms groups
]

In article <35B7A801.AB40F1E9@geocities.com>,
	Catherine Lynn Smith <k-lynn@geocities.com> writes:
> 
> --------------51D6BFB7CFAD54F70FE1C721
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit

Please don't do that. Usenet is a plain text medium.

> Some months ago, I asked this question and someone referred me to a
> mailing list that had not yet had it's digest updated.  Now I can't find
> that URL to save itself.

what? never mind.

> Seeing the advantages of various SQL's, I would be interested in
> converting these to utilize an SQL server instead.  I was just a wee bit

I suppose you mean a relational database server?

> frustrated, however, when I noted (at least from my observations) that
> most of the stuff that is written under perl does little more than pass
> commands to the SQL.  I was wondering if there were any recommended
> mechanisms to allow perl hashes (say with 'tie') to directly manipulate

A hash only keeps key-value combinations. A relational database does
much much more. You cannot use a hash to access a complete relational
database. That is why SQL exists.

> various object database properties in something like PostgreSQL, MySQL
> or mSQL?

object database properties?

> Please respond via email as well as I do not get back to this newsgroup

'this' newsgroup? You attempted to post to five, probably got through
to 4. Your message has the same crap three times, or something like
that. text, which is good, HTML, which is evil, and some crappy jpg,
which is positively horrible. Your post might qualify as the dimmest,
most clueless attempt at Usenet for this year.

forget it. no email

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Thu, 23 Jul 1998 21:49:22 -0400
From: "Terry Cora" <TerryLCora@worldnet.att.net>
Subject: Re: Database help for newbie
Message-Id: <6p8p6q$bvq@bgtnsc03.worldnet.att.net>

http://www.cgi-resources.com/Programs_and_Scripts/Perl/Database_Manipulation
/

There are 20 different database management scripts to choose from



Kent Wang wrote in message <35B78D99.BEE7C4FE@biogate.com>...
>i would like to somehow manage a text database, that i can add to,
>delete entries, and edit. anybody know how?
>




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

Date: Fri, 24 Jul 1998 02:16:04 GMT
From: tony.nelson@mci.com (Anthony Luke Nelson)
Subject: delete fiel after a certain date
Message-Id: <35b7ed79.14787463@news.mci2000.com>

	Does anyone have an example of how I could automate deleting
files say after three business days? We have a common share where
users exchange files but never seem to delete them. I would like to
run a batch job every night and check all files and subdirectories
that are three or more days old. If they exist, delete.
 



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

Date: Thu, 23 Jul 1998 21:00:56 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Expanding $1 in a variable substitution
Message-Id: <osp8p6.o2j.ln@localhost>

Danny van der Rijn (dannyv@tibco.com) wrote:
: Robert Seals wrote:
: > 
: > 
: > In other words, I want to refer to the matched
: > text in the replacement string.

: i think what you're looking for is
: $pat = "abcdefghijklmnop";
: $pat =~ s/abc(.*)m/\1\1\1/;
: print $pat;


   He probably _doesn't_ want that.

   It generates several warnings with -w, and good perl programmers
   use -w on their scripts  ;-)


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


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

Date: Fri, 24 Jul 1998 02:57:09 GMT
From: darrensw@pacbell.net
Subject: GMTIME
Message-Id: <35b7f79f.13698522@news.pacbell.net>

Hi all

I am trying to find a routine to allow me to parse GMTIME and then
recalculate and then rename as $GMTIME1 for example.

I have searched and searched but no luck, any ideas??

I have searched CPAN.

Thanks,

Darren		


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

Date: 24 Jul 1998 01:01:21 GMT
From: ac1@fspc.netsys.itg.telecom.com.au (nobody)
Subject: Re: HELP - MS personal web server and cgi
Message-Id: <6p8md1$eth@newsserver.trl.OZ.AU>

Dan Baker (dtbaker_@flash.net) wrote:
: but try the xitami server instead, it is small, fast, and works right
: out of the box. http://www.imatix.com/ 

Hey, I just realised Xitami is imatix spelt backwards (duh!). What's
going on here.

AC



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

Date: 24 Jul 1998 03:08:02 GMT
From: "Dom" <domv@addme.com>
Subject: how do you extract information from a cgi page?
Message-Id: <01bdb6c9$8e688c60$b28e0fce@bhvd3>

This is a multi-part message in MIME format.

------=_NextPart_000_01BDB68E.E209B460
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit


	How do you extract information from a cgi page? I want to search for words
(like a search engine) but not on an HTML page but from a page generated by
a cgi script. How do you do that with perl?

	Thanks in advance!

	Dom

	
------=_NextPart_000_01BDB68E.E209B460
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<html><head></head><BODY bgcolor=3D"#FFFFFF"><p><font size=3D2 =
color=3D"#000000" face=3D"Arial"><br>&#009;H<font size=3D1 face=3D"MS =
Sans Serif">ow do you extract information from a cgi page? I want to =
search for words (like a search engine) but not on an HTML page but from =
a page generated by a cgi script. How do you do that with =
perl?<br><br>&#009;Thanks in =
advance!<br><br>&#009;Dom<br><br>&#009;<font size=3D2 =
face=3D"Arial"><br></p>
</font></font></font></body></html>
------=_NextPart_000_01BDB68E.E209B460--



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

Date: Thu, 23 Jul 1998 23:07:32 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Is Perl Year 1999 Compliant???
Message-Id: <alecler-2307982307320001@dialup-869.hip.cam.org>

In article <6p7tm7$cf4@canyon.sr.hp.com>, John_Cavanaugh@NOSPAM.hp.com wrote:

> Am I the only one on the planet terribly concerned about year 1999
> compliance. Doest every company have a group working on this.

You're joking, but actually there is a potential Year 1999 problem. Think
of those databases out there that have records with "99" put in as a bogus
value for "year unknown".

A.L.


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

Date: 24 Jul 1998 04:18:31 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Is Perl Year 1999 Compliant???
Message-Id: <6p91un$hj4$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to 
<John_Cavanaugh@NOSPAM.hp.com>],
who wrote in article <6p7tm7$cf4@canyon.sr.hp.com>:
> 
> Am I the only one on the planet terribly concerned about year 1999
> compliance. Doest every company have a group working on this.

We on perl5-porters are frantically working to release perl5.005,
which is supposed to be year-1998-compliant.  While not all the hope
is lost yet, so far no convincing result is in view.

I would not expect year-1999-compliant perl earlier than in 7
quarters.  This feature is planned for release 5.007 (1999 Q2), but
the continuing slippage of 5.005 may cause interdepartment rivalty to
shutdown Perl development completely.  The "Merl" group is pressing
hard to switch the resources to development of its "Multihost"
scripting architecture.  The loss of "Bronze Felix" did already
shutter the fragile balance of forces in this battle...

Sorry for a bad news,
Ilya


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

Date: Thu, 23 Jul 1998 17:33:39 +0100
From: "Jon" <jon@unknown.com>
Subject: Re: Javascript History -1 (Need the Perl equivalent)
Message-Id: <6p7od4$jc87@mascagni.pfizer.com>

<no_perl_relevance>


I think this is probably what you are looking for ...

$ENV{'HTTP_REFERER'}

this is the environment variable containing the URL of the page from which
the script was "run"

OR
What you could also do is pass the javascript variable document.location to
the cgi script as a
parameter e.g. in your Javascript in the HTML page
document.write("<img src=\"whatever.cgi?document.location\">");
a bit messier ...


</no_perl_relevance>


Hope this helps,

Jon
 *** he who be of no kewl tagline ***

swhite@accessonline.com wrote in message
<35aeafcc.3726642@news.sprint.ca>...
>Hi,
>
>How do I read the name of the HTML file that I used to call the perl
>script?
>I need a function like the javascript history -1 that I can call in
>Perl.
>
>Thanks alot everyone.
>
>Stephen




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

Date: 24 Jul 1998 03:46:03 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: modifying a text file
Message-Id: <6p901r$1jo$4@nswpull.telstra.net>

In article <6p8fok$ov2$1@vixen.cso.uiuc.edu>,
	Bob Shair (courtesy) <rmshair@delphi.itg.uiuc.edu> writes:
> melspace@my-dejanews.com wrote:
>> I am trying to figure out how to replace one line in a text file.  I have
>> read perlfaq5, but I am still puzzled.	
> 
> 
> Assuming that you want to replace a line, other than the last,
> I suspect that you may be out of luck.  I haven't found a way
> to do that without truncating the file at that point.
> 
> That's to say if your goal is:
> Before				After
> AAA				AAA
> BBB				BBB
> CCC				CCCnew
> DDD				DDD
> 
> I'm as stumped as you... after writing CCCnew, line DDD vanishes.

It actually doesn't. It gets overwritten. Files are just a string of
bytes.

Have _you_ read perlfaq5?

# perldoc perlfaq5
     How do I change one line in a file/delete a line in a
     file/insert a line in the middle of a file/append to the
     beginning of a file?

It explains where your way of thinking goes wrong.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Fri, 24 Jul 1998 11:11:18 -0700
From: Christopher Johnson <hbmus009@csun.edu>
Subject: Net::Telnet
Message-Id: <901304456.2038600664@news.csun.edu>

I'm trying to make a perl mud client, but I'm haveing a difficult time in
getting Net::Telnet to behave.

Here is the code that reads the text coming from the server...

	use Net::Telnet();
	$session = new Net::Telnet();
	$session->open(Host => $hostname, Port => $port);

	while (1)
		{
		$ch = $session->get;
		print($ch);
		}

Now, the get method is supposed to read a character at a time from the
stream. And it does, however the input stream from the telnet session seems to
be line buffered.  So 'get' doesn't return anything until the server sends a
newline character.  This is a problem because there are various prompts.

i.e.

	10H 10M 10M>

doesn't show up until after I enter a command to the server.  If anyone can
tell me what I'm doing wrong, it'd be much appreciated.

Thank you,
Chris Johnson



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

Date: Thu, 23 Jul 1998 19:33:34 -0500
From: Joe Halbrook <joe@halbrook.com>
Subject: newbie Q2: do 'script.pl?parm1=xxxx';
Message-Id: <35B7D65E.1B47766@halbrook.com>

I need to call another script using "do 'xxx.pl';" only passing parms. 
Any ideas?


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

Date: Thu, 23 Jul 1998 19:27:11 -0500
From: Joe Halbrook <joe@halbrook.com>
Subject: newbie Q: self-calling script?
Message-Id: <35B7D4DF.77BB4E0F@halbrook.com>

Can anyone point mein the right direction?  

I have a mulit-purpose script that I'd like to perform a do
'same-script'  or  use the 'eval' function to pass a different ACTION
parm to itself and follow a different execution path.  Is this possible?

Any ideas would be greatly appreciated.

Thanks.


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

Date: 24 Jul 1998 03:30:28 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: parsing question
Message-Id: <6p8v4k$1jo$1@nswpull.telstra.net>

In article <6p8d3s$ig4$1@heliodor.xara.net>,
	"Martin" <minich@globalnet.co.uk> writes:
>>1. you didn't check the return value of open().
>>   you must *always* do that.  No but's.

> I was in a rush; what can I say? IRL, I always do that but I
> was trying to do this and must have overlooked it. Honest <g>

Like he said: 'no buts' :)

>>4. you already did a split( /=/, $_, 2 ) when you did a
>> if ( /=/ ) so use the results, rather than splitting again.
> 
> OK, so I should have used $' and $`

I wouldn't agree that fast. Use of $', $` and $& slows your program
down, for every regexp used. I would probably not use them.

Either use brackets and $1 $2, or do the split first, and check the
number of results.

> 
>>5. superfluous quoting:
>>>     $firstline = "$indata";
> 
> I always do that incase indata contains a semicolon.

So? That doesn't break anything. Watch:

# perl -e '$a = "foo;bar"; $b = $a; print $b, "\n"'
foo;bar

see?

The contents of a scalar don't get evaluated, unless you specifically
ask for it. It would be very messy if it was otherwise.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 24 Jul 1998 00:03:13 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: parsing question
Message-Id: <x7pvevlwu6.fsf@sysarch.com>

>>>>> "M" == Martin  <minich@globalnet.co.uk> writes:

  >> 3. bizarre mixing of $_ and $indata.  $_ was sufficient for
  >> the task.


  M> I always name strings and arrays identical in foreach loops -
  M> I get confused easily <g>

this is an ok philosophy (i use it) but you still went about coding it
poorly. see below.

  >> 4. you already did a split( /=/, $_, 2 ) when you did a
  >> if ( /=/ ) so use the results, rather than splitting again.


  M> OK, so I should have used $' and $`

  >> 5. superfluous quoting:
  >>> $firstline = "$indata";


  M> I always do that incase indata contains a semicolon.

  >> In summary:
  >> 
  >> my $filename = "myfile.dat";
  >> open INF, "< $filename" or die "open $filename: $!";

< is unnecessary as files open for reading by default. and it is safer
to call open as a function so precedence problems don't crop up

open( INF, $filename) || die "open $filename: $!";

  >> my $firstline;
  >> my %hash;
  >> 
  >> while (<INF>) {

since you don't want to use $_ do this

	while( defined( $firstline = <INF> ) ) {

  >> chomp;

why do yo chomp when you just match later on. a waste of cpu time.

  >> if ( /^[MTWFS]/ ) {
  >> $firstline = $_;

since you are using a var, bind it directly to the regex.

	if ( $firstline =~ /^[MTWFS]/ ) {

  >> %hash = ();
  >> }
  >> elsif ( /=/ ) {

same here

	elsif ( $firstline =~ /=/ ) {

i don't like using  $` and $' for both esthetic and efficiency reasons
see my other solution below

  >> $hash{ $` }  = $';
  >> }
  >> # &c.
  >> }
  >> 
  >> close INF;

  >> 7. One should just use $/ for this kind of thing.

  M> Obviously ?!?!?!? LOL!

also if you use $/, localize it in the sub so it won't affect any other code.

TIMTOWTDI

i like to use range expressions to parse files like this. no need to
mess with $/ and it does the parsing on the fly.
it is a very flexible  method i have used on many file formats which are
in some form of paragraph (starting and ending lines are well defined)

here is some (untested) but typical code for this type of problem

here was the example data. the timestamp line is not defined so i didn't
define it's regex


Weekday Month Day Year TimeStamp
    name = value                # note, these lines are indented with a tab
    name = "ascii value"
    name = value
                                # note: <blank line>


while( defined( $line = <INF> ) ) {

# match lines from timestamp to blank line

	if ( $line_num = $line =~ /pattern to match timestamp/ ..
	                 $line =~ /^$/ ) {

# see if this is the timestamp line

		if ( $line_num == 1 ) {

# found timestamp line, init the hash

			%hash = () ;

# process the timestamp fields

			blah blah $1 $2 ;

# parse next line
			next ;
		}

# see if this is the blank line (the range line number will have an 'E'
# in it)
		if ( $line_num =~ /E/ ) {

# process complete record

			blah blah ;

			next ;
		}

# this should be a value line, so parse it (untested regex so don't yell)
# starting tab doesn't matter. 
		if ( $line =~ /(\w+)\s*=\s*(\w+)/ ||
		     $line =~ /(\w+)\s*=\s*"([^"]+)"/ ) {

			$hash{ $1 } = $2 ;

			next ;
		}

# error, since the line didn't match anything before

		print STDERR "Bad line '$line'\n" ;

	}
}

if you use this code, you have to pay runtime royalties :-)

enjoy,

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 24 Jul 1998 03:49:04 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Beautifier Home Page
Message-Id: <slrn6rg11g.b7v.sholden@pgrad.cs.usyd.edu.au>

On Thu, 23 Jul 1998 14:16:33 GMT, John Porter <jdporter@min.net> wrote:
>Bart Lateur wrote:
>> 
>> Why not? :-) Even if you might succeed to convince me into using fixed
>> pitch fonts for code, there will still be thousands of people who still
>> write code that way. So a "general solution" that only works if you use
>> fixed pitch fonts, is not a general solution. That was my argument.
>
>Just how general does a solution have to be, to be considered a "general
>solution"?  Must we insist that all new source code files be stored as
>Unicode, and require the editors (and all the other tools) to support
>that?
>No?  Well, 99.999% of all programmers using fixed width fonts is general
>enough in my book.

Fair  enough.

I must admit though  I use tabs not spaces, my main reason is that it is really
really easy to automatically convert tabs->spaceswith, but not so easy to
convert the other way.

>
>> if I read code in a fixed
>> pitch font, like Courier, I notice that it tires me after a while. After
>> only 10 minutes, I notice that I'm starting to stare at the letters. I
>> must really concentrate to simply see what is written there. Besides,
>> Courier is just a damn ugly. :-)
>
>Uh, no arguments from me about Courier.  But I did not miss your subtle
>elision: "fixed pitch font, like Courier", so all your arguments against
>Courier apply implicitly to all fixed pitch fonts.  And of course, that
>just ain't so.  I don't use Courier.  But I do use a fixed pitch font.
>And it isn't ugly, and doesn't tire my eyes.
>
>
>> So, the reason to use a variable pitch font, is the same reason why
>> there are no books printed in a fixed pitch font either: variable pitch
>> is simply far easier to read. Code is just text, anyway. 
>
>No, not quite.
>When I'm programming in Lisp, I want to able to see the parens.  In
>every
>(or nearly every(?)) variable width font, parentheses are wisps of hints 
>of marks.  Commas need to be immediately distinguishable from periods.  
>The same principle pertains to all punctuation marks.  
>And it applies for all languages, not just Lisp.  
>
>In programming, spacing of characters is utterly unimportant.
>The compiler doesn't see it; why should I see it any differently from
>the
>compiler?  Also, some variable-width fonts seem to be ambivalent about
>the difference between a backtick and a single quote.

But all of that is arguing  over the font. As you said about Courier not
applying to all fixed fonts, so 'some variable-width fonts' doesn't apply
to all variable widthfonts...

The variable width font I use makes it easy to tell periods and commas apart,
easy to distinguish all punctuation marks, and a ( is as wide as an x and thus
easy to see - not  a mere wisp....

Sam



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

Date: 24 Jul 1998 03:58:46 GMT
From: kherron@campus.mci.net (Kenneth Herron)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6p90pm$qta$1@news.campus.mci.net>

As I said elsewhere in the thread, I tend to split code out into a
separate routine if I find myself indenting too much (not the *only*
reason, of course :-).  Given the original code, a logical split would
be to separate the code that handles looping through dates from the
code that processes each candi-date.

That would still leave some fairly messy code to handle looping through
a range of dates.  The following probably isn't an exact
replacement--it may have a fencepost error relative to the original
code, for example--but gives the flavor of an alternate method.  As
someone else suggested, this converts the dates to seconds since the
epoch--days since a common starting date could have been used, if the
application needed to handle a wider range of dates--and loops forward
one day at a time.  A separate variable tracks day-of-week to avoid
having to call gmtime() each time through the loop.

------------------------------------------------------------
use Time::Local;
$oneday = 24 * 3600;

sub yyyymmdd_to_epoch ($) {
	if ($_[0] =~ /^(\d{4})(\d{2})(\d{2})/) {
		return timegm(0, 0, 0, $3, $2, $1);
	}
	else {
		return -1;
	}
}

[...]
	my($start_dow, $end_dow, $hour, $minute, $start_tm,
		$end_tm, $dow, $now);
	$start_dow = shift @parm_list;
	$end_dow = shift @parm_list;
	$hour = shift @parm_list;
	$minute = shift @parm_list;

	$start_tm = yyyymmdd_to_epoch $starting_date;	# Error-checking left
	$end_tm = yyyymmdd_to_epoch $ending_date;	# out for simplicity
	$dow = (gmtime $start_tm)[6] + 1;		# day of week, 1-7

	for ($now = $start_tm; $now < $end_tm; $now += $oneday) {
		if (($dow >= $start_dow) && ($dow <= $end_dow)) {
			my($yr, $mo, $dy) = (gmtime $now)[5,4,3];
			push (@recurrences, sprintf("%04%02%02%02%02",
				$yr + 1900, $mo + 1, $dy, $hour, $minute));
		}
		$dow = (0, 2,3,4,5,6,7,1)[$dow];	# Increment within 1-7
	}
------------------------------------------------------------
-- 
Kenneth Herron -- kherron@campus.mci.net
"When Microsoft first took control of the Funk & Wagnalls Encyclopedia
product, there was a flattering biography of Bill Gates.  But it said he
was known as a tough competitor.  Now it says that he's known for his
charitable contributions." -- Gary Reback, <http://www.ljx.com/reback/>


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

Date: 24 Jul 1998 03:02:22 GMT
From: gis83812@cis.nctu.edu.tw (I-Fei Tsai)
Subject: Question: Oraperl on Windows NT?
Message-Id: <6p8tfu$a77$1@news.cis.nctu.edu.tw>

Hello! Everybody,

  Does any one program oraperl on the platform of Microsoft Windows?
Would you please give me some information such as web page address
or personal experience? Thank you very much!

Best regard,
I-Fei Tsai.
Department of Computer & Information Science
National Chaio Tung University
gis83812@cis.nctu.edu.tw



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

Date: Fri, 24 Jul 1998 04:43:16 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Returning values from a child process
Message-Id: <EwL144.Jrv@world.std.com>

Chris Bero <cbero@uwyo.edu> writes:

>If I have a parent process which forks to a child process and that child does
>some kind of processing of a variable, is there a way to return the new value of
>that variable to the parent process?  (my god, that was one sentence!)

Open a pipe before you fork, have the child write the variable to the
pipe, and have the parent read the pipe and store the result in the
variable. Or use a piped open and have the child write it to STDOUT.

Or take a look and see if someone wrote a "shared memory" module for
your operating system variant. (If you told us what kind of Unix box
you were working with, I might just be able to point you to the right
one.)

-- 
Andrew Langmead


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

Date: 24 Jul 1998 03:34:08 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: sprintf and decimals
Message-Id: <6p8vbg$1jo$2@nswpull.telstra.net>

In article <MPG.10213e918f833a4d989742@nntp.hpl.hp.com>,
	lr@hpl.hp.com (Larry Rosler) writes:

>> $t = sprintf("%.0f",$number);
> 
> You deserve congratulations for doing it right.  However...
> 
> Print $number immediately before this.  If it is indeed 0.8, install a 
> version of perl that works.  I have checked it in 5.002 and 5.004 with no 
> problems.

I think that actually has to do with having broken system libraries.
perl should just call one of the printf(3S) functions. I haven't
actually checked perl's code, but I can harldy imagine it being
otherwise. Besides, I seem to remember this coming up a while ago on
this group.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Thu, 23 Jul 1998 20:51:55 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sprintf and decimals
Message-Id: <MPG.1021a4b2d5fc433098977e@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc; copy mailed to Martien Verbruggen 
<mgjv@comdyn.com.au>.]

In article <6p8vbg$1jo$2@nswpull.telstra.net> on 24 Jul 1998 03:34:08 
GMT, Martien Verbruggen <mgjv@comdyn.com.au> says...
> In article <MPG.10213e918f833a4d989742@nntp.hpl.hp.com>,
> 	lr@hpl.hp.com (Larry Rosler) writes:
> 
> >> $t = sprintf("%.0f",$number);
> > 
> > You deserve congratulations for doing it right.  However...
> > 
> > Print $number immediately before this.  If it is indeed 0.8, install a 
> > version of perl that works.  I have checked it in 5.002 and 5.004 with no 
> > problems.
> 
> I think that actually has to do with having broken system libraries.
> perl should just call one of the printf(3S) functions. I haven't
> actually checked perl's code, but I can harldy imagine it being
> otherwise. Besides, I seem to remember this coming up a while ago on
> this group.

You are correct that perl 5.003 and below called the C library [s]printf.  
But as I recall, in 5.004 perl got its own implementation of sprintf.  I 
know for sure that it got its own documentation in perlfunc without 
referring to [s]printf(3C).  So it is most unlikely that this poster is 
actually using 5.004; he probably does have a broken C library as you 
suggest (or has misinterpreted the situation :-).

Larry

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 24 Jul 1998 03:07:42 GMT
From: "Nathalie M." <elssa09@nospam.callisto.si.usherb.ca>
Subject: substitution code query - how much can it really do?
Message-Id: <35B7F9BC.14EC@nospam.callisto.si.usherb.ca>

I've already used a piece of substitution code to arrive at this:

http://callisto.si.usherb.ca/~eslcafe/cgi-bin/test/sample-result.htm

using:

$line =~ s/$in{'word'}/<\/td><td nowrap><FONT
COLOR\=BLUE><b>$in{'word'}<\/b><\/FONT><\/td><td nowrap>/oi;

If you look at the page above, I have flushed out all the occurences of
the word "storm" in a corpus of text.
Then I lined the word up in the centre of the page. (I know the page is
wide. It's meant to be like that.)

BUT NOW I want to highlight the word on either side of "<FONT
COLOR=BLUE>storm</FONT>" in ANY give sample of text, for example:

<FONT COLOR=RED>big</FONT> <FONT COLOR=BLUE>storm</FONT> <FONT
COLOR=RED>in</FONT>

It's a perl question! For the life of me I can find anyting in a
reference manual that comes close to it.

Please reply to

mailto:elssa09@nospam.callisto.si.usherb.ca

Delete "nospam."

I will be away for a week and will probably miss any replies posted -
but I could REALLY  use your inspiration.

Thanks

:-)

Nathalie


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

Date: Thu, 23 Jul 1998 11:04:40 -0400
From: Alex Rolfe <arolfe@genome.wi.mit.edu>
Subject: threads in perl
Message-Id: <35B75108.41C6@genome.wi.mit.edu>

Is it possible to program using threads in perl?  If so, is there any
online documentation or examples?

	Thanks,
	Alex Rolfe
	arolfe@genome.wi.mit.edu


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

Date: 24 Jul 1998 02:08:45 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Using 2 d Arrays in Perl 4
Message-Id: <6p8qbd$q80@news-central.tiac.net>

In article <35B5CBCA.659A0F79@ml.com>,
Paul Bashforth  <paul_bashforth@ml.com> wrote:
>I've written a script in Perl 5 which uses 2 dimensional arrays..
>
>eg $Column[$row][$k] = $item;
>
>However, I need to be able to run this as Perl 4 but when I do I'm
>getting the following error...
>
>syntax error in file ./convert123.pl at line 71, next 2 tokens "]["
>
>Can you tell me if such arrays are allowed in Perl 4 or indeed if there
>is a way I should declare them in Perl 4?

You can't directly do it in perl 4, there's the old

  $hash{$index1, $index2} = $value;

which uses $; to mangle the index so you're effectively saying

  $hash{join ($;, $index1, $index2)} = $value;

which may make traversing the hash by row / column harder later unless
you've stashed information about index values elsewhere.

Alternatively you can use type globs to do tricks with symbol table
entries and do a lot of explicit work in perl 4.  If you're forced to do
this I would seriously consider upgrading to perl 5 or attacking the
problem differently...

Hope this helps,

Mike





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


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

Date: Thu, 23 Jul 1998 21:16:06 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: using s///
Message-Id: <6pq8p6.o2j.ln@localhost>

Alexander Weaver (weave005@bama.ua.edu) wrote:

: I've got a 

   Frequently Asked Question  ;-)



   perlfaq, part 4:

   "How can I split a [character] delimited string except when inside
    [character]? (Comma-separated files)"


   Where they show how to split on commas except for commas that
   are in double quoted strings.

   Sound familiar?


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


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

Date: Thu, 23 Jul 1998 21:22:21 -0400
From: Marco Moreno <mmoreno@cas.org>
Subject: What's the most efficient regex to force NOT matching any char?
Message-Id: <35B7E1CD.E265644C@cas.org>

I would like to iterate thru a string and skip over as many chars as
possible that don't need anything done to them, but stop and perform
some conversion on each char that does not match a regex.  The regex
may vary depending on the data format and would be defined by a
variable at runtime.

My question is:  If I want to force the conversion of every char, what
is the most efficient regex I should use to force an unsuccessful
match of the pass-thru regex?

I've thought of "[^\x00-\xFF]" and "(?!.)", but is there something
better?

Here is a blurb of what I'm trying to do:

$passthru_regex = get_regex();  # What should I assign here?

while ($orig_string =~ m{\G

        # Match as many characters as possible
        # that can be passed thru as-is
        ($passthru_regex+)

        # Otherwise, get the next 2-byte char
        | (..)

        }gosx)
{
    my $passthru_string = $1;
    my $char = $2;

    if (defined $passthru_string) {
        print $passthru_string;
    } else {
        print do_something($char);
    }
}

Incidently, using "(?!.)" on 5.004_01 spewed something like:

/((?!.)+)|(.)/: regexp *+ operand could be empty at (eval 20) line 2.

though it no longer does on 5.005.  Should this construct be avoided
or was that a bug?

Thanks!

Marco Moreno
mmoreno@cas.org


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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