[7604] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1230 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 26 12:07:41 1997

Date: Sun, 26 Oct 97 09:00:34 -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           Sun, 26 Oct 1997     Volume: 8 Number: 1230

Today's topics:
     A little help, please. <"jvleigh"@_no spam_kih.net>
     Re: A little help, please. <dave@sitesolve.com>
     Re: A little help, please. (brian d foy)
     Re: A little help, please. (Tad McClellan)
     Re: A little help, please. <dave@sitesolve.com>
     Re: An Interesting CGI Problem ... <rootbeer@teleport.com>
     Are Perl perform well in NT Server Platform?? <lhchiu5@ie.cuhk.edu.hk>
     Re: ARGV question (brian d foy)
     Re: ARGV question <zenin@best.com>
     Re: ARGV question (Lloyd Zusman)
     Re: awk style field variables in perl <zenin@best.com>
     Re: awk style field variables in perl <joshua@ednet.co.uk>
     Re: CGI tools (brian d foy)
     Re: CGI tools <zenin@best.com>
     Re: detection of first execution since login <rootbeer@teleport.com>
     Re: Email the form information <rootbeer@teleport.com>
     Re: Encryption <amias@mindless.com>
     Re: Memory problems - how can I fix? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: Memory problems - how can I fix? <rootbeer@teleport.com>
     Perl module for system-independent "stty raw"? (Lloyd Zusman)
     Re: Perl module for system-independent "stty raw"? (dave)
     Re: Primes via regexen (Was: Re: non-greedy regexps) (Abigail)
     Question:DB2&Perl <choper@choper.demon.co.uk>
     Re: running a shell script through Perl without waiting (Jeremy D. Zawodny)
     Re: Sending a binary attachment with perl question? <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 26 Oct 1997 01:42:19 -0400
From: Jeremy Leigh <"jvleigh"@_no spam_kih.net>
Subject: A little help, please.
Message-Id: <62unhm$724$1@dbtsvr2.dbtech.net>

Hi,

I am very new to perl programming.  I have read books on it with not
alot of success.  So, I am now trying to learn by looking at the code
and trying to put in real terms what the code is doing.

I downloaded the FormMail script from MSA.  In studying it, I have a
couple questions my books do not help me answer completely.  Would
anyone mind helping me?

This is a code fragment from the subroutine check_url.
  
if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {

Here's what I think I understand:
The pattern on the left will be compared to what is on the right.
It will look for http(with or without an s)://(no extra single or
multiple /) $referer.
All letters can be any case.

Questions:
Why does it call for multiline pattern matching?
What special property does the | have as a delimiter in this expression?

I appreciate your help,

Jeremy Leigh


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

Date: Sun, 26 Oct 1997 01:04:19 -0700
From: "David Lawrence" <dave@sitesolve.com>
Subject: Re: A little help, please.
Message-Id: <62uqar$5gf$1@quartz.inquo.net>

Maybe using m|expression| instead of m/expression/ or /expression/ simply
lets you use slash characters without backticking them.  So, instead of
/https?:\/\// you have just |https?://|.

--------------------------------------
David Lawrence
Site Solutions
http://www.sitesolve.com/




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

Date: Sun, 26 Oct 1997 03:51:37 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: A little help, please.
Message-Id: <comdog-ya02408000R2610970351370001@news.panix.com>

In article <62unhm$724$1@dbtsvr2.dbtech.net>, jvleigh@kih.net wrote:

>I am very new to perl programming.  I have read books on it with not
>alot of success.  So, I am now trying to learn by looking at the code
>and trying to put in real terms what the code is doing.
>
>I downloaded the FormMail script from MSA.  

just as a word of caution - i would not recommend any of that code 
unless you want to pick up some heinously bad programming habits.

have you tried "Learning Perl" [1]?  besides being technically very good,
it's a very accessible and humorous read.  that is, if you know your
Flintstones trivia :)

[1]
Learning Perl
Randal L. Schwartz & Tom Christiansen
ISBN 1-56592-284-0 
<http://www.oreilly.com>

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sun, 26 Oct 1997 09:18:05 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: A little help, please.
Message-Id: <dvmv26.kr.ln@localhost>

Jeremy Leigh ("jvleigh"@_nospam_kih.net) wrote:

: I am very new to perl programming.  I have read books on it with not
: alot of success.  So, I am now trying to learn by looking at the code
: and trying to put in real terms what the code is doing.


"Mastering Regular Expressions" (www.ora.com) is  very helpful in
understanding regular expressions.

You can also read the perlre and perlop man pages for regex info.


: I downloaded the FormMail script from MSA.  In studying it, I have a
: couple questions my books do not help me answer completely.  


I don't know what MSA is, but I see some questionable things in the
regex below, so I'm inclined to believe Brian's comment.


: Would
: anyone mind helping me?

OK.


: This is a code fragment from the subroutine check_url.
:   
: if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {


Well, we don't have the whole pattern there, since we don't know
what $referer is meant to contain.

I'll try to explain the rest, but I'm not going to guess what the
value of $referer might be.


: Here's what I think I understand:
: The pattern on the left 
  ^^^^^^^^^^^

The left of the equal sign in not a pattern at all.

It is a string.


: will be compared to what is on the right.
: It will look for http(with or without an s)://

So far so good.


: (no extra single or
: multiple /) $referer.

No, the parenthesized part will match a sequence of zero or more
non-slash characters.


: All letters can be any case.

: Questions:
: Why does it call for multiline pattern matching?


It does not call for multiline pattern matching.


: What special property does the | have as a delimiter in this expression?


It is just a delimiter in this expression   ;-)

They could have chosen some other char with no change in behavior.

If you use slash as a delimiter, then perl will infer that you want
to do a pattern match. If you want to use some other delimiter char,
then you have to tell perl that it is a pattern match by using the
'm' at the beginning.

eg:

/match me/;  # default pattern match delimiter char

m/match me/; # default pattern match delimiter char

m!match me!; # alternative delimiter char

m{match me}; # "balanced" chars for delimiters


-------

What I find suspicious in the given regex:

1) no anchor at beginning of string

   m|^https?://([^/]*)$referer|i
     ^
     ^

2) no anchor at end of string

   m|https?://([^/]*)$referer$|i
                             ^
                             ^

3) no slash required after matching char class

   m|https?://([^/]*)/$referer$|i
                     ^
                     ^


4) not quoting the contents of $referer

   m|https?://([^/]*)\Q$referer\E|i
                     ^^        ^^


So, this _might_ be better:

   m|^https?://([^/]*)/\Q$referer\E$|i


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Sun, 26 Oct 1997 01:04:19 -0700
From: "David Lawrence" <dave@sitesolve.com>
Subject: Re: A little help, please.
Message-Id: <62vqgd$48v$1@quartz.inquo.net>

Maybe using m|expression| instead of m/expression/ or /expression/ simply
lets you use slash characters without backticking them.  So, instead of
/https?:\/\// you have just |https?://|.

--------------------------------------
David Lawrence
Site Solutions
http://www.sitesolve.com/




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

Date: Sun, 26 Oct 1997 07:46:32 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Bjorn Lindstrom <bjorn@realitynet.com>
Subject: Re: An Interesting CGI Problem ...
Message-Id: <Pine.GSO.3.96.971026074201.12522H-100000@usertest.teleport.com>

On Sat, 25 Oct 1997, Bjorn Lindstrom wrote:

> But if a user enters HTML code (like a URL), the rest of the information
> that they typed into the TEXTAREA is lost, including the URL.

If you're not using valid HTML, you should fix that. If your HTML is valid
but your browser isn't doing the right thing, you should complain to the
author of the browser. If your browser is sending the right information
but your server isn't passing it on to your CGI script, you should
complain to your webmaster. If your script is getting the right
information but isn't dealing with it properly, you need to debug your
script. In that case, I recommend using the CGI.pm module (or a similar
one) so that you can use Perl's interactive debugger. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 26 Oct 1997 21:12:31 +0800
From: Kevin <lhchiu5@ie.cuhk.edu.hk>
Subject: Are Perl perform well in NT Server Platform??
Message-Id: <345341BF.5FF5EA04@ie.cuhk.edu.hk>

I want to write a CGI program on Window NT platform. Is Perl perform
well on NT plaform??



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

Date: Sun, 26 Oct 1997 01:06:51 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: ARGV question
Message-Id: <comdog-ya02408000R2610970106510001@news.panix.com>

In article <3452742E.50BC@coos.dartmouth.edu>, rjk@coos.dartmouth.edu wrote:

>Nem W Schlecht wrote:
>> 
>> $len = scalar @ARGV;    # using '$len = @ARGV' is bad, because if @ARGV
>>                         # contains only one element, $len will be set to
>>                         # that instead of '1'
>
>Whereever did you get that crazy idea from?
>
>Using '$len = @ARGV' already puts @ARGV in a scalar context.
>In this case, specifying scalar() explicitly doesn't accomplish
>anything.

sure it does.  imagine reading through someone else's code and not
understanding a section like

   my @x;

   $x = @ARGV;

with lots of other stuff going on around those lines.  as a code reviewer
you wonder if the programmer meant to use the scalar context, especially
since there an array variable of the same name in scope [1].

to make it clear what you are trying to do, you explicity state the 
context by using scalar.  the code is easier to maintain on your part
so when you look at your creation three days later you know what you
were trying to do, and the code reviewer knows that you weren't sloppy
with your thingys (i.e. $,@,%).

in this case, my programmers must use scalar() - it's part of the
corporate Perl style guide.

if you really want to pick nits, you should demonstrate that the 
text in the comment is incorrect.


[1]
i think one of the perl purity test questions deals with using $x, @x, and
%x all within the same script...

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 26 Oct 1997 05:42:19 GMT
From: Zenin <zenin@best.com>
Subject: Re: ARGV question
Message-Id: <62ul7r$3co$3@nntp2.ba.best.com>

Chipmunk <rjk@coos.dartmouth.edu> wrote:
> Nem W Schlecht wrote:
> > $len = scalar @ARGV;    # using '$len = @ARGV' is bad, because if @ARGV
> >                         # contains only one element, $len will be set to
> >                         # that instead of '1'
> Whereever did you get that crazy idea from?

	Probably from doing something like:
		my ($len) = @ARGV;  ## $len is now == $ARGV[0]
	
> Using '$len = @ARGV' already puts @ARGV in a scalar context.
> In this case, specifying scalar() explicitly doesn't accomplish
> anything.

	Except to make the code easier to read, maintain, debug, etc.

	When flying through hundreds of lines of code looking for a
	bug, are these differences really going to catch your eye?
		my ($foo) = @bar;
		my $bar   = @bar;
		my $cat   = scalar @bar;
		my ($dog) = scalar @bar;

	The last three all do the same thing, but if you don't state
	scalar when you meen it you're just asking for trouble.  It also,
	BTW, does nothing to effect runtime to add it.
-- 
-Zenin (zenin@best.com)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Archive (Moving soon!)              http://www.best.com/~zenin/



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

Date: 26 Oct 1997 14:29:37 GMT
From: ljz@asfast.com (Lloyd Zusman)
Subject: Re: ARGV question
Message-Id: <slrn656ksv.hk.ljz@ljz.asfast.net>

On 26 Oct 1997 05:42:19 GMT, Zenin <zenin@best.com> wrote:
> Chipmunk <rjk@coos.dartmouth.edu> wrote:
> > 
> > [ ... ]
> >
> > Using '$len = @ARGV' already puts @ARGV in a scalar context.
> > In this case, specifying scalar() explicitly doesn't accomplish
> > anything.
> 
> 	Except to make the code easier to read, maintain, debug, etc.
> 
> 	When flying through hundreds of lines of code looking for a
> 	bug, are these differences really going to catch your eye?
> 		my ($foo) = @bar;
> 		my $bar   = @bar;
> 		my $cat   = scalar @bar;
> 		my ($dog) = scalar @bar;
> 
> 	The last three all do the same thing, but if you don't state
> 	scalar when you meen it you're just asking for trouble.  It also,
> 	BTW, does nothing to effect runtime to add it.

I'm in wholehearted agreement.  Just because a programming construct
is redundant doesn't mean that it shouldn't be used.  Given the fact
that other people might some day have to maintain the code I write, I
try to use certain constructs to help clarify the intent of what I'm
doing.  The use of an explicit 'scalar' to extract the number of
elements in a list is one such construct.

I also tend to do this with other Perl constructs.  For example, the
following two conditionals are equivalent in Perl, but I usually
prefer to use the second one to help it be more clear to people as to
whether 'func' will actually get called:

1.   open(F, "<$file") or func($a, $b, $c);

2.   unless (open(F, "<$file")) {
        func($a, $b, $c);
     }

The use of an explicit "<" in the above 'open' statements is yet another
example of this.

[stepping onto soap box]

The question often boils down to whether it's more important to me to
simply save some of my own time and effort during coding, or whether I
want to help other people in the future save time and effort (and
money, in the case of my employer who might have to pay for this
time).

Perl often gives us more than one way to do a given thing, much to
its credit.  This gives us programmers more opportunities to choose
the clearest and most easily maintainable constructs when writing
our code than we have in many other languages.

Of course, if one desires obscurity in ones code, Perl provides a
cornucopia of constructs that can be used towards that end, as well.
Perhaps you are teaching Perl and want to make sure that your students
are aware of all of its power, or perhaps you want to write a JAPH, or
perhaps you want to impress somone with your esoteric knowledge, or
perhaps you want to blackmail your boss into not laying you off by
writing vast quantities of code that only you are able to maintain.
And I'm sure that there are other reasons for writing obscure code,
and if any of these apply to you, Perl is a wonderful tool to use for
this purpose.

Some of you may have noticed that I didn't mention run-time
efficiency, and this is deliberate. In most cases, I don't consider
the cost of a the machine cycles saved by using a more obscure Perl
construct to be able to offset the cost of paying someone to decipher
this code some time in the future.  I generally go by the adage, "As
time goes on, computer time gets cheaper, and man-hours get more
expensive." And in applications where run-time efficiency does happen
to be of paramount importance, I recommend detailed and complete
commenting of those sections of code where difficult-to-understand
constructs are used.  Of course, in time-critical applications such as
these, it sometimes is better in the first place to use a compiled
language rather than an interpreted language such as Perl.

In general, then, I say this: when in doubt, choose the clearest and
most easily maintainable constructs when writing code.

[stepping down from soap box]


-- 
 Lloyd Zusman
 ljz@asfast.com


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

Date: 26 Oct 1997 05:32:32 GMT
From: Zenin <zenin@best.com>
Subject: Re: awk style field variables in perl
Message-Id: <62uklg$3co$2@nntp2.ba.best.com>

Waqar Hafiz <waqar.hafiz@virgin.net> wrote:
> In awk, fields within each record/line can be accessed
> through awk variables $1, $2 ...
> Is there such mechanism in perl?

	If you want to have it as a one liner, use the -F and -a
	options to "autosplit" the lines.

	If it's in a larger program, call split() yourself.

	#!/usr/local/bin/perl -w
	while (<>) {
		# Split on white space.
		my @fields = split ' ', $_;

		# BTW, the above can also be short cutted as just:
		my @fields = split;
		# Because white space and $_ is the default.

		# Print first element
		print "$fields[0]\n";

		# Print fields in reverse
		print join (' ', reverse @fields), "\n";

		# Print first three fields
		print "@fields[0..2]\n";
	}

	$ foo.pl test.txt
	foo
	that this bar foo
	foo bar this

	See also: perldoc -f split
	
-- 
-Zenin (zenin@best.com)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Archive (Moving soon!)              http://www.best.com/~zenin/


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

Date: 26 Oct 1997 10:37:39 GMT
From: Joshua Goodall <joshua@ednet.co.uk>
Subject: Re: awk style field variables in perl
Message-Id: <62v6hj$qp8$1@monteverdi.ednet.co.uk>

In comp.lang.perl.misc Zenin <zenin@best.com> wrote:
> 	If you want to have it as a one liner, use the -F and -a
> 	options to "autosplit" the lines.

One of the best ways, here's an example:

perl -lane 'print if $F[9] =~ /tcp/;'

which is a one-line version of a 200-line program that made Cisco security outputs
useful. Remember that Perl's base is 0, so use $F[9] where awk would have used
$10. The -l is useful in one-liners for automatic chomping etc.

> 		# Split on white space.
> 		my @fields = split ' ', $_;

> 		# BTW, the above can also be short cutted as just:
> 		my @fields = split;
> 		# Because white space and $_ is the default.

Almost but not quite accurate. The default split is on \s+ - which means that
consecutive whitespaces are ignored. I only remember this when I've been
calling split on a syslog output and it doesn't work right for the first ten
days of the month.

ZZ:wq

-- 
Joshua Goodall <joshua@ednet.co.uk>                Edinburgh's local ISP:
edNET Admin Group / Newsmaster                   http://www.ednet.co.uk/

                              ...I am not a number, I am a free(3) man(1)


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

Date: Sun, 26 Oct 1997 00:54:11 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: CGI tools
Message-Id: <comdog-ya02408000R2610970054110001@news.panix.com>

In article <62u9gq$qhj$3@nntp2.ba.best.com>, Zenin <zenin@best.com> wrote:

>Connie Wang <c0w0461@unix.tamu.edu> wrote:
>> What's the advantage or disadvantage of Perl over other CGI tools
>
>        Perl is not a "CGI tool".

sure it is - as much as a hammer is a carpentry tool.  hammers are
used for more than carpentry, and Perl is used for more than CGI.

this question is analagous to someone walking into a store and asking
why your product is better than the others.  no sales person is his or
her right mind is going to quibble over pedantic distinctions ;)

however, the computer consultant's next question is "what do you want to
do and what resources do you have available?"  once one knows that, a
proper answer can be given.  despite any religious beliefs, Perl is not
always the best solution (just 99% of the time ;) ).

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 26 Oct 1997 05:24:37 GMT
From: Zenin <zenin@best.com>
Subject: Re: CGI tools
Message-Id: <62uk6l$3co$1@nntp2.ba.best.com>

brian d foy <comdog@computerdog.com> wrote:
> In article <62u9gq$qhj$3@nntp2.ba.best.com>, Zenin <zenin@best.com> wrote:
> >        Perl is not a "CGI tool".
> sure it is - as much as a hammer is a carpentry tool.  hammers are
> used for more than carpentry, and Perl is used for more than CGI.

	Good point.

> despite any religious beliefs, Perl is not
> always the best solution (just 99% of the time ;) ).

	Actually, it's 99.9949438% of the time. -Remember, Perl does all
	it's math with floats by default. :-)

-- 
-Zenin (zenin@best.com)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Archive (Moving soon!)              http://www.best.com/~zenin/


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

Date: Sun, 26 Oct 1997 07:57:43 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Chenyang Xu <chenyang@mashie.ece.jhu.edu>
Subject: Re: detection of first execution since login
Message-Id: <Pine.GSO.3.96.971026075009.12522K-100000@usertest.teleport.com>

On Sat, 25 Oct 1997, Chenyang Xu wrote:

> On UNIX, is there a way for a perl script to find out whether its
> current execution is the first execution since the recent user login?

In general, no, since Unix doesn't remember what programs have been run.
In practise, though, you might be able to get what you need. For example,
you could call the script from .profile (or whatever) so that it's run
upon startup. If that won't do what you want, can you let us know what
you're trying to accomplish? Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 26 Oct 1997 07:47:18 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Connie Wang <c0w0461@unix.tamu.edu>
Subject: Re: Email the form information
Message-Id: <Pine.GSO.3.96.971026074648.12522I-100000@usertest.teleport.com>

On Sat, 25 Oct 1997, Connie Wang wrote:

> I know there is a email function, 

Perl doesn't have an email function, but there are some modules on CPAN
which may do what you want. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 26 Oct 1997 15:34:55 +0000
From: Amias <amias@mindless.com>
Subject: Re: Encryption
Message-Id: <3453631F.283D@mindless.com>

Hello brian ,

Please could you tel me about the encryption code you mentioned
Thanks for the response
-- 
Toodle-pip
Amias

http://www.homeusers.prestel.co.uk/amias
ICQ 3099152
Anyone spamming me _will_ have problems with their server


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

Date: Sun, 26 Oct 97 10:20:34 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Memory problems - how can I fix?
Message-Id: <34536020$1$ofn$mr2ice@speaker>

In <wwolfeEIMvyv.LG5@netcom.com>, on 10/26/97 at 12:56 AM,
   wwolfe@netcom.com (Ryan) said:
+-----
| I have a bit of code that does a wonderful job of sucking up
| tons of memory when I don't really think it should.

| for (1..100000) {
+--->8

You are aware that "1 .. 100000" builds a list containing the elements "1",
"2", ... "99999", "100000" and then iterates over that list?

-- 
brandon s. allbery              [Team OS/2][Linux]          bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                 KF8NH
Warpstock '97:  OS/2 for the rest of us!  http://www.warpstock.org
Memo to MLS:  End The Burn Scam --- Doug Logan MUST GO!  FORZA CREW!



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

Date: Sun, 26 Oct 1997 08:01:25 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ryan <wwolfe@netcom.com>
Subject: Re: Memory problems - how can I fix?
Message-Id: <Pine.GSO.3.96.971026075857.12522L-100000@usertest.teleport.com>

On Sun, 26 Oct 1997, Ryan wrote:

> I have a bit of code that does a wonderful job of sucking up
> tons of memory when I don't really think it should.

> for (1..100000) {

In the current implementation, that line will create a list of 100000
scalars, and keep that list around until the end of the loop. Ouch! :-)

   for ($_ = 1; $_ <= 100000; $_++) {

Does that fix things for you? Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 26 Oct 1997 04:09:35 GMT
From: ljz@asfast.com (Lloyd Zusman)
Subject: Perl module for system-independent "stty raw"?
Message-Id: <slrn655gb6.hk.ljz@ljz.asfast.net>

I looked through CPAN, and I haven't been able to find what I'm
looking for: a Perl module which will allow me to do an "stty raw", an
"stty sane", etc. in a system independent manner.  Furthermore, I
would like to do this totally within my Perl process, and therefore I
want to avoid using "system('stty raw')".

I can do this via ioctl, but that involves writing several versions of
my code, given the variations of ioctl among the various systems out
there ... for example, one of the systems I'm running is Linux, and
the standard BSD and SYSV ways of doing "stty raw" and "stty sane" via
ioctl don't seem to work on that particular system.

I don't need all the esoteric stty commands.  If I could have
system-independent, Perl versions of the "raw", "echo", "-echo", and
"sane" stty functions, I'd be happy.

Any ideas?

Thanks in advance.

-- 
 Lloyd Zusman
 ljz@asfast.com



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

Date: Sun, 26 Oct 1997 14:02:43 GMT
From: over@the.net (dave)
Subject: Re: Perl module for system-independent "stty raw"?
Message-Id: <34534cea.801795@news.one.net>

ljz@asfast.com (Lloyd Zusman) wrote:


>I don't need all the esoteric stty commands.  If I could have
>system-independent, Perl versions of the "raw", "echo", "-echo", and
>"sane" stty functions, I'd be happy.
>
>Any ideas?

My curses libarary for HPUX provides a raw mode.  There is a curses module for
Perl but I'm not sure whether it supports raw mode and if it does on which
platforms.  I'm having trouble with the C curses library on HPUX 10.


Dave
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________


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

Date: 26 Oct 1997 06:17:14 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Primes via regexen (Was: Re: non-greedy regexps)
Message-Id: <slrn655o74.e7.abigail@betelgeuse.wayne.fnx.com>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on 1517 September 1993
in <URL: news:62uaf7$aub$1@agate.berkeley.edu>:
++ In article <slrn6533dm.e7.abigail@betelgeuse.wayne.fnx.com>,
++ Abigail <abigail@fnx.com> wrote:
++ > I get the following results:
++ > 
++ > 3000 (abi) : 230 secs (229.75 usr  0.02 sys = 229.77 cpu)
++ > 3000 (john): 222 secs (221.78 usr  0.00 sys = 221.78 cpu)
++ > 
++ > 
++ > The (11+?) marginally better, but much less than I expected it to be.
++ 
++ Why?  As many people explained, minimal-repeaters (applied for simple
++ nodes) are slower (per try) than the usual ones.  

They might be slower per try, but shouldn't it take a lot less tries?

Take for instance '11111111'. 

Match that with '^(11+)\1+$'. Regex machine gobbles up all 8 1's, then
has to backtrack to 4 1's till it finally finds one that satisfies the \1+.
But for '^(11+?)\1+$' the regex machine first try for (11+?) is '11',
which is a satisfying \1.

There might be some neat optimization based on length going on that
I'm not aware of though.

I'm afraid both my news server and dejanews missed the explainations
of many people.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^(11+?)\1+$/'


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

Date: Sun, 26 Oct 1997 12:16:28 +0000
From: choper <choper@choper.demon.co.uk>
Subject: Question:DB2&Perl
Message-Id: <uZsPVDAcSzU0Ew9M@choper.demon.co.uk>

Hi,

sorry if this has been asked and answered before but I've only just
started picking up this newsgroup. My problem is this, I have a DB2
database on an AS400 wich we want to extract information from and
display as dynamic web pages. Now I know this can be done using a
product called Net.Data, but what I wanted to know was is it possible to
do this using Perl ? If it is how do I go about it ? ( I'm really new to
Perl btw.....nothing like leaping in at the deep end :)

Any help would be gratefully excepted, either via email or the
newsgroup.

Thanks.

Mark


  _______                                             
 / ___/ /  ___  ___  ___ ____                    
/ /__/ _ \/ _ \/ _ \/ -_) __/mark@cheese.org      
\___/_//_/\___/ .__/\__/_/@choper.demon.co.uk    
             /_/


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

Date: Sun, 26 Oct 1997 13:50:14 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: running a shell script through Perl without waiting for the return status
Message-Id: <34554a76.42635356@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On 25 Oct 1997 17:54:22 GMT, pramanujam@aol.com (PRamanujam) wrote:

>If I have a benchmark program which I wish to run for save 10 to 15 iterations
>How Do I achieve this in perl

Why not look at the Benchmark module?

perldoc Benchmark

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Sun, 26 Oct 1997 07:49:28 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Barry Kaplan <barry@megaspace.com>
Subject: Re: Sending a binary attachment with perl question?
Message-Id: <Pine.GSO.3.96.971026074828.12522J-100000@usertest.teleport.com>

On Fri, 24 Oct 1997, Barry Kaplan wrote:

> Is it possible to send a binary attachment using the mailto statement in
> perl? If so, can someone show me an example of this? Thanks.

Perl doesn't have a mailto function, although that's probably available
through some module you're using. If the module's docs aren't adequate, or
if the module's abilities are less than you need, you should contact its
author. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

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

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