[6479] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 104 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 12 17:28:20 1997

Date: Wed, 12 Mar 97 14:00:26 -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           Wed, 12 Mar 1997     Volume: 8 Number: 104

Today's topics:
     Re: "My" ruminations <jstern@world.northgrum.com>
     a chat program <blan0416@uidaho.edu>
     Re: a tricky regex (Jeff Godden)
     Basic I/O and 'if vs unless' questions (Chris Starkey)
     Re: Calling a Perl Program from within HTML <kevlar@ns.net>
     Counter help me peez >:P <lorraine@ait.nrl.navy.mil>
     Re: Date conversion from server logs to time() format <damon@netserver.stanford.edu>
     Re: Elegant way to strip spaces off the ^ and $ of a va (Greg Ward)
     Re: Elegant way to strip spaces off the ^ and $ of a va <lpeters@aol.net>
     Re: Elegant way to strip spaces off the ^ and $ of a va <lpeters@aol.net>
     embedded perl, perl_parse and setuid programs <freehill@austin.ibm.com>
     Re: Grep function question (Mik Firestone)
     Re: grep question (Tad McClellan)
     Re: grep question (Byron Brummer)
     Re: How do I get all more than 2 hours old files <fawcett@nynexst.com>
     Re: How to spam - legitimately (Michael Shields)
     html embedding <lorraine@ait.nrl.navy.mil>
     I'm scared and don't know what to do. Do you know?? <Tom@intermart.co.uk>
     Re: Include perl script in HTML? <Web.Technical@bankamerica.com>
     Re: Interactive drawing alternatives in perl? (David M Holmes)
     Re: Is possible in perl run a string like a piece of pr <rajeshg@ccwf.cc.utexas.edu>
     Re: Looking for non-Unix Perl book <buehner@pfaffenhofen.netsurf.de>
     Re: matching whitespace? (Tad McClellan)
     Re: newbie question: how to pick a particular line in p (Ken Williams)
     Pattern matching on stream (Peter Scott)
     Re: Perl "strict" usage (Frans Postma)
     Perl 5.002 bug?  Infinite loop *inside* push() after GD <eryq@enteract.com>
     Re: Removing trailing and leading spaces <igorv@styx.or.fedex.com>
     Re: Running same perl script on different platforms (Michael Constant)
     Re: Standard "Reaper" procedure doesn't work on Solaris (Bryan Miller)
     Re: Standard "Reaper" procedure doesn't work on Solaris (Gideon King)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 12 Mar 1997 18:48:59 GMT
From: Jim Stern <jstern@world.northgrum.com>
Subject: Re: "My" ruminations
Message-Id: <3326FA9B.70C4@world.northgrum.com>

Luigi Mattera wrote:
> 
>   I recently slapped "use strict" into my Perl programs and watched
> them crash and burn due to variables not being declared.  Ok, that was
> no problem.  I found out that the correct way to do this was via the
> "my" keyword.

Good.

> 
>   This immediately caused me to have FORTRAN flashbacks.  FORTRAN has
> a keyword "common," which as you can guess by the name makes a
> variable common to an entire program, I.E. global.  Why is this a bad
> thing?  Well then, you haven't seen FORTRAN 77 code starting with
> *pages* of common declarations.  If someone asks you to debug one of
> these, you're better off shooting yourself on the spot.

Just think of it as character-building. :-)

> My teacher suggest that we never ever use this ability.

"Never" may be too strong.  But "sparingly."  Very.

> 
>   The problem is that "my" seems too similar to be a coincidence.  Am
> I misinterpreting this keyword?

Not sure I understand this.  Are you asking whether "my" variables
are like FORTRAN common variables?  If so, no!  They're much more
tightly scoped.  See the perlfunc(1) man page.

> Does Perl have a main() construct
> which allows me to pass variables back and forth rather than make them
> all global by force?  I do not want to fall into the "common" trap of
> old FORTRAN 77 code, since I would like what I am doing to be readable
> after I am done with it.  Thanks for any assistance.

Are you asking how to share a variable among selected packages
only?  I'll answer that.  Please post again if I have misinterpreted.

One approach is to use a package-scope variable and to reference
that from selected other packages.  This is like FORTRAN's named common.

Another is to define accessor subs to get and set the desired variable.
Or write one sub that returns a reference to a variable.  Accessor
subs are generally the preferred way to go for OO code, although
there the subs are usually called "methods."  You can force
all accesses to take place via subs:

	{	# WARNING:  Untested code
		my $hidden;
		sub getHidden {$hidden}
		sub setHidden($hidden = shift;}
	}

(I adapted this from the perlsub(1) man page.)

Finally, sometimes rethinking your code eliminates the need to access
the variable directly.  This is especially so when you tend to access
several package variables in a pattern.  If so, write a higher level
sub that does it all.

-- 
Jim Stern -- Views here are my own, not Northrop Grumman's.   (El
Segundo, CA)


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

Date: Wed, 12 Mar 1997 13:27:23 -0800
From: Derek Blandford <blan0416@uidaho.edu>
Subject: a chat program
Message-Id: <33271FBB.7372@uidaho.edu>

Hey,
I've set up my own chat...and it works pretty good so far.  What I'm
wondering is if there is a way that I can print to two frames at once
from the same perl program.  Right now, the input is fed to a file, then
the chat frame refreshes and displays new messages.  Then the program
returns the form to the bottom frame.  How could I make an output to
both the bottom and top frame?  Thanks a bunch, guys.  I appreciate your
help.  My e-mail is blan0416@uidaho.edu

Jason Hansen


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

Date: 12 Mar 1997 19:27:39 GMT
From: godden@u.washington.edu (Jeff Godden)
Subject: Re: a tricky regex
Message-Id: <5g703b$imp@nntp1.u.washington.edu>

In article <3326F2C2.1B38@eai.com>, Bryan Hart  <bryan@eai.com> wrote:
>Sorry for asking such a question here, but I'm getting a bit stumped. 
>I'm looking for a regex (or some other way) to remove whitespace from a
>string EXCEPT when the whitespace is enclosed in quotes("").
>Here's an example string:
>$Footer = { PullDown["New Issue"(AddNewIssue), "Help"(Help), "Issue
>...

Consider at some time buying a copy of 
-----------------
   Mastering Regular Expressions
   By Jeffrey E. F. Friedl
   1st Edition January 1997
   1-56592-257-3, Order Number: 2573
   368 pages, $29.95
-----------------
It nicely explains ways around such nasty things as you're asking.

Essentially from what i learned from Master Friedl is that you want to
match such quoted regions inside parentheses so that you can replace
them later before gobbling away all the white space.  For this purpose
the chew but don't swallow (?: ... ) perl regular expression extension
is great.

good luck.
--
jeff godden@u (seattle)


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

Date: Thu, 13 Mar 1997 04:24:05 GMT
From: chris.starkey@3dlabs.com (Chris Starkey)
Subject: Basic I/O and 'if vs unless' questions
Message-Id: <E6y5yB.787@3Dlabs.com>

Hi,
  I am fairly new to Perl5 and I need to write a script to grope round
some suns.   Great opportunity to learn Perl :)   The following
segment reads hostnames from "hostfile" and then checks they are alive
before executing the 'rsh <command>'.   My first question is : why
does the unless statement work, when I had 'if (system ("ping $name
2")) it didn't execute the 'rsh' section ?   Surely if (the system
command) is true then the {bit in the brackets} is done.   My second
question is : why when I run the script file and redirect the STDOUT
to a file (ie ./my_script > my_script.out) isn't the "Checking $name"
printed to the file ?   It seems to work if I modify the print
statement to include 'print STDERR'.

Thanks for any help,
Doug
doug@3dlabs.com  

sub get_sun_release {
        open(HOSTFILE, "hostfile");
        while ($name = <HOSTFILE>) {
                chop($name);
                if ( $name =~ /^#/ ) {  # if commented out hostname
                        next;           # go to the next one
                        }
                print "\nChecking $name :\n";
                unless (system ("ping $name 2")) {
                        system ("rsh $name uname -a");
                        }
                }
        close (HOSTFILE);
        }




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

Date: Wed, 12 Mar 1997 12:21:52 -0800
From: "K. Healy" <kevlar@ns.net>
Subject: Re: Calling a Perl Program from within HTML
Message-Id: <33271060.167E@ns.net>

Laurel Shimer wrote:
> 
> I'm not absolutely clear on what you want to do - but I think maybe 
> this is the sort of thing you do w/ Java Script.
> 
> Others- Is that the wrong track to suggest?

Maybe, maybe not.  Try comp.infosystems.www.authoring.cgi, for non-perl
related questions.  You probably get a lot further.

> Laurel
> 
> In article <331A1D13.6F42@cdsnet.net>, thorsoft@cdsnet.net wrote:
> 
> > I need to include about 50 lines of html code into 10 sites.  I also
> > need to pass a parameter to the cgi code so I know which 50 lines of
> > code that is needed.  There are 4 different snippets of code each
> > with a different graphic.  The cgi code would then look at the
> > parameter and then generate the proper html code for inclusion into
> > the page that called the cgi program.
> >
> > Can I call a cgi program from an html page while the html page is
> > loaded?  This is similar to a server side include, but some of the
> > sites do not want to make their "html" files "shtml" for the server
> > side includes to work.
> >
> > Thanks,
> > Rick
> 
> --
>         The Reader's Corner: Mystery, Romance, Fantasy
>      Short stories, excerpts, themes and resources
>         http://www.autopen.com/index.shtml
>      Subscribe to our free StoryBytes publication
> Current Mermaids Issue at http://www.autopen.com/mermaids.shtml

HTH.

K.


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

Date: Wed, 12 Mar 1997 16:21:09 -0500
From: Brian Lorraine <lorraine@ait.nrl.navy.mil>
Subject: Counter help me peez >:P
Message-Id: <33271E45.41C6@ait.nrl.navy.mil>

Could someone help me with what is probably a simple perl problem? I'm
working on a text counter that's rather simple. You can view it at:
"www.ait.nrl.navy.mil/cgi-bin/lorraine/testcgi.pl"
Anyhoo here is the actual perl code:
################################################
#!/usr/bin/perl

open(COUNTFILE, "testct");                 
$numero = <COUNTFILE>;                     

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

print "You are visitor number $numero\n" || print "Can't open the
file\n";

$numeronext = $numero + 1;              
print COUNTFILE "$numeronext\n";         
close(COUNTFILE);
################################################

Yes, this script gives users read and execute permission and yes that
"testct" countfile does give read and write permission to everyone. From
what I can see this simple program SHOULD take the number already in
there and print it out (which it does) and then takes that numbr, add
one, and print that new number into the "testct" file (WHICH IS THE
PROBLEM). It won't print to the file. I keep opening to check if it
changed, but all I see in "testct" is a lonely "1". Would someone please
offer some assistance :) ??? much more preferably by email but here in
newsgroups if u want...

--------------------------------------------------------------
Brian "the BrAiN" Lorraine           lorraine@ait.nrl.navy.mil

                      "let the music set u free"

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


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

Date: Wed, 12 Mar 1997 12:29:34 -0800
From: Conrad Damon <damon@netserver.stanford.edu>
To: webmaster@gmom.com
Subject: Re: Date conversion from server logs to time() format
Message-Id: <3327122E.2781@netserver.stanford.edu>

require "timelocal.pl";
$time = timelocal($sec,$min,$hours,$mday,$mon,$year);

timelocal.pl is part of the standard perl distribution.

----------

> I am trying to find some perl routines that will take the date format
> found in the web server common log format, and convert it into the
> integer format returned by time(). Can anyone point me in the right
> direction?


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

Date: 12 Mar 1997 20:49:44 GMT
From: greg@bic.mni.mcgill.ca (Greg Ward)
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <5g74t8$4mj@sifon.cc.mcgill.ca>

Sherman Hsieh (asialive@best.com) wrote:
> Hi all,
> 	I couldn't come up with an elegant way to strip off spaces
> (newline, tab or whatever) of a string. Does anyone have a good solution
> to this.

How about this:

$variable =~ s/^\s*//;
$variable =~ s/\s*$//;

I've always been slightly irked that you can't do this in one pass,
but it's still pretty darn simple and elegant.

        Greg
--
Greg Ward - Research Assistant              greg@bic.mni.mcgill.ca
Brain Imaging Centre (WB201)                 voice: (514) 398-4965 (or 1996)
Montreal Neurological Institute                fax: (514) 398-8948
Montreal, Quebec, Canada  H3A 2B4


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

Date: Wed, 12 Mar 1997 15:17:07 -0500
From: Les Peters <lpeters@aol.net>
To: Sherman Hsieh <asialive@best.com>
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <33270F43.446B@aol.net>

Sherman Hsieh wrote:

> $variable = "    jklsd jslkjsd   ";
> 
> I want to strip off all the spaces before and after the string above so
> the resulting string should look like:
> 
> $variable = "jklsd jslkjsd";

>From Jeffrey E.F. Frield's Mastering Regular Expresions, page 290:

$variable =~ s/^\s+//;
$variable =~ s/\s+$//;

Jeffrey goes on to describe one-line attempts and why they are
non-optimal.

-- 
Les Peters, Team Lead, Information Retrieval Operations
http://www.mis.aol.com/~lpeters/


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

Date: Wed, 12 Mar 1997 15:21:59 -0500
From: Les Peters <lpeters@aol.net>
To: Sherman Hsieh <asialive@best.com>
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <33271067.794B@aol.net>

Sherman Hsieh wrote:

> $variable = "    jklsd jslkjsd   ";
> 
> I want to strip off all the spaces before and after the string above so
> the resulting string should look like:
> 
> $variable = "jklsd jslkjsd";

Perhaps this?

$var =~ s/^\s+(\S.*\S)\s+$/\1/;


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

Date: Wed, 12 Mar 1997 10:53:08 -0600
From: Chris Freehill <freehill@austin.ibm.com>
Subject: embedded perl, perl_parse and setuid programs
Message-Id: <3326DF74.41C6@austin.ibm.com>

I have a setuid C program from which I'm trying to call some perl
code. Consulting the perlguts, perlembed, etc. man pages, I
implemented this as

char *embedding[] = {"", "-e", "sub _eval_ {eval $_[0] }" };

int perl_eval(char *string)
{
    int val;

    char *argv[2];
    argv[0] = string;
    argv[1] = NULL;

    val = perl_call_argv("_eval_",0,argv);
    return val;
}

int main()
{
       _my_perl = perl_alloc();
       perl_construct(_my_perl);
       perl_parse(_my_perl,NULL,3,embedding,environ);
   
	perl_eval(...string of perl code...);

    /* etc, etc */ 
}

 Anyway, when the perl_parse function is executed, I get the message
 "No -e allowed in setuid scripts". 

 To get around this, I tried putting
 the function perl_eval in a file, and modifying the variable 
 embedding so that "-e" is not used, and the function is read from the
 file.  In this case, I get the message "No program input from stdin
 allowed while running setuid".
 
 I'm able to make the above mentioned solutions work in non-setuid
 programs.  The question is, is there a way to embed perl into 
 setuid C programs? Is there any way to get around this?

 Thanks,
 Chris


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

Date: 12 Mar 1997 14:41:45 GMT
From: mfiresto@vnet.ibm.com (Mik Firestone)
Subject: Re: Grep function question
Message-Id: <5g6fb9$o7e$1@mail.lexington.ibm.com>

In article <E6uxHz.9Cx@cee.hw.ac.uk>,
Triantafyllos Marakis <ceetm@cee.hw.ac.uk> wrote:
>I am trying to construct a function that will count the 
>number of occurances of a string to a file.
>
>So far I've written the following code:
>
>open(IN_FILE, $in_file) or
>  die "Program Fault; File cannot be found:$in_file\n";
>while ($line = <IN_FILE>)
>{                          
>  $line = lc($line);
>  
>  @list = split(/ /, $line);
>  $strings_per_line = grep(/$string/, @list); #count the occurance
>				              #of the string
>  $counter += $strings_per_line;
>}
>close(IN_FILE);
>
>But if a string is contained more than once in a word      
>(e.g. ......hello......hello... it increases the counter 
>by one)
>
>How is it possible to change the code above to achieve the goal?
>

It depends on exactly what you would like to do.  As you are already
creating several arrays here, I am assuming this is not a problem.  The
first trick is to realize that a m// evaluated in a list context will
return a list of all matches, so you could do this:
  my @trash; # You are using -w and use strict right?
  $counter = 0;  # Keeps -w happy
  while ( <IN_FILE> ) {
      @trash = /$string/ig; # use /i to ignore case
      $counter += @trash;
  }
Of course, that will cause strings like 'test' and 'testing' to match when
$string = 'test'.  If that is okay, no problem.  If you want only exact
matches, include the word boundaries in the RE like /\b$string\b/g.  

I tried a few other tricks, to avoid having to use the temp array, but
I couldn't quite figure it out.  Maybe those who know more than I can offer
that solution.

Htth
-----
Mik Firestone  mfiresto@mindspring.com
Evil Overlord Rule #15: I will make it clear that I _do_ know the
meaning of the word "mercy"; I simply choose not show them any.



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

Date: Wed, 12 Mar 1997 11:30:29 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: grep question
Message-Id: <l7p6g5.sh2.ln@localhost>

Triantafyllos Marakis (ceetm@cee.hw.ac.uk) wrote:
:  I have written the following code

:      $line = lc($line);
:      @list = split(/ /, $line);   #split the line to words
:      $strings_per_line = grep /$string/, @list;
:      $counter += $strings_per_line;

:  How is it possible to return the number of occurances of a string
:  if $strings_per_line 
:  has the required string occuring more than once to its body?

:  Example.
:    If $string = "hello" and $line = "..hello....hello...."
:    to return 2


You already asked this...

I already answered this...


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


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

Date: 12 Mar 1997 21:53:07 GMT
From: byron@no.such.domain (Byron Brummer)
Subject: Re: grep question
Message-Id: <5g78k3$brp$4@nntp2.ba.best.com>

Triantafyllos Marakis (ceetm@cee.hw.ac.uk) wrote:
:      $line = lc($line);
:      @list = split(/ /, $line);   #split the line to words
:      $strings_per_line = grep /$string/, @list;
:      $counter += $strings_per_line;

:  How is it possible to return the number of occurances of a string
:  if $strings_per_line 
:  has the required string occuring more than once to its body?

	Your code should be (almost) ok now, what output are you getting?
	Are you sure your $string is all lower case?
	If you want exact matches however, you may want to replace the
	"/$string/" with "$_ eq $string". -It's a little faster anyway.

@words = qw(this this is a test);
$count = grep $_ eq 'this', @words;
print "$count\n";

	Prints out "2".

-Zenin
 zenin@best.com


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

Date: 12 Mar 1997 14:27:55 -0500
From: Tom Fawcett <fawcett@nynexst.com>
Subject: Re: How do I get all more than 2 hours old files
Message-Id: <8jybbsvrk4.fsf@nynexst.com>

Ronak Bhatt <rbhatt@netscape.com> writes:
> Hi,
> 
> How would I get the filenames, that were created before two hours ( when
> the script is run).


print join("\n", grep(-M $_ < 2/24, <*>));

which brings up an interesting question -- why is the $_ necessary here?
If you just say:

print join("\n", grep(-M < 2/24, <*>))

you get "Glob not terminated".  Presumably Perl thinks the first < is
starting a glob.

-Tom


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

Date: 12 Mar 1997 20:11:06 -0000
From: shields@crosslink.net (Michael Shields)
Subject: Re: How to spam - legitimately
Message-Id: <5g72kq$f2i$1@daedalus.crosslink.net>

In article <3325c0aa.84322097@news.earthlink.net>,
Lee <DeathToSpam@dev.null.com> wrote:
> The english language is pure democracy in action<s>.

No; it's an anarchy.  In a democracy the majority rules over all.
-- 
Shields, CrossLink.


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

Date: Wed, 12 Mar 1997 16:28:06 -0500
From: Brian Lorraine <lorraine@ait.nrl.navy.mil>
Subject: html embedding
Message-Id: <33271FE6.167E@ait.nrl.navy.mil>

Quik Question... lets say I have a perl/cgi script that does the
following print statement somewhere:
#####
print "<CENTER>Olah Taco</CENTER>; 
#####
Is there a way I can take this html like output from this script and
embed it into a part of another html document. For instance, If i have
an html document where part of it says:
#####
<CENTER><B>You are visitor XXX</B></CENTER>
#####
Is there a way (without server side includes) that I can stick the
output of that one script into where the XXX in this html document is?

thanks,
peez respond by email if u can, or here if u really prefer >:)


--------------------------------------------------------------
Brian "the BrAiN" Lorraine           lorraine@ait.nrl.navy.mil

                      "let the music set u free"

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


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

Date: Wed, 12 Mar 1997 20:35:20 +0000
From: Tom Holder <Tom@intermart.co.uk>
Subject: I'm scared and don't know what to do. Do you know??
Message-Id: <RFBUAFAIOxJzEwu1@resmon.demon.co.uk>

Hi, like the title says, I am very scared and lost.

I have a web development project for the next 8 weeks and require the
use of CGI. Firstly I know nothing about CGI but as this is a perl group
I will not offend you by posting CGI queries.

The problem is, I have to do some pretty heavy programs (Chat, Message
board etc.) and I know NOTHING about perl.The only thing I do know is
that it is an interpreted language and to be honest this scares me even
more. The next big worry is that I am using win95 but the servers must
have perl scripts. What do I do? Isn't it just UNIX? I'm not prepared to
use Linux either because my knowledge of UNIX is very thin to say the
least and with only 8 weeks I don't want to learn a totally new O/S.

I do have 'some' limited programming experience in C and I am fairly
good at Pascal but nothing major. OOP is a subject that I have only
touched on but would prefer not to get into this because of the time
scale.

I would really apreciate any information (aimed at an idiot- 17 year old
college student : ) that could help me get started with Perl and
possibly some CGI and Perl related material.

Thanks for your help I really apreciate it...

-- 
Tom,

Tom@intermart.co.uk
Tom@ednet.co.uk
Tom@resmon.co.uk
Tom@2000plus.co.uk


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

Date: Wed, 12 Mar 1997 12:05:20 -0800
From: WebTech <Web.Technical@bankamerica.com>
To: Andreas Wostrack <ubcg5ab@muck>
Subject: Re: Include perl script in HTML?
Message-Id: <33270C80.41C6@ns.net>

[mailed and posted]

Andreas Wostrack wrote:
> 
> This is probably an FAQ but how do I include a perl script
> in an HTML document?
> Any help welcome.
> 
> Cheers,
>    Andreas

You don't but you were amazingly dead-on about that FAQ part:

http://www.perl.com/perl/faq/perl-cgi-faq.html

Hope that helps.

K.


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

Date: Wed, 12 Mar 1997 10:18:16 GMT
From: david.holmes@bigfoot.com (David M Holmes)
Subject: Re: Interactive drawing alternatives in perl?
Message-Id: <E6xE06.J8o@ciba-geigy.ch>

In article <Pine.SOL.3.91.970307105124.26219B-100000@Helios.goldworks.com>, 
Serge Kolgan <skolgan@Helios.goldworks.com> wrote:
>On Fri, 7 Mar 1997, Clay Irving wrote:
>
>> Take a peek at the "Graphics" section of Perl Reference:
>>    http://www.panix.com/~clay/perl/query.cgi?graphics+index
>
>this is all great, but not a single module/package mentioned in URL above
>supports *interactive* drawing, that is: select primitive (click), draw 
>primitive (click), modify... (click-click-click) :)

Interesting that you should mention this.  I've been seriously thinking 
about writing such a thing for my final year degree project.

I'm intending to utilise perltk, the OpenGL module perhaps, and the 'PDF 
on the Fly' module from the University of Nottingham, for final output.
It would be a vector based drawing package.

I'm going to use the PDF module because it is to be used primarily for 
creating Origami folding diagrams.

Dave

--
David M Holmes              |          Novartis, Inc.
david.holmes@bigfoot.com    |    holmes@chbs.ciba.com
----------------------------+------------------------
Dave's Origami - http://www.geocities.com/Tokyo/2162/


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

Date: Wed, 12 Mar 1997 13:34:46 -0600
From: Rajesh Gottlieb <rajeshg@ccwf.cc.utexas.edu>
To: Maurizio Belluati <Maurizio.Belluati@cselt.stet.it>
Subject: Re: Is possible in perl run a string like a piece of program?
Message-Id: <Pine.GSO.3.96.970312133150.10126B-100000@piglet.cc.utexas.edu>


Here's a little program I wrote once that lets you enter a mathematical
expression on the command line and evaluates it.  It shouldn't be too hard
to change it so it gets its expressions from a file instead.

Raj

#!/usr/local/bin/perl
#log(x)     logarithm base e
#exp(x)     e to the power of x
#x**y       x raised to the power of y
#x % y      x MODULUS y
#xey        x*10raised to the power of y; also: xe-y xe+y
print "equation: ";
chop($equation = <STDIN>);
print eval $equation;
print("\n");
die "eval: $@" if $@;

> Hello,
> 
> We've a perl application that need to read math functions stored (like
> strings) in a file. After read the function we need to process it. So a
> possible solution is to write a subroutine that read the function parse
> its string rappresentation end return the result. It could be better if
> in perl there is a function that receives as input a piece of perl code
> (so we write the function in perl syntax) and run it. 
> Does perl have it?
> 
> Thank you for any help.
> 
> Maurizio.Belluati@cselt.stet.it
> 
> 



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

Date: Wed, 12 Mar 1997 22:03:37 +0100
From: Thomas Buehner <buehner@pfaffenhofen.netsurf.de>
Subject: Re: Looking for non-Unix Perl book
Message-Id: <VA.0000005a.00aef0c8@intersco.intersolv.de>

> FWIW, I spent about 5 mins browsing through the Camel book (the one
> everyone seems to use and recommend) and "unlink" caught my eye
> immediately.  This book is not cryptic or poorly laid out, and
> methinks quite usable.  Get it.

I ordered it immediately, along with Cross-Platform Perl, after I had 
read Tom Christansen's review WWW page.

Thanks a lot for suggesting it!

Thomas Buehner




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

Date: Wed, 12 Mar 1997 11:50:22 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: matching whitespace?
Message-Id: <ucq6g5.tq2.ln@localhost>

Tom Christiansen (tchrist@mox.perl.com) wrote:
:  [courtesy cc of this posting not sent to cited author via email
:   because his newsreader is screwed up

: In comp.lang.perl.misc, 
:     astroweb@astron (alex filippenko) writes:
: :i know i could look it up but i am 20min away from any perl book....sorry

: It's really verging on the edge of of unacceptable behaviour to send
              ^^^^^^^^^^^^^^^^^^^
              ^^^^^^^^^^^^^^^^^^^
: off a request like this.  You waste thousands of people's time 
: just because you're to lazy to use the man pages or their moral
: equivalents.

: You're online -- hence you can look it up.  Perl is shipped with 
: about 600 pages of documentation, which you can grep through.



Over the edge, in my book.

I entered one black mark for astroweb@astron when I first saw it...


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


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

Date: Wed, 12 Mar 1997 15:31:20 -0500
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: newbie question: how to pick a particular line in perl5 (win32)
Message-Id: <ken-1203971531200001@news.swarthmore.edu>

> I retrived some data off the web and would like to get
> the 27th line for example.

When the implementation for tied arrays is complete, won't we be able to
do something like this:

tie (@file, 'File_as_List', $max_length);
print $file(26);

?

Perhaps my syntax isn't right, but the basic idea is to use a list as a
reference to the lines of a file.

-Ken Williams, The Math Forum
 ken@forum.swarthmore.edu


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

Date: 12 Mar 1997 18:09:30 GMT
From: pjscott-remove-to-email@euclid.jpl.nasa.gov (Peter Scott)
Subject: Pattern matching on stream
Message-Id: <5g6rgq$p4c@netline-fddi.jpl.nasa.gov>

This sounds a bit odd but it would be useful.  I am wondering if
there is such a thing as a streaming pattern match, which is the
best term I can come up with.  Let me illustrate.  A common task
is to scan a file until some pattern is found and set a variable,
so the code is something like:

	while (<INPUT>) {
		$found = 1, last if /foo/;
	}

Now suppose pattern foo might match across multiple lines (so we'll
have some \s in foo and a /s qualifier).  Can't do the above; if you
know how many lines it might match across you can push each new line
onto an array, shift off the first one to go out of bounds, and match.
Ugly, and what about when you don't know how many lines it might match
across?  You can slurp the whole file into a string (and I usually do),
but this is wasteful, especially if you're searching potentially long
files for strings which are probably near the beginning (the example
which prompted this is searching for <META> tags in HTML).

It doesn't seem unreasonable to want to say, "Read as much of the
file as you need to either match this or reach EOF," although it
doesn't sound like an easy thing to implement, and I haven't found
anything like it on CPAN.  Anyone got any brilliant suggestions for
doing it?

(Apologies for the mangled return address... just spam defense...)

-- 
This is news.  This is your      |  Peter Scott, NASA/JPL/Caltech
brain on news.  Any questions?   |

Disclaimer:  These comments are the personal opinions of the author, and 
have not been adopted, authorized, ratified, or approved by JPL.


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

Date: Wed, 12 Mar 1997 18:53:39 GMT
From: F.Postma@inter.NL.net (Frans Postma)
Subject: Re: Perl "strict" usage
Message-Id: <3326f3aa.4304514@news.Nl.net>

mattera@ssga.ssb.com (Luigi Mattera) wrote:

>  I was surprised by the slowdown myself.  I had timed my script for
>each execution list and it went from around 50 seconds to execute to
>around 2 minutes 20 seconds.  Does using "my" multiple times on a
>single variable cause slowdown?  I combined them all to be certain,

It might, it *will* cause a warning under perl5.003_23 and higher (if
you run with -w which I use as default most of the time)

In general you'll never use my() twice on the same variable in the
same scope...it just doesn't make sense.

 ..."we're up here and you're down there!" (Ed Harris)

Frans Postma
	(fpostma@inter.nl.net)


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

Date: Wed, 12 Mar 1997 13:21:23 -0600
From: Eryq <eryq@enteract.com>
Subject: Perl 5.002 bug?  Infinite loop *inside* push() after GDBM_File fetch
Message-Id: <33270233.4A4CDA00@enteract.com>

Perl 5.002, Linux 1.2.13 with 32 MB RAM, libgdbm 1.7.3, using
the standard system malloc:

I've got a fairly complex Perl CGI script and I'm running into 
a problem: after a fetch a particularly large scalar (well, 22KB,
not large for Perl) from a tied GDBM_File, split it into a (700 element)
array, and pass the arrayref back up to a calling subroutine, the 
upper-level subroutine has no trouble iterating through the
contents of that array... but when I attempt to push() its
contents onto a second array, Perl *hangs* inside the push():
"top" says that it's still running and churning up CPU, but
not increasing in memory size. 

If I attempt to iterate through the array element by element,
it works fine until it gets to the 460th element or so, and
that scalar element that was previously a string is now all of a sudden
undefined.  PLUS, Perl then hops out of my for() loop for no
reason at all.

I don't know much about Perl internals, but it seems like something 
is corrupting the free store OR the stack.  Has anyone ELSE seen
an effect like this?

Smaller GDBM_File scalars with the exact same code have worked 
perfectly for months.

TIA,
-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.enteract.com/~eryq
 \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
           |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: Wed, 12 Mar 1997 15:52:07 -0600
From: Igor Vulfson <igorv@styx.or.fedex.com>
To: Avi <avi@tase.co.il>
Subject: Re: Removing trailing and leading spaces
Message-Id: <33272587.7396@styx.or.fedex.com>

Avi wrote:
> $a="    just a string    ";
> $a= s/^\s+|\s+$//g;
> print("$a");

$a="    just a string    ";
$a=~ s/^\s+|\s+$//g;
print("$a");

Note the '~' after the second '='.

iv
-- 
Igor Vulfson                |  Email: mailto:ivulfson@fedex.com
Sr. Scientific Programmer   |  URL:   http://www.magibox.net/~unabest/
Operations Research, FedEx  |  Phone: (W) 901-395-7358  (H) 901-624-0776


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

Date: 12 Mar 1997 12:40:43 -0800
From: mconst@soda.CSUA.Berkeley.EDU (Michael Constant)
Subject: Re: Running same perl script on different platforms
Message-Id: <5g74cb$k3n@soda.CSUA.Berkeley.EDU>

In article <33259654.66A4@memh.ti.com>, Derek May  <dmay@memh.ti.com> wrote:
>Is there a way to set up our scripts to check the current OS version
>before looking for the perl executable?
>
>We are currently running on HPUX machines with OS v9.07.  We are
>installing new HPUX machines running OS 10.20.  On the old machines,
>perl is located in /usr/local/bin, but on the new machines perl will
>have to be installed somewhere else.  We would like to be able to use
>the same scripts without having to make duplicate copies with a new
>header line.

Put a little shell script in front of your perl script:

#! /bin/sh
if [ `uname -r` = "A.09.07" ]; then
    exec /usr/local/bin/perl -x $0
else
    exec /other/place/bin/perl -x $0
fi

#! /magically/invoked/perl
print "Hello, world\n";

That's all one file, even though it has two #! lines.  It starts up /bin/sh,
tests uname -r to see what OS version it's using, and hands the script to one
of two perl binaries.  The -x option to perl tells it that the script has
leading garbage, so perl ignores everything up to a #! line that mentions
perl.  (Otherwise, perl would try to parse the sh script at the top, and
this could only lead to confusion.)  You can put extra options on the
#! /magically/invoked/perl line if you want, and they will be parsed just
as they would if perl were being started in the normal manner.

You may have to tweak the uname line to match what your system says when you
type "uname -r".  However, if you happen to know that everyone running your
script will always have perl in their path, you can do away with the uname
(and most of the sh script) altogether:

#! /bin/sh
exec perl -x $0

#! /magically/invoked/perl
print "Hello, world!\n";
-- 
        Michael Constant (mconst@soda.csua.berkeley.edu)


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

Date: 12 Mar 1997 20:11:05 GMT
From: millerb@pt9541.ped.pto.ford.com (Bryan Miller)
Subject: Re: Standard "Reaper" procedure doesn't work on Solaris.
Message-Id: <5g72kp$d8j7@eccws1.dearborn.ford.com>

Gideon King (gideon@csarc.otago.ac.nz) appears to have written:
>I am using the standard "reaper" from the perlipc documentation to clean  
>up child processes, and I find that it doesn't work under Solaris. The  
>test can be reproduced using the standard code from the perlipc page. My  
>test platforms have been:
>NeXTXTEP 3.3, Perl 5.002 - Works
>OpenStep 4.1, Perl 5.002 - Works
>Solaris, Perl 5.002 - doesn't work
>Solaris, Perl 5.003 - doesn't work

>The offending code is:
>sub REAPER 
>{ 
>	$SIG{CHLD} = \&REAPER;  # loathe sysV
>	$waitedpid = wait;
>	logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
>}
>$SIG{CHLD} = \&REAPER;

It has never worked on Digital Unix (3.2d) either.  I've
been trying it since 5.001 and we are now using 5.003.
Using the above code causes the parent to wait for the
first child forked - and by wait I mean do _nothing_ until
the first child dies.

I'm hoping to write some of my own hooks to get around this.
If Perl && Digital had more of the requisite POSIX hooks it
might be possible to just change the mask.  Gaack!

Let us know what you find out.

regards,
Bryan
--
----------------------------------------------------------
Bryan Miller                |
ClearCase Administrator     |
Advanced Vehicle Technology	|    "Nil Sine Numine"
Ford Motor Company          |
bmiller6@ford.com           |


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

Date: 12 Mar 1997 21:41:01 GMT
From: gideon@csarc.otago.ac.nz (Gideon King)
Subject: Re: Standard "Reaper" procedure doesn't work on Solaris.
Message-Id: <5g77td$79o$1@celebrian.otago.ac.nz>

In article <5g5m8r$7gf$1@halcyon.com> blm@halcyon.com (Brian L. Matthews)  
writes:
> In article <5g54o1$1s6$1@celebrian.otago.ac.nz>,
> Gideon King <gideon@csarc.otago.ac.nz> wrote:
> |sub REAPER 
> |{ 
> |	$SIG{CHLD} = \&REAPER;  # loathe sysV
> |	$waitedpid = wait;
> |	logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
> |}
> |$SIG{CHLD} = \&REAPER;
> |If I comment out the line
> |	$SIG{CHLD} = \&REAPER;  # loathe sysV
> 
> This is completely out of left field, so it may have nothing to do with
> anything. However, at one time, because of the way SIGCHLD worked on
> System V, you had to reset the signal *after* the wait, otherwise
> SIGCHLD would be raised again immediately. If that was the entire
> story, I would expect an infinite loop, but maybe Solaris only
> inherited part of the behavior and SIGCHLD just gets raised once
> more? What happens if the "loathe sysV" line is moved after the wait
> line?
> 
> Just a thought, and I apologize if this has no relation to reality...
> 

Thanks for the suggestion. It stopped the duplicate reaped message, but  
the program still only works every second time.

---

Gideon King                    | Phone +64-3-479 9017
Acting Manager                 | Fax   +64-3-479 8529
The Black Albatross            |
University of Otago            |
Computer Science Applied       | e-mail gideon@csarc.otago.ac.nz
         Research Centre       | NeXT mail, MIME ok. PGP key available.
Department of Computer Science |
P.O. Box 56                    | I don't have a solution
Dunedin                        |         but I admire the problem.   
New Zealand                    |
WWW access: http://www.csarc.otago.ac.nz:805/


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

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

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