[8243] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1860 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 11 15:15:23 1998

Date: Wed, 11 Feb 98 12: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, 11 Feb 1998     Volume: 8 Number: 1860

Today's topics:
    Re: "Teach Yourself Perl in 21 days" (Was: Re: substitu (Dave Till)
    Re: Code Example Needed (Eileen Kortright)
        Expanding Filenames? (Brian C. Ladd)
    Re: Expanding Filenames? (Nathan V. Patwardhan)
    Re: Expanding Filenames? <tchrist@mox.perl.com>
    Re: garbage collection in perl (Craig Berry)
    Re: garbage collection in perl <tchrist@mox.perl.com>
    Re: GDBM_File question <mike@ns.minivend.com>
    Re: Hashes Usage <SNIPhsommer@micro.ti.comSNIP>
        help needed <herac@xs4all.nl>
        Help Please. Perl Win32, ODBC, Memory Problems <moc.care@hcajp - Reverse to get address>
    Re: Help with code.........!! (Steve Linberg)
    Re: how do I mail results in perl? <webmaster@fccj.cc.fl.us>
    Re: How generate counter? chris+usenet@netmonger.net
    Re: How to receive the output of a file upload form? <jdporter@min.net>
        Metacharacters - Advice please. (User)
    Re: Metacharacters - Advice please. <tchrist@mox.perl.com>
    Re: Metacharacters - Advice please. (Mike Stok)
    Re: Metacharacters - Advice please. (User)
    Re: Metacharacters - Advice please. <tchrist@mox.perl.com>
    Re: My Module:  To release or not to release... (Steve Linberg)
        Of Cards, Spindles, and Sealing wax Re: already off top wdr@world.std.com
        perl -d core dump 5.004_04 <steves@wco.com>
    Re: perl -d core dump 5.004_04 <steves@wco.com>
    Re: Sharing variables between scripts <webmaster@fccj.cc.fl.us>
    Re: test!! please ignore this message i am seeing if it <kaleja@rahul.net>
    Re: test!! please ignore this message i am seeing if it <tchrist@mox.perl.com>
    Re: The 'study' function (Ian Kallen)
    Re: To All Perl Guru's (Craig Berry)
    Re: Too simple to ask but then .... <webmaster@fccj.cc.fl.us>
    Re: Year 2000 Compliance: Lawyers, Liars, and Perl (Craig Berry)
    Re: Year 2000 Compliance: Lawyers, Liars, and Perl (I R A Aggie)
    Re: Year 2000 Compliance: Lawyers, Liars, and Perl (John Stanley)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 11 Feb 1998 13:09:05 -0500
From: davet@angel.uunet.ca (Dave Till)
Subject: Re: "Teach Yourself Perl in 21 days" (Was: Re: substitute...)
Message-Id: <6bspg1$gmj@angel.uunet.ca>

>Tom Phoenix wrote:
>
>> I had heard Randal claim that he could start at any random page in that
>> book and find a serious error of fact within four pages. It was hard for
>> me to believe that it could be that bad. So, when a student in one of my
>> classes had a copy, I asked to borrow it. I figured that, although I'm not
>> up on every detail as much as Randal, maybe I could spot an error or two.
>>
>> I flipped it open at random.
>>
>> The first function described in the first paragraph of the first page I
>> opened to listed the function's two parameters in the wrong order.
>>
>> I gave the book back.
>>
>> Although it's too small a sample to be statistically useful, I can now say
>> that 100% of the information I've checked from that book is wrong. :-)

Tom:  do you remember, offhand, what that function was?  I don't know of
any functions that have their parameters listed in the wrong order (if I
did, I'd get their descriptions fixed :-)).  I am honestly interested in
making the book as accurate as I can (given the constraint that I don't
control much of the production process).

As regards the "one error in four pages" claim:  my errata list is on
the web at "http://www.net/~davet/errata52.html".  It's up to date except
for Tom Grydeland's comments (posted recently).  I think I'm doing better
than "one in four", though I may be missing some. :-)

--Dave Till
davet@uunet.ca


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

Date: Wed, 11 Feb 1998 18:02:27 GMT
From: mystra@torilmud.com (Eileen Kortright)
Subject: Re: Code Example Needed
Message-Id: <34e1e033.228020246@news.mw.mediaone.net>

On 11 Feb 1998 14:29:22 GMT, Tom Christiansen <tchrist@mox.perl.com>
wrote:

>I'm afraid that you haven't given a clear enough question there for
>me to understand what you mean.  I suspect that you need to think more
>about the problem first.  Are you trying to figure out the appropriate
>data structure?  What should it contain?  How should it be accessed?

Hrm, I was afraid of this. Kay, I'll post exactly what it is I'm
trying to do further down. I didn't because I was "afraid" that:

	a) I would be made fun of
	b) I would appear stupid

No one likes either.

And thank you for your post, I appreciate it very much.

>Without well thought-out data structures and access methods, programs are
>virtually impossible.  With them, they are easy.  A venerable textbook
>that goes by the title "Algorithms + Data Structures = Programs" extolls
>this point quite well.  Perhaps you should get it.

Is this book written in English? :P

>Now, how do you go about choosing the proper Perl data structure?
>Here's a tip for you:
>
>
>    You're thinking                                         Use
>    -------------------------------------------             -----
>
>       anything ordered, like vector, array, list, tuple => @ARRAY
>  unordered relation, set, bag, record, structure, table => %HASH
>
>When you have a complex relation, such as a lookup table of lists of
>records, you need to think about which of the two fundamental data
>structures to use at each different level.  I suspect that what you
>need to do here is maintain a homogeneous data structure, probably a
>hash of arrays.  You would index this hash using the date, and that
>would produce an ordered list of events.  If that's what you're going
>to be using, you should make yourself comfortable with accessing this
>structure: reading it, searching in it, sorting it, writing it out,
>selecting only those elements a particular criterion, etc.  Examples of
>this can be found in the perldsc manpage, or chapter 4 of the caerulean
>Camel (blue book edition :-).

I thought carefully about what you said and evaluated what I was doing
-- and I think I'm on the right track. *think* :P

Now, I'm an old dBase III programmer. Old as in both terms of the
word. Things have changed quite a bit since then, but Perl resembles
the scripting language quite a bit. So, forgive me if I use database
terms here and there.

Okay, here's the scope:

In Forgotten Realms (TSR AD&D Campaign set):

standard year = 365 days
twelve months= 1 year
one month = 30 days
one week = 10 days (called a "Ten Day", not a week)

There are five days left over and each one of these days can be said
to be a "month" unto itself. It doesn't belong to any month but stands
on its own as a day of "worship" -- usually in respect to a change of
seasons.
Example: What would be January 31 is actually Midwinter Day and
belongs to no month.

Every 4 years is a leap year and that sixth day is called "Shieldmeet"
and is treated like one of the five.

Program does this: calculates what the FR day would be in relation to
the current real life day. Ie: January 1 would be Hammer 1. The result
is printed into a nicely formatted web page. The CGI, and thus, the
web page, is the EASY part :P

Later on I plan on putting the entire calendar in with notes on events
that will or have transped in Forgotten Realms. First things first,
tho.
	
Here's my current array for yer viewing pleasure:

%fr_months =
		 ( 	1..30,"Hammer",
		    	31,"Midwinter",
			 32..61,"Alturiak",
			 62..91,"Ches",
			 92..121,"Tarsakh",
			 122,"Greengrass",
			 123..152,"Mirtul",
			 153..182,"Kythorn",
			 183..212,"Flamerule",
			 213,"Midsummer",
			 214..243,"Eleasias",
			 244..273,"Eleint",
	       	       	 274,"Higharvesttide",
		        	275..304,"Marpenoth",
        			305..334,"Uktar",
        			335,"Moonfest",
        			336..365,"Nightal",
        			366,"Shieldmeet"
		       );

The keys are the range of numbers or Julian year dates that the FR
month covers. The values are the FR months. Now, here's what is
supposed to happen:

Take value of the Julian year date (example: today is the 42nd day of
1998)
Result:	$Julian=42

Go through the values field and locate the element equivilent of "42" 
Result:	 32..61,"Alturiak"

Get the key (month) from that pairing.
Result: 	Alturiak

Take the Julian date to the lowest value of the current key range and
subtract the key from the Julian date
		
Result: 42-32= 10

The date is: the 10th day of Alturiak 

This make sense? Is there a better way?
Now, I've not seen an array with a key range in it like I have here
but Perl doens't seem to be choking on it. 

>The remainder of your message I shall address under separate cover.

Oh, boy. *cringe*

>	Tom Christiansen	tchrist@jhereg.perl.com
>If you consistently take an antagonistic approach, however, people are
>going to start thinking you're from New York.   :-)

Canada, but I've been living in Michigan far too long :P




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

Date: 11 Feb 1998 18:32:58 GMT
From: ladd@baldhead.cs.unc.edu (Brian C. Ladd)
Subject: Expanding Filenames?
Message-Id: <LADD.98Feb11133258@baldhead.cs.unc.edu>

How do I open a file named with shell metacharacters? For example:

    $fname = '~ladd/public_html/index.html';
    open(FH, "<$fname");

It would be nice if this actually opened /sbin1/usr/ladd/public_html/...
(or whatever it is; I have no way of knowing what the prefix is for every
user I might want to expand). I have a nasty solution using a spawned ls
and I assume it is the wrong answer.

Anybody have a pointer to the right answer?

advTHANKSance

-bcl
--
Brian C. Ladd                                                 bcl Consulting &
www.cs.unc.edu/~ladd/                                           On-line Design




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

Date: 11 Feb 1998 19:31:57 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Expanding Filenames?
Message-Id: <6bsubd$abr@fridge.shore.net>

Brian C. Ladd (ladd@baldhead.cs.unc.edu) wrote:
: How do I open a file named with shell metacharacters? For example:

:     $fname = '~ladd/public_html/index.html';
:     open(FH, "<$fname");

Unless I've completely missed your question, what's wrong with
$ENV{'HOME'}?  Are you trying to open the ~ of other people, too?

--
Nathan V. Patwardhan


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

Date: 11 Feb 1998 19:45:25 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Expanding Filenames?
Message-Id: <6bsv4l$hjt$3@csnews.cs.colorado.edu>
Keywords: FAQ chastisement

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, ladd@baldhead.cs.unc.edu (Brian C. Ladd) writes:
:How do I open a file named with shell metacharacters? For example:
:    $fname = '~ladd/public_html/index.html';
:    open(FH, "<$fname");
:Anybody have a pointer to the right answer?

You mean beyond this one?

    % man perlfaq5
    ...
    How can I translate tildes (~) in a filename?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

"Make is like Pascal: everybody likes it, so they go in and change it. "
	    --Dennis Ritchie


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

Date: 11 Feb 1998 17:49:39 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: garbage collection in perl
Message-Id: <6bsobj$55n$2@marina.cinenet.net>

? the platypus {aka David Formosa} (dformosa@st.nepean.uws.edu.au) wrote:
: In <6bp1re$7k$2@marina.cinenet.net> cberry@cinenet.net (Craig Berry) writes:
: 
: >Also, Perl never returns any
: >memory to the OS (it keeps it in a pool for reuse instead),
: 
: Is this a perl thing or an OS thing?

Perl thing.  Many OSs allow apps to release heap memory so that other 
apps can use it.  However, in most circumstances Perl's way is better.
Doing OS-visible heap releases tends to be a high-overhead, low-profit 
operation.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 11 Feb 1998 18:53:46 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: garbage collection in perl
Message-Id: <6bss3q$e99$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, cberry@cinenet.net (Craig Berry) writes:
:Perl thing.  Many OSs allow apps to release heap memory so that other 
:apps can use it.  However, in most circumstances Perl's way is better.
:Doing OS-visible heap releases tends to be a high-overhead, low-profit 
:operation.

It can be easily shown that this is in theory feasible

    #define SIZE (10 * 1024 * 1024)
    main() {
	ps(); sbrk( SIZE);
	ps(); sbrk(-SIZE);
	ps();
    } 
    ps() {
	static char str[200];
	sprintf(str, "ps l%d", getpid());
	system(str);
    } 

The issue, as you Craig seem to be aware, is that just because you can
move the end point doesn't mean that you can easily fix the midpoints.

It's really very much like a text file.  You want to remove a few words
here and there.  Well, you can't actually do that, although you could
change where EOF fell.  You have to make a new copy, crunch down, then
truncate.  

malloc() is seldom amenable to that kind of thing, and even if it is,
you can bet your program isn't.  And how are you going to go find how
all the myriad places that mention those pointers and change *them*?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


Remember why the good Lord made your eyes -- Pla-gi-a-rize! --Tom Lehrer


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

Date: 11 Feb 1998 18:02:44 GMT
From: Mike Heins <mike@ns.minivend.com>
Subject: Re: GDBM_File question
Message-Id: <6bsp44$2vv$2@ocoee.iac.net>

Curt Siffert <siffert@tangrams.com> wrote:
> I wrote a script that created a gdbm file on one machine.
> I have another script that counts the rows by getting the
> scalar value of "keys" once it opens it.

> I've sinced moved the gdbm file to another machine.
> It was on Solaris, now it's on FreeBSD.  The same
> counting script (appended below) isn't able to open the file
> anymore.  It craps out on the "dbmopen" command
> (which I'm using instead of tie), by saying that the
> file doesn't exist - although it does pass the -e test.

> Can anyone tell me why?  Is the format of a gdbm file
> system dependent or something?  I really wanted to be
> able to just port these gdbm files over to another machine.

What you want and what you get are sometimes two different
things. 8-)

GDBM is byte-order dependent. You might have made a move from
one big-endian to another, but not from big-endian to 
little-endian.

DB_File is the only byte-order independent DBM supported by
Perl, I believe. Maybe the only one around.

Regards,
Mike Heins                          http://www.minivend.com/  ___ 
                                    Internet Robotics        |_ _|____
Few blame themselves until they     131 Willow Lane, Floor 2  | ||  _ \
have exhausted all other            Oxford, OH  45056         | || |_) |
possibilities.                      <mikeh@minivend.com>     |___|  _ <
 -- anonymous                       513.523.7621 FAX 7501        |_| \_\


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

Date: Wed, 11 Feb 1998 12:23:32 -0600
From: Holly Sommer <SNIPhsommer@micro.ti.comSNIP>
Subject: Re: Hashes Usage
Message-Id: <34E1ECA4.31816C9C@micro.ti.comSNIP>

Steve Linberg wrote:

: I doubt anyone can give a clearer explanation of these data structures
: than you'll find in the book.  Type the examples in yourself and play 
: with them.  You'll get it.

OK, after some fiddling, it seems that an array of hashes fits the
model better, but I have a couple of new questions.

My fields are (for example): name, venue, dates and descript
They are delimited from their values with a colon (:), in each record.
The dates field will be read in as one line, from the dB file,
but that line actually represents a space-delimited array of dates.
The descript field is a multi-line entry.

So, I have:

@records = (
   {
      name => $name,
      venue => $venue,
      dates => ???,
      descript => ???
   }
);

My questions are these:

For the dates element, if I read it in as a line (dates => $dates), 
and then @dates = split( / /, $dates) , how do I reference the
individual
elements of the @dates array, which is in a hash, which is in an array
of hashes? $records[$i]{$dates[$k]} ?

How do I get a multi-line value associated with one key?

Thanks :)

-Holly


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

Date: Wed, 11 Feb 1998 20:24:26 +0100
From: herac <herac@xs4all.nl>
Subject: help needed
Message-Id: <34E1FAEA.A1F15088@xs4all.nl>

I would like to replace all the string wich like <font face="wp
multinational roaman" size=4> and also the other font sizes and sizes
wich i dont know
can somebody help me pls
herac@xs4all.nl



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

Date: Wed, 11 Feb 1998 13:41:05 -0600
From: "Phil Jach - Reverse to get address" <moc.care@hcajp - Reverse to get address>
Subject: Help Please. Perl Win32, ODBC, Memory Problems
Message-Id: <34e1fee2.0@news1.ibm.net>

I've written a script that checks the security event log on a lot of NT
servers using Win32::EventLog.  After I scan the event log for certain Event
ID's I output the results to two locations.  One is a generic ASCII text
file and the other is an Access 95 database table using Win32::ODBC to
insert the data.  Now here's the problem.

When the script is running, I can look at the task manager and watch the
process running.  The memory the process is using keeps increasing until the
script completes or crashes.  On a PC running 32MB, it will crash with out
of memory on the ODBC connection and a message from NT saying you are
running low on virtual memory.  On a PC with 64MB it will make it through
but uses almost all the systems virtual memory and brings the system to a
crawl.

Here is a code fragment showing the writing of the data:
The program is too large to post.

Code fragment...
 .
 .
 .
&OPEN_DB();
# A sub to open the ODBC connection.

$command = # Leaving this data out.
# $command is the SQL command that will be used below.  Trust me it works.
I've written 11,000+ records using it.

$db->Sql( $command );
$db->Close();  # closes the ODBC connection.

# Here the same data is appended to a text file.
open (RESULTS, ">>SecurityLog.txt") || die "Can't create report: $!\n";
print (RESULTS "$command\n");
close (RESULTS);
 .
 .
 .

After the data is written to it's locations the program loops again and
starts on the next server.

I can say this, that before it ever gets to the next server it has already
started eating up memory with the data it's pulling out of the event log.

The program works.  It puts the data in the specified places but uses way to
much memory.  To the point it will either crash the script or bring the
system to a crawl.

Is there something I'm not doing in my script to release memory that the
variables were occupying after the data was written?

Is there some kind of flush that needs to occur or a reset?

The variables get new data placed in them on every pass of the loop.

I can clarify if you need too.  email: pjach"AT"erac.com.

Change the "AT" to @.  "Duh!!"

Thanks for the help.







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

Date: Wed, 11 Feb 1998 13:24:01 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Help with code.........!!
Message-Id: <linberg-1102981324010001@projdirc.literacy.upenn.edu>

In article <6brrtp$pkv@argentina.earthlink.net>, you@somehost.somedomain
(asdf) wrote:

> I am having problems understanding the mechanics of the following code:

<expletive-laden code deleted>

Try being a little more polite with what you post, and you will be less
likely to piss people off and get killfiled and ignored.

-- 
Steve Linberg                  |    National Center on Adult Literacy
Systems Programmer etc.        |           University of Pennsylvania
linberg@literacy.upenn.edu     |        http://www.literacyonline.org


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

Date: Wed, 11 Feb 1998 13:26:32 -0500
From: "Webmaster" <webmaster@fccj.cc.fl.us>
Subject: Re: how do I mail results in perl?
Message-Id: <34e1ee79.0@usenet.fccj.cc.fl.us>

Original Author CC'ed and answer posted:
sls wrote in message <34E118F2.2EDB@ni.net>...
>I have a program which runs in perl as follows:
>
>$ret = ./dfrun program
>
>$ret captures the results from the ./dfrun program.
>
>Now I want to mail that - the $ret
>
>how can I do this using the mail command?
>
>
>Thanks for any and all assistance - Paul

:-)


Since someone helped me I am willing to pass what I learned on...

HTH,
Bill

PS - The following code is not supported however;
it is a single subroutine which will not work by itself...

#!/usr/local/bin/perl -w

use strict; # In conjunction with the -w option, make sure there no errors!

# Prepare to check security issues...  Setup Globally Required variables...
my($ercType) = ''; # The Error Type which occurred...
my($ercCode) = ''; # The Error Code which occurred...
my($buffer)  = ''; # General buffer used to hold things...

#...........................................................................
 .
sub errorReturned { # Was there an error?

    my($strErc) = " " . $ercType . " " . $buffer . " " . $ercCode;

# The location of your sendmail binary
my $SENDMAIL = '/usr/lib/sendmail';

open (MAIL, "| $SENDMAIL toyou\@where.ever.you.are") ||
  die ("$0:  Fatal Error!  Cannot open sendmail:: $!\n");

print MAIL "Reply-to: somebody\@some.where.else\n";
print MAIL "From: $0 Gateway'\n";
print MAIL "To: 'Whoever You Are'\n";
print MAIL "Subject: Erc Message!\n";

print MAIL "X-Comments: ==========  Error Msg from $0 Gateway!
===============\n";

print MAIL $strErc;  # What it was, or what you want to say...

print MAIL "\n";
close (MAIL);

    exit(); # We're outta here!
}

######## End of Code...





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

Date: 11 Feb 1998 19:00:04 GMT
From: chris+usenet@netmonger.net
Subject: Re: How generate counter?
Message-Id: <6bssfk$ioi$3@schenectady.netmonger.net>

In article <6bqsis$t5t$3@csnews.cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, jzhuang@ringer.cs.utsa.edu (Jun Zhuang) writes:
> :I try to generate a counter by calling: counter.cgi
> 
> Then post to a CGI group.

Tom, is it possible for you to mark your useful and informative posts
to separate them from the one-line quips?  I used to read everything
you write (I even have a perl program that e-mails posts by you,
Randal, etc. to me), but lately I'm drowning in this sea of
"you are satanspawn" posts.

I fully agree with the sentiment you're expressing, and this request
should be taken with the appropriate 1/2 :-)

/: *Pattern Matching/:j
1 article killed.
/: *Why won't this work\?/:j
/guestbook/:j
/newbie/:j
4 articles killed.
/!!!/:j
1 article killed.
/help!/:j
4 articles killed.
/ntperl/:j
/oraperl/:j
/merlyn/f:+
/tchrist/f:+
75 articles selected.
/: *Perl on Windows 95/:j

-- 
	       Christopher Masto <chris@netmonger.net>
	Director of Operations, NetMonger Communications, Inc.
    +1-516-221-6664  http://www.netmonger.net/  info@netmonger.net


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

Date: Wed, 11 Feb 1998 14:31:49 -0500
From: John Porter <jdporter@min.net>
Subject: Re: How to receive the output of a file upload form?
Message-Id: <34E1FCA5.1A16@min.net>

Bud Bundy wrote:
> 
> You know that INPUT TYPE=file.

Lord have mercy.

> What is the quickest and simplest way
> to manage the output with a perl script?

perl->manage(OUTPUT);

Or possibly CGI.pm.
 
> Thanks

John Porter


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

Date: Wed, 11 Feb 1998 16:57:23 GMT
From: networks@skynet.co.uk (User)
Subject: Metacharacters - Advice please.
Message-Id: <34e1d7c3.6293257@news.skynet.co.uk>

Are metacharacters only a problem when the script executes another
program, eg, sendmail? or should all scripts check for metacharacters?

Thanks.


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

Date: 11 Feb 1998 19:02:24 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Metacharacters - Advice please.
Message-Id: <6bssk0$e99$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, networks@skynet.co.uk (User) writes:
:Are metacharacters only a problem when the script executes another
:program, eg, sendmail? or should all scripts check for metacharacters?

A problem?  They're often a feature.  The perlsec manpage talks
a good bit about this.  What part of that was confusing?

The bottom line is that programs run on the behalf of someone
else should not call the shell with random input supplied by 
someone else who may hate you.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


Emacs is a fine programming language, but I still prefer perl. -me


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

Date: 11 Feb 1998 19:11:39 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Metacharacters - Advice please.
Message-Id: <6bst5b$q8a@news-central.tiac.net>

In article <34e1d7c3.6293257@news.skynet.co.uk>,
User <networks@skynet.co.uk> wrote:
>Are metacharacters only a problem when the script executes another
>program, eg, sendmail? or should all scripts check for metacharacters?

It depends, if you use a user's input in a regular expression then the
regex metacharacters can be a problem if they aren't wanted.  

Usually the -T flag is helpful - it forces all "dubious" data to be
checked before it can be used.  When checking data from a user it's better
to explicitly check against what you allow rather than to check against a
(possibly incomplete) set of "bad" metacharacters. 

The -T flag is documented in the perlrun man page, perlfaq7 and perlsec
are a couple of places which deal with tainting (and untainting) data.

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: Wed, 11 Feb 1998 17:34:03 GMT
From: networks@skynet.co.uk (User)
Subject: Re: Metacharacters - Advice please.
Message-Id: <34e1e0f8.8650240@news.skynet.co.uk>

On Wed, 11 Feb 1998 16:57:23 GMT, networks@skynet.co.uk (User) wrote:

>Are metacharacters only a problem when the script executes another
>program, eg, sendmail? or should all scripts check for metacharacters?
>
>Thanks.

Opps!

Will the following make form input 'safe':

$value =~ s/~!/ ~!/g;

?

Thanks (again)..


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

Date: 11 Feb 1998 19:37:10 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Metacharacters - Advice please.
Message-Id: <6bsul6$hjt$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, networks@skynet.co.uk (User) writes:
:Will the following make form input 'safe':
:$value =~ s/~!/ ~!/g;

Of course not.  What's form input?  What's safe?
It sounds like you're in way over your head here.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

There ain't nothin' in this world that's worth being a snot over.
	    --Larry Wall in <1992Aug19.041614.6963@netlabs.com>


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

Date: Wed, 11 Feb 1998 12:52:16 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: My Module:  To release or not to release...
Message-Id: <linberg-1102981252160001@projdirc.literacy.upenn.edu>

In article <6bsgp7$4ka$1@nntp3.uunet.ca>, smcnabb@NO@%SPAMinterlog.com
(Steve McNabb) wrote:

> Also, I'm a relative newbie Perl hacker (I've been programming for about 4 
> months or so) so my code may not be the best in the universe, but I
figure it's 
> better to release something (and have it critiqued by the rest of the
community 
> for elegance, "safeness", efficiency, etc) rather than release nothing at all.

I suggest the following:

1)  Sit down with a printout of your code and the Programming Perl, 2nd
edition, p. 537-550, and be sure it does all the right things.

2)  destructive-test it, debug it, document it and post it here, asking
for comment.

3)  Submit it to CPAN when you're satisfied.

You'll be a better programmer for the process, you'll have to opportunity
to learn and get ideas from other feedback, the Perl community will
benefit from some more rock-solid, stable, useful code, and you'll be a
few notches up on the Karma scale!

-- 
Steve Linberg                  |    National Center on Adult Literacy
Systems Programmer etc.        |           University of Pennsylvania
linberg@literacy.upenn.edu     |        http://www.literacyonline.org


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

Date: Wed, 11 Feb 1998 18:50:40 GMT
From: wdr@world.std.com
Subject: Of Cards, Spindles, and Sealing wax Re: already off topic on card wallopers
Message-Id: <Eo89oJ.EFF@world.std.com>

Dan'l  wrote:

> And you could fold, spindle, and mutilate them as a gesture of adolescent
> protest.  (I haven't seen a spindle in a LONG time.  

I forget if it was a catalog or a Staples/OfficeMax, but the last
one I saw, moderately recent (in the 1990's) had been modified for
OSHA compliance

> that he spindles his _hand_?)

to prevent exactly that sort of thing.  It has a plastic gantry
(think Cape Caneveral) with a spring loaded guard that you slip the
offending slip under and whomp, it gets spindled .

> Remember the dramatic
> scene in "The Pawnbroker" where Rod Steiger was so overcome with angst

No. But we'd already determined you were of an age with my _older_
sisters in law. :-)

-- 
Bill Ricker  N1VUX  wdr@world.std.com  "The freedom of the press belongs 
http://world.std.com/~wdr               to those who own one."--A.J.Liebling


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

Date: Wed, 11 Feb 1998 11:08:00 -0800
From: Steven Smith <steves@wco.com>
Subject: perl -d core dump 5.004_04
Message-Id: <34E1F710.6F0E@wco.com>

The follosing chunk of code gives me a coredump when I run
the debugger, but the code I pulled it from runs fine
without the debugger.  I get this on both our Sun OS and
Solaris builds.

Does anyone else get the same results?
Is this a known bug?

Thanks
Steve S.

> perl -d w1

Loading DB routines from perl5db.pl version 1.01
Emacs support available.
 
Enter h or `h h' for help.
 
Got signal SEGV
Abort (core dumped)


============
#!/usr/local/bin/perl
@files = sort { a <=> b } @files;


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

Date: Wed, 11 Feb 1998 11:32:42 -0800
From: Steven Smith <steves@wco.com>
Subject: Re: perl -d core dump 5.004_04
Message-Id: <34E1FCDA.2AE6@wco.com>

Steven Smith wrote:
> 
> The follosing chunk of code gives me a coredump when I run
> the debugger, but the code I pulled it from runs fine
> without the debugger.  I get this on both our Sun OS and
> Solaris builds.
> 
> Does anyone else get the same results?
> Is this a known bug?
> 
> Thanks
> Steve S.
> 
> > perl -d w1
> 
> Loading DB routines from perl5db.pl version 1.01
> Emacs support available.
> 
> Enter h or `h h' for help.
> 
> Got signal SEGV
> Abort (core dumped)
> 
> ============
> #!/usr/local/bin/perl
> @files = sort { a <=> b } @files;
My problem was that I had a <= > b, not $a <=> $b.  But should this
generate a core file?

Thanks
Steve S.


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

Date: Wed, 11 Feb 1998 13:41:24 -0500
From: "Webmaster" <webmaster@fccj.cc.fl.us>
Subject: Re: Sharing variables between scripts
Message-Id: <34e1f1f4.0@usenet.fccj.cc.fl.us>

>but say there are 50 variables.. in that one script..
>and I want another script to use the variable, not necessarily
>the values.. the script that contains the variables.. *just* contains
>variables.. no other functions..
>To make it simple.. I have for instance 30 scripts.. CGI or non CGI .. that
>are going to be using the same variables..and say there are 30 variables...
>is there a simple way to 'include' or 'require' a script.pl that has the
>variables listed.  Maybe this can't be done.. thought it could be.


Create your own .PM and export them into your own namespace.

See CGI.pm (now included with 5.004) and you will see how to 'share'
variables the way you are discribing.

HTH,
Sneex




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

Date: Wed, 11 Feb 1998 10:33:58 -0800
From: Russell Bornschlegel <kaleja@rahul.net>
Subject: Re: test!! please ignore this message i am seeing if it works!
Message-Id: <34E1EF16.11A0@rahul.net>

John Porter wrote:
> 
> Brandon Blum wrote:
> >
> > never done a newsgroup before, trying to learn perl and i want
> > to post,
> > hopefully this works, just ignore it!
> 
> Certainly never read a FAQ.
> Never heard of netiquette.
> First thing he does is spam our newsgroup!

And you were never a newbie, I'm sure. How's he supposed to 
know that FAQs and netiquette exist if he hasn't read the 
newsgroups?

At least he didn't post in all caps.

-Russell Bornschlegel


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

Date: 11 Feb 1998 19:47:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: test!! please ignore this message i am seeing if it works!
Message-Id: <6bsv8u$hjt$4@csnews.cs.colorado.edu>
Keywords: KLB chastisement

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, kaleja@rahul.net writes:
:And you were never a newbie, I'm sure. How's he supposed to 
:know that FAQs and netiquette exist if he hasn't read the 
:newsgroups?

Ignorance of proper social behaviour is no excuse.  There is no alibi for
someone jumping into Usenet without understanding the rules of Netiquette.
They should be required to sign a form to that effect.

This is not just a big bulletin board, you know.  In the next, moderated
incarnation of this newsgroup, we shall be free of such.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "If you only have a nail, you tend to see every hammer as a problem."
    	--Larry Wall


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

Date: 11 Feb 1998 18:16:28 GMT
From: spidaman@well.com (Ian Kallen)
Subject: Re: The 'study' function
Message-Id: <6bspts$d25$1@was.hooked.net>

Hmmm, well I tried testing it with the following, where using -s should 
make it 'study' the pattern whereas omitting it should suppress studying:

#!/usr/local/bin/perl

# oldmcdonald - had a farm

use Benchmark;
print "studying $ARGV[1] ...\n" if $ARGV[0] eq '-s';
timethis (10000,
   q{
      die q{give me a farm animal sound (w/ -s for study'ing)} unless @ARGV;
      my $sound;
      $study++,shift(@ARGV) if $ARGV[0] eq '-s';
      $sound=$ARGV[0];
      study $sound if ($study);
      SW: {
         $eieio=emit('cow'),last SW if $sound=~/moomoo/i;
         $eieio=emit('turkey'),last SW if $sound=~/gobblegobble/i;
         $eieio=emit('duck'),last SW if $sound=~/quackquack/i;
         $eieio=emit('chicken'),last SW if $sound=~/cluckcluck/i;
         $eieio=emit('pig'),last SW if $sound=~/oinkoink/i;
         $eieio=emit('horse'),last SW if $sound=~/neighneigh/i;
         $eieio=emit('donkey'),last SW if $sound=~/heehaw/i;
         $eieio=emit('goose'),last SW if $sound=~/honkhonk/i;
         $eieio=emit('monkey'),last SW if $sound=~/eeh-eeh/i;
         $eieio=emit('doodlebug'),last SW if $sound=~/\S+/i;
      } # SW
      sub emit {
         $out='And on his farm he had a '.shift().", E-I-E-I-O\n";
         $out.="With a $ARGV[0] here, a $ARGV[0] there...\n";
         return $out;
      } # emit
   }, SWITCH
);
print $eieio;

On my laptop, (p100 w/ FreeBSD & perl 5.004_04) it runs about a half/full 
second  slower with 'study' enabled (depending on string length).  Any code 
examples of using 'study' to accelerate  pattern matches would be 
appreciated!  Page 287 of the Friedl book says  in 5.003 study can make 
successful matches fail.  But my  read of it suggests that after a string 
is subjected to study, multiple match attempts against it should 
accelerate, not slow down.

thanks,
-Ian

Feel free to cross post to alt.duck.quack.quack.quack

Andrew M. Langmead (aml@world.std.com) wrote:
: spidaman@well.com (Ian Kallen) writes:
: >I have yet to see in code or literature use of the 'study' function (I was 
: >hoping the 'Effective Perl' book would touch on it, but it's still an 
: >excellent book)... I'm looking for a good example (like with the Benchmark 
: >module :) of benefits from 'study'

: According to the book "Mastering Regular Expressions" study() has been
: broken in in recent releases of perl. I haven't tested this myself
: though, so you might want to check for yourself. 

: The purpose that it serves, though, is to optimize constructs like the
: following. It only works for certain types of input, (if certain
: characters that you are trying to match on are uncommon characters in
: the string.) so you really need to bechmark it agains a representive
: data set to see if there is any improvement or not.


: sub return_match_if_found {
:   my $string = shift;

:   study $string; # find the common characters in $string

:   return 'foo' if /foo/;
:   return 'bar' if /bar/;
:   return 'baz' if /baz/;
:   return 'qux' if /qux/;
:   return 'quux' if /quux/;
:   return;
: }
--
Ian Kallen <spidaman@well.com>
"Like so many Americans, she was trying to construct a life that made
sense from things she found in gift shops."
                -- Kurt Vonnegut, Jr.


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

Date: 11 Feb 1998 17:53:09 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: To All Perl Guru's
Message-Id: <6bsoi5$55n$3@marina.cinenet.net>

I R A Aggie (fl_aggie@thepentagon.com) wrote:
: In article <6bqi3h$he5$5@marina.cinenet.net>, cberry@cinenet.net (Craig
: Berry) wrote:
: 
: + server.  CGI.pm is helpful in this regard, as it notices when it's being
: + run 'offline' and lets you hand-enter pseudo-form data. 
: 
: Shoot, not only that, you can tell it to use a file as the CGI input...
: 
: James - rather useful, for long forms... :)

Yes, it's really hard to praise CGI.pm enough.  I think anyone who does 
CGI work in Perl who doesn't use it should evaluate themselves for other 
masochistic tendencies. :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 11 Feb 1998 13:00:55 -0500
From: "Webmaster" <webmaster@fccj.cc.fl.us>
Subject: Re: Too simple to ask but then ....
Message-Id: <34e1e877.0@usenet.fccj.cc.fl.us>

Simple questions (especially those without prior research) require simple
answers :-)

I am afraid to ask - are they just giving out systems engineering degrees in
Singapore now?  I am sorry, but I needed to ask.

If you ONLY want to display a directory listing under a web server, just
'enable directory browsing'.  Yes, easier than writing Perl.  You are using
a Web Server, right?  Otherwise, you will need to write the httpd portion
with the rest of your perl script :-)  Not impossible, but you wanted
easy...

HTH,
Sneex


Gilles Chong wrote in message <34DFFDF1.891FF917@csah.com>...
>Hi guys n gals,
>Im getting into tt PERL thing n would like to do an extremely simple
>thing.
>I wanna display a list of files sitting on a directory on my Unix system
>on a web page. How to proceed? Actually I can use the "system" command
>rite? Like: system "cd /X/Y/Z; ls -l". But then where will the list be
>displayed? N if i wanna display it on my webpage, do i get the list
>first in a string n then parse it n display the parsed string in my HTML
>page?
>Surely there is a much easier way to do it, rite?
>
>Help help! Pls advise me thru email.
>Fanx
>
>G.
>--
>Gilles Chong (glchy@csah.com, glchy@csa.com.sg)
>Systems Engineer, Internet Division
>CSA Holdings Ltd, Singapore.
>
>




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

Date: 11 Feb 1998 17:41:44 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <6bsnso$55n$1@marina.cinenet.net>

M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote:
: Craig Berry <cberry@cinenet.net> wrote:
: >I think the real issue isn't so much bad habits (though that's another
: >important topic), but rather bad data.  As others have pointed out, a lot
: >of the data formats in production systems today trace their ancestry back
: >to the 1401 era.  At no point has it made sense to take the massive hit in
: >expense and inconvenience to move terabits of data into a more modern
: >format.
: 
: That's exactly the fallacy that has got things into the mess they are.
: The longer you leave it, the bigger the pile of bits will be and the
: harder the conversion will be.   And the dimmer the memories of those
: who remember what it all meant anyway.

All quite true.

: So it _always_ makes sense : to convert at the earliest opportunity. 

Always?  Suppose that my developers estimate that doing a full ground-up 
data reformatting pass on my company's stored information will cost $20 
million and take a full year, with a 20% risk of significant downtime during 
the transition...and my projected annual profit is $5 million?  Does it 
really make sense to turn a $5 million profit into a $15 million loss to 
replace a system which is working for my business?

True, the old crufty data formats are probably costing me more per year 
to maintain and integrate with new applications, but it takes a long time 
(typically) for that sort of cost to add up to the one-time gigantic 
expense of rebuilding every DB and app from the ground up.  When one 
choice is better than the other can be calculated, but doing so requires 
numerous assumptions to be made about interest rates, future profits, 
cost of future maintenance and expansion, and so forth.  It's certainly 
not a black and white issue!

: But people are too busy worrying "can I survive tomorrow" to think
: about surviving the millenium (or even the year leading up to it).

If your ability to survive tomorrow is in doubt, this seems a very 
reasonable way to prioritize your worries. :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 11 Feb 1998 12:48:11 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <fl_aggie-1102981248120001@aggie.coaps.fsu.edu>

In article
<C5C213BF9F942A6B.FDAE3CB50D37E998.C5A5520FEA4B4C65@library-proxy.airnews.net>,
Derek Balling <dballing@speedchoice.com> wrote:

+ Bart Lateur wrote:

+ > Perl's functions should always have returned 4 digit years.
 
+ But, as we all know, they've returned "years since 1900", which is an
+ interesting way of saying "we WEREN'T compliant, but the values you get
+ in 2000 will be 'x', and not just 00's."

Why is that not compliant?

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: 11 Feb 1998 18:08:00 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <6bspe0$h4s$1@news.orst.edu>

In article <34e1a394.337144498@news.iag.net>,
Phil Barnett <dev.nul@iag.net> wrote:
>On Wed, 11 Feb 1998 11:02:46 GMT, bart.mediamind@tornado.be (Bart
>Lateur) wrote:
>>Zooko Journeyman <zooko@xs4all.nl> wrote:
>>>I glanced at the
>>>Perl time functions, said "Holy shit!  Looks like the Y2K 
>>>bug!", put "printf("19%2d", time);" for the timestamp, and made
>>>a note to myself to check up on that bug.
>
>>You don't mention what it your error was. You've got me guessing.
>In 2000, the code would have output 19100 instead of 2000. It's a bug.
>

in 2000, the code would output 1994 followed by 7 more digits. 

The only time the code would have output 19100 is on Jan 1, 1970, at
0:01:40 GMT.

The code as presented would give a decodable and correct timestamp, as
long as you ignore the "19" prepended to it. The only real question is
why prepend the "19"?



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

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

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