[16736] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4148 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 28 03:05:31 2000

Date: Mon, 28 Aug 2000 00:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967446312-v9-i4148@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 28 Aug 2000     Volume: 9 Number: 4148

Today's topics:
        basic question <kevin@kevinackerman.com>
    Re: basic question <bwalton@rochester.rr.com>
    Re: Bulk add to a hash.. Any ideas? (Logan Shaw)
    Re: DB_File Problem: HELP!!! <bwalton@rochester.rr.com>
    Re: Good companion book to Programming Perl? (David H. Adler)
        HELP: CGI and file permissions, Apache <nigelh@home.com>
    Re: HELP: CGI and file permissions, Apache <bwalton@rochester.rr.com>
    Re: How can I find an images size?? fperkins@my-deja.com
    Re: How can I find an images size?? (Martien Verbruggen)
    Re: Managing Temporary Directories/Files <brock_johnson@my-deja.com>
        Need help build BerkeleyDB on Solaris 7 <rtanner@onlinemac.com>
    Re: No Server Logs (David Efflandt)
    Re: Online Perl Study/Reference Guides <bwalton@rochester.rr.com>
    Re: Online Perl Study/Reference Guides <bwalton@rochester.rr.com>
    Re: pattern matching question <wyzelli@yahoo.com>
    Re: pattern matching question <godzilla@stomp.stomp.tokyo>
    Re: pattern matching question <wyzelli@yahoo.com>
    Re: pattern matching question <godzilla@stomp.stomp.tokyo>
    Re: pattern matching question <wyzelli@yahoo.com>
    Re: pattern matching question <anmcguire@ce.mediaone.net>
    Re: Perl binary file download using octet-stream <jhelman@wsb.com>
        removing a line from a file <jhijas@yahoo.es>
    Re: selling perl to management (Abigail)
        Syntax Error <galton@dreamscape.com>
    Re: Syntax Error (Prasanth A. Kumar)
    Re: Syntax Error <wyzelli@yahoo.com>
    Re: Syntax Error <rtanner@onlinemac.com>
    Re: Syntax Error <mikecook@cigarpool.com>
    Re: use CGI to remove files (doco)
    Re: use CGI to remove files (doco)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 28 Aug 2000 02:17:43 GMT
From: "Kevin Ackerman" <kevin@kevinackerman.com>
Subject: basic question
Message-Id: <bZjq5.31324$dG.888419@typhoon.nyroc.rr.com>

Hello,
    I have one simple question, What is the difference between PERL and CGI.
My closest guess is that PERL is an interpreted language and CGI is the
*thing* that makes PERL and a web browser work together. However, I am not
satisfied that this is correct. Any help with the correct answer to my
question would be greatly appreciated.

Best Regards,
Kevin Ackerman






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

Date: Mon, 28 Aug 2000 02:46:45 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: basic question
Message-Id: <39A9D2BD.5E32CCEB@rochester.rr.com>

Kevin Ackerman wrote:
 ...
>     I have one simple question, What is the difference between PERL and CGI.
> My closest guess is that PERL is an interpreted language and CGI is the
> *thing* that makes PERL and a web browser work together. However, I am not
> satisfied that this is correct. Any help with the correct answer to my
> question would be greatly appreciated.
 ...
> Kevin Ackerman

Kevin, you have it exactly right.  Perl is an interpreted language (that
actually compiles to byte-codes at runtime and is then interpreted). 
CGI is short for "common gateway interface", which defines a set of
standards for programs which communicate with web browsers.  A program
in most any language can be used as a "CGI" program.  All it needs to be
able to do is to read the values of environment variables, to be able to
read a specified number of bytes from its standard input, and be able to
write to standard output.  Thus, CGI programs can be written in DOS
batch files, Unix shell scripts, C, Perl, etc etc.  Perl, though, is
particularly good at it.  Hence, some folks might get the impression
that CGI programs are Perl programs.
-- 
Bob Walton


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

Date: 27 Aug 2000 21:46:57 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Bulk add to a hash.. Any ideas?
Message-Id: <8ocjr1$pqd$1@provolone.cs.utexas.edu>

In article <8oc336$8um$1@nnrp1.deja.com>,  <alphazerozero@my-deja.com> wrote:
>I am curious if anyone knows a shortcut to adding to a hash.
>I know how to create a new hash anonamously but I dont know how to add
>several key/value pairs to an already existing hash at the same time.
>
>I was hoping this woudl work, but to no avail (as was obvious when I
>thought about it)
>#first set up the hash
>$hash={'key1'=>"value1",
>       'key2'=>"value2"};
>
>#then later add to it in bulk
>$hash->{'key3'=>"value3",
>        'key4'=>"value4"}; #but it doesnt work
>
>$hash->{'key3'}="value3";  #however this
>$hash->{'key4'}="value4";  #does... But surely its more verbose than
>nec?

There's always this:

	%$hash =
		(
		%$hash,
		key3 => 'value3',
		key4 => 'value4'
		);

But that's pretty inefficient if %$hash has a zillion elements in it
and you only want to add 25 or something.

Personally, I'd like a way to use a hash slice to get key/value pairs
rather just values.  I.e., I'd like this:

	%x = mymysteryoperator (%x, keys %x);

to not change the value of X, but this:

	%x = mymysteryoperator (%x, grep (/[A-Z]/, keys %x));

would keep all keys which contain an upper-case character.

  - Logan


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

Date: Mon, 28 Aug 2000 03:42:26 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: DB_File Problem: HELP!!!
Message-Id: <39A9DFCA.49B7F9E8@rochester.rr.com>

Paul Dortman wrote:
 ...
> I have problem with my *.db database. Please, help me.
> 
> I want to port my  *.db database to another unix server. To simplify problem
> I created the s.db file with only one key  by script:
> 
> use DB_File;
> $db = '/home/paul/temp/s.db';
> tie(%db, 'DB_File', $db) or die "Could not open $db : $!";
> $num = $db{'num'};
> $num++;
> $db{'num'}=$num;
> print $num;
> untie %db;
> 
> The result s.db file has 32768 byte long for one server, and has 8192 byte
> long for another server. I think It's because of some internal settings such
> as size of field. But how can I change them to port my database from one
> server to another?
> 
> I should done it quickly, So Please help me or give me links to
> documentation that can be helpful.
 ...
> Paul

You probably can't assume that the binary files are transportable from
one system to another.  You will probably need to convert your file to
an ASCII intermediate form, than convert it back to a tied hash on the
other system.  I have no information on what your keys and values
contain, so you'll have to devise those routines yourself.  Anything
that will let you subsequently obtain the original keys and values
without corruption will work fine.

If your keys and values don't contain newlines, carriage returns or form
feeds and the keys don't contain colons, maybe something like
[untested]:

   ...
   tie(%db....
   open OUT,">junk.txt" or die "Couldn't open junk.txt for output,
$!\n";
   while(($key,$value)=each %db){
      print OUT "$key:$value\n";
   }

on the old computer, followed by:

   ...
   tie(%db....
   open IN,"junk.txt" or die "Coulnd't open junk.txt, $!\n";
   while(<IN>){
      ($key,$value)=split /:/,$_,2;
      $db{$key}=$value;
   }

on the new computer.  You could probably rig up something cool with
sockets to avoid generating the large ASCII file if that is a problem.
-- 
Bob Walton


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

Date: 28 Aug 2000 05:59:07 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Good companion book to Programming Perl?
Message-Id: <slrn8qjvtb.37s.dha@panix6.panix.com>

On Sun, 27 Aug 2000 16:58:19 GMT, Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "SD" == Speed Demon <speed.demon9999@virgin.net> writes:
>
>  SD> Perl for Dummies is AMAZING. Ok, its a dummies book but it teaches
>
>please don't promote that pile of smoldering dung in this newsgroup. it

For a more detailed and less heated informed opinion on this book,
please see http://www.plover.com/~mjd/perl/reviews/p54d.html

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Please stop flirting with my canvas.	- Damian Conway


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

Date: Sun, 27 Aug 2000 17:31:37 -0800
From: Nigel Heinsius <nigelh@home.com>
Subject: HELP: CGI and file permissions, Apache
Message-Id: <270820001731379290%nigelh@home.com>

I'm installing a web site for the first time on Apache and am having
some trouble with getting some things to work.

I have a set of perl CGI scripts that can be used to update various
HTML files on the site. The scripts work fine only when the permission
on the HTML files is set to "world writable". Obviously, I don't want
to have this. How can I allow the CGI scripts to update the files
without allowing this level of accessibility? I read that if the CGI is
owned by say, "root", and the HTML file is owned by "root" then you
should only have to allow "owner writable" on the HTML. This does not
work for me.

My Apache server runs under user "webuser" of group "webgroup"

How do I configure to allow only the CGI scripts and the owner (root)
to write to the HTML files?

Nigel


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

Date: Mon, 28 Aug 2000 03:00:37 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: HELP: CGI and file permissions, Apache
Message-Id: <39A9D5EB.38094744@rochester.rr.com>

Nigel Heinsius wrote:
> 
> I'm installing a web site for the first time on Apache and am having
> some trouble with getting some things to work.
> 
> I have a set of perl CGI scripts that can be used to update various
> HTML files on the site. The scripts work fine only when the permission
> on the HTML files is set to "world writable". Obviously, I don't want
> to have this. How can I allow the CGI scripts to update the files
> without allowing this level of accessibility? I read that if the CGI is
> owned by say, "root", and the HTML file is owned by "root" then you
> should only have to allow "owner writable" on the HTML. This does not
> work for me.
> 
> My Apache server runs under user "webuser" of group "webgroup"
> 
> How do I configure to allow only the CGI scripts and the owner (root)
> to write to the HTML files?
> 
> Nigel

[warning: off-topic]

You are making a big mistake if you run your CGI scripts as root (your
site will be hacker heaven).  What you should probably do is to make the
owner of the files your CGI scripts are to modify be "webuser", and set
them to owner read/write only.  Don't forget to make the directories in
which the files reside such that "webuser" has the ability to create or
delete files if your CGI programs do any of that.  When you say "this
does not work for me", what exactly doesn't work?  What exact errors do
you get?

And, what is your Perl question?  You would probably have better luck
with the above on comp.infosystems.www.authoring.cgi .
-- 
Bob Walton


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

Date: Mon, 28 Aug 2000 02:16:40 GMT
From: fperkins@my-deja.com
Subject: Re: How can I find an images size??
Message-Id: <8oci1r$p3r$1@nnrp1.deja.com>



> Get yourself winzip, it read gzipped tar files. Or get some windows
> versions of gzip and tar. Otherwise you'll have to ask here every time
> you need a module. www.tucows.com should have some stuff for you.

Nothing in your post is Perl specific.  Please refrain from continuing
threads which are not Perl specific.

Cheers,
Frank


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 28 Aug 2000 05:02:12 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: How can I find an images size??
Message-Id: <slrn8qjshv.ma.mgjv@verbruggen.comdyn.com.au>

On Mon, 28 Aug 2000 02:16:40 GMT,
	fperkins@my-deja.com <fperkins@my-deja.com> wrote:
> 
> 
> > Get yourself winzip, it read gzipped tar files. Or get some windows
> > versions of gzip and tar. Otherwise you'll have to ask here every time
> > you need a module. www.tucows.com should have some stuff for you.
> 
> Nothing in your post is Perl specific.  Please refrain from continuing
> threads which are not Perl specific.

*plonk*
tata

-- 
Martien Verbruggen              | 
Interactive Media Division      | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.   | Gates?
NSW, Australia                  | 


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

Date: Mon, 28 Aug 2000 03:59:17 GMT
From: Brock <brock_johnson@my-deja.com>
Subject: Re: Managing Temporary Directories/Files
Message-Id: <8oco2c$vki$1@nnrp1.deja.com>


> In article <39A97670.3D983F37@shentel.net>, Albert Dewey
<timewarp@shentel.net> wrote:
> No Brock - I will not flame you for posting this. In fact I find the
idea quite
> intreguing and unique. With so many people using the internet for
functionality,
> it is refreshing to come across a new concept as most people are out
there
> reinventing the wheel. Not sure if you will make any $$$ from this
one but I do
> see its purpose. However, my help will be limited at best but read on
anyway.
>

Thanks for not flaming me and giving me such an honest and thorough
assessment. (Other posters here, also deserve nothing less than the
kind of help you offered here, IMO. Thanks for showing a good example).
The idea of an unzip program is definitely not new, but I guess putting
it on a website where anyone could just type in the URL and hit SUBMIT
and whola! the file is unzipped, is probably a unique concept. FWIW,
I'm not looking to make any money off of this, and do not run a
webserver. It will be FREE for those who wish to use it.

> > Since zip files can extract to one or more
> > files or directories, I need my script to automatically extract to
the amount
> > of folders(directories) and files needed.I want this all to be done
inside of
> > a directory named "tmp," and each time it is used to make a unique
name for
> > the sub file(s)/directory(s)... or new un-zipped file(s)/directory
(s) under
> > the "tmp" directory.
>
> Basically you are going to have to create a server side utility in
Perl that will
> manage the session that you wish the user to interact with. This is
actually
> pretty easy to do, cookies and all. I would not attempt a write of
unique
> directory names for each of these zipped directories. Instead, I
would do just
> the opposite as what you have stated, I would create a 'session'
directory that
> the zipped file will utilize and within this directory create the
actual
> directory structures - names and all - that the zip/tar file
contains. Actually,
> I would just go ahead and unzip/untar the file in this
created 'session'
> directory as the directory structures will automatically be created
by doing
> this. Perl does have routines or available modules that you can
access that will
> unzip/untar the file as needed, all you really need to do is to
manage the
> creation and removal of the 'session' directory as becomes necessary.
As to these
> routines, I am sure that some of the Perl coders out there can point
you in the
> direction of the correct module that will make this job of unzipping
a file
> relatively pain free.

Your advice here seems logical. I'll have to study this as this is a
bit advanced for me. I'm not sure what you mean by creating a session.
Do you mean a telnet or tty?
>
> > Additionally, I need the script, when done, to
> > automatically display the unzipped URL's to the user for their
immediate
> > uploading to their own server (or downloading to their PC).The
unzipped
> > file/directory needs to automatically remove itself after a certain
amount of
> > time, say 30 minutes. (I'm doing it this way to prevent including a
file upload
> > feature in the script.)
>
> I would manage this (again, this is just me) by presenting something
of a
> scrolling list of the extracted files to the user so he could
download them and
> put them in the proper location. As part of this list I would include
an
> 'extracted to folder' description so the user can create the same
directory
> structure on the side. Then again if you are a Java coder, you could
create a
> simple applet that will do this automatically on the client's machine
and handle
> the download of the requested files without further interaction on
the part of
> the user. This is how I would handle it because making them manually
create the
> proper directories and download the files into each proper one will
handicap the
> user quite a bit if they had to deal with a compressed file with
hundreds of
> individual files within it. The applet method would involve have a
Perl routine
> on the server receiving instructions from the Java applet on the
client, ftp
> style. Would be real sweet if you get it set up properly.
>
A bit over my head still, but I'll try. I know a bit of Javascript, but
little to nothing about Java or applets. Maybe I can do it without
using Java applets?

> After the session is done, you can use a script that will easily
remove the
> entire 'session' directory in one easy act. There will be others who
will scream
> at me for suggesting this but this is how I personally would deal
with this -
>
>  ## Remove the session directory and all its contents where $Session
is the
> name/path of the 'session' directory.
>  system ("rm -fr $Session");
>
I noticed that Brian d Toy stated the $session can cause problems
unless you use "list." So, should the above coding be replaced with
system ("rm -fr -ls $Session"); in the above?

To
> run this system command, you would setup a crontab script that would
call your
> Perl maintenance script every hour or so that manages the removal of
old
> sessions. As part of this process, you would use Perl to build a
simple flatfile
> database of session entries in it to record things like the time of
the session
> and the session folder that the session lives in, then your
maintenance routine
> would read this datafile to manage the old sessions accordingly.
>
Sounds like more good info that I need to learn.

> > Further, I would like for my perl script to die
> > if my "tmp" directory fills to more than 5 megabtyes, to keep
anyone from
> > overrunning my disk space.
>
> Read the next part for a rely to this -
>
> > And lastly, I want to limit the program to not
> > accept zip file sizes over 300K.
>
> Simply put this into your Perl script that accepts the uploaded file -
>
> $CGI::POST_MAX=1024 * 300;
>
> This will limit file sizes to a total of 300K per session. I would
assume that
> 300K won't overfill your hard drive too much when unzipped so
limiting the upload
> to this amount should suffice to control the hard drive space
required for the
> process as a whole.
>
[snip]

> Regards and good luck with it -
>
> Albert Dewey
>
Your suggestions really bring home the fact of thinking through the
actions needed in a script before coding is started. I'm still not
quite sure why cookies are needed. I assumed that I needed the
file size to limit big files per person, and the file size limit for
the temp directory so that several people at once wouldn't overrun my
allowable disk space. Maybe I'm wrong though.

Again, thanks for your thoroughness. I was hoping this would be easier.
You have made me aware that this is WAY over my head, but I still want
to try it.

--
The Best to all!
Brock Johnson


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 27 Aug 2000 20:29:07 -0700
From: Rob Tanner <rtanner@onlinemac.com>
Subject: Need help build BerkeleyDB on Solaris 7
Message-Id: <39A9DC83.3162C096@onlinemac.com>

I am trying to build BerkeleyDB-0.11 against BerkeleyDB-3.1.14 on
Solaris 7.  It builds without any complaint, but 'make test' fails
horribly (the full output is appended below).
I built BerkeleyDB-3.1.14 with '--enable-test' and let it run it's full
bank of tests (it's a very comprehensice test suite, taking about 14
hours to run on a dual-processor Enterprise 450).  The result, the
BerkeleyDB-3.1.14 build is okay.  I have also doubly and triply checked
to make sure I have no older versions laying around of of libdb.a, .so*,
etc, and made sure that there were symbolic links in /usr/lib back to
the BerkeleyDB default install path.  I know, also, that my copy of
BerkeleyDB-0.11 (the perl module) source is okay, since it's identical
to the copy of my Linux box which builds and tests perfectly.

Also, note in the results posted below: all those errors to the effect
'cant remove directory, file exists', etc, don't occur on my Linux box
where all the tests simply generate an 'ok'.  

Anybody got any ideas what's going on?



'make test' results:

PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
-I/usr/local/lib/perl5/5.6.0/sun4-solaris -I/usr/local/lib/perl5/5.6.0 
-e 'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests
@ARGV;' t/*.t
t/btree.............Can't call method "db_put" on an undefined value at
t/btree.t line 163.
t/btree.............dubious                                                  
        Test returned status 17 (wstat 4352, 0x1100)
DIED. FAILED tests 29-243
        Failed 215/243 tests, 11.52% okay
t/destroy...........ok                                                       
t/env...............Can't remove directory ./fred: File exists at
t/env.t line 95
Can't remove directory ./fred: File exists at t/env.t line 105
Can't remove directory
/u/home/rtanner/c_scapes/db/db-3.1.14/perl.BerkeleyDB/fred/log_dir: File
exists at t/env.t line 155
Can't remove directory
/u/home/rtanner/c_scapes/db/db-3.1.14/perl.BerkeleyDB/fred: File exists
at t/env.t line 155
Can't remove directory ./fred: File exists at t/env.t line 178
Can't remove directory ./fred: File exists at t/env.t line 204
Can't remove directory ./fred: File exists at t/env.t line 241
t/env...............ok                                                       
t/examples..........Cannot open filt.db: File exists
t/examples..........dubious                                                  
        Test returned status 17 (wstat 4352, 0x1100)
DIED. FAILED tests 5-7
        Failed 3/7 tests, 57.14% okay
t/examples3.........ok                                                       
t/filter............ok                                                       
t/hash..............Can't remove directory ./fred: File exists at
t/hash.t line 166
t/hash..............ok                                                       
t/join..............ok                                                       
t/mldbm.............skipped test on this platform
t/queue.............Can't remove directory ./fred: File exists at
t/queue.t line 225
t/queue.............ok                                                       
t/recno.............Can't remove directory ./fred: File exists at
t/recno.t line 200
t/recno.............ok                                                       
t/strict............Can't remove directory ./fred: File exists at
t/strict.t line 105
Can't remove directory ./fred: File exists at t/strict.t line 237
t/strict............ok                                                       
t/subdb.............No $db defined
t/subdb.............dubious                                                  
        Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 10-43
        Failed 34/43 tests, 20.93% okay
t/txn...............Can't remove directory ./fred: File exists at
t/txn.t line 76
Can't remove directory ./fred: File exists at t/txn.t line 144
Can't remove directory ./fred: File exists at t/txn.t line 214
Can't remove directory ./fred: File exists at t/txn.t line 281
Can't remove directory ./fred: File exists at t/txn.t line 350
t/txn...............ok                                                       
t/unknown...........Can't call method "type" on an undefined value at
t/unknown.t line 116.
t/unknown...........dubious                                                  
        Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 12-41
        Failed 30/41 tests, 26.83% okay
Failed Test  Status Wstat Total Fail  Failed  List of failed
-------------------------------------------------------------------------------
t/btree.t        17  4352   243  215  88.48%  29-243
t/examples.t     17  4352     7    3  42.86%  5-7
t/subdb.t       255 65280    43   34  79.07%  10-43
t/unknown.t     255 65280    41   30  73.17%  12-41
1 test skipped.
Failed 4/15 test scripts, 73.33% okay. 282/1206 subtests failed, 76.62%
okay.
*** Error code 255
make: Fatal error: Command failed for target `test_dynamic'



-- 


       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)
  
  Rob Tanner
  McMinnville, Oregon
  rtanner@onlinemac.com


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

Date: Mon, 28 Aug 2000 04:17:00 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: No Server Logs
Message-Id: <slrn8qjptd.r6v.efflandt@efflandt.xnet.com>

On Sun, 27 Aug 2000 17:53:24 GMT, Brock <brock_johnson@my-deja.com> wrote:
>I do not have access to my webserver's logs to see my perl coding errors. Is
>there a better way to show errors to my browser than using
>CGI::Carp('FatalsToBrowser')... or using R. Schwartz's script that only shows
>errors from die or warn? Thanks.

Put your own simple wrapper around your script that redirects stderr to
stdout and prints it in plain text:

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print `myother.cgi 2>&1`;	# note: backticks


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Mon, 28 Aug 2000 03:10:32 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Online Perl Study/Reference Guides
Message-Id: <39A9D850.46023292@rochester.rr.com>

MC wrote:
> 
> I know this has been asked many many times, but ...
> 
> Can someone post a few links to online basic perl lessons and references. Also a
> few good study books suggestions.
> 
> This is for a friend who is interested in learning perl. He is not new to
> programming, just wants to learn a new language.
> 
> MC
 ...

http://www.perl.com/reference/query.cgi?tutorials

Learning Perl
Programming Perl

http://www.oreilly.com

-- 
Bob Walton


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

Date: Mon, 28 Aug 2000 03:53:47 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Online Perl Study/Reference Guides
Message-Id: <39A9E273.B7BFE7EC@rochester.rr.com>

MC wrote:
 ...
> Can someone post a few links to online basic perl lessons and references. Also a
> few good study books suggestions.
> 
> This is for a friend who is interested in learning perl. He is not new to
> programming, just wants to learn a new language.
> 
> MC
 ...
http://www.perl.com/reference/query.cgi?tutorials

Learning Perl
Programming Perl

http://www.oreilly.com

-- 
Bob Walton


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

Date: Mon, 28 Aug 2000 10:45:23 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: pattern matching question
Message-Id: <Qejq5.8$Ny3.1397@vic.nntp.telstra.net>

> #!/usr/local/bin/perl
>
> print "Content-Type: text/plain\n\n";
>
> $string = "0-0-0-0-0-0";

Did you try with $string = ' - - - - - ' ?

"Boss, your script fails the criteria"

Wyzelli




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

Date: Sun, 27 Aug 2000 19:15:29 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: pattern matching question
Message-Id: <39A9CB41.C7D242FC@stomp.stomp.tokyo>

Wyzelli wrote:
 
> > #!/usr/local/bin/perl

> > print "Content-Type: text/plain\n\n";

> > $string = "0-0-0-0-0-0";
 
> Did you try with $string = ' - - - - - ' ?
 
> "Boss, your script fails the criteria"


"....6 digit, hyphen delimited set of numbers, 
 each no less than 0 nor greater than 4 ."

Work on your reading comprehension skills.
Currently your displayed reading comprehension
skill level, I would estimate, as a well educated
and well seasoned teacher, to be equal to a young
pre-pubescent child, perhaps eight to ten years of age.
Illiteracy can be cured, if you truly try.

Godzilla!


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

Date: Mon, 28 Aug 2000 12:17:15 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: pattern matching question
Message-Id: <wBkq5.11$Ny3.1946@vic.nntp.telstra.net>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:39A9CB41.C7D242FC@stomp.stomp.tokyo...
> "....6 digit, hyphen delimited set of numbers,
>  each no less than 0 nor greater than 4 ."
>
> Work on your reading comprehension skills.
> Currently your displayed reading comprehension
> skill level, I would estimate, as a well educated
> and well seasoned teacher, to be equal to a young
> pre-pubescent child, perhaps eight to ten years of age.
> Illiteracy can be cured, if you truly try.

Right back atcha.

Since a space does not fit the rules, and your script displays

print "Your string passes all tests. Boss, you are a genius!",
      "\n  String: $string";

even when the string contains spaces, then your script is wrong!  Nuff
Sed.

Wyzelli




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

Date: Sun, 27 Aug 2000 21:45:16 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: pattern matching question
Message-Id: <39A9EE5C.960EA7C@stomp.stomp.tokyo>

Wyzelli wrote:
 
> Godzilla! wrote:

> > "....6 digit, hyphen delimited set of numbers,
> >  each no less than 0 nor greater than 4 ."

> > Work on your reading comprehension skills.
> > Currently your displayed reading comprehension
> > skill level, I would estimate, as a well educated
> > and well seasoned teacher, to be equal to a young
> > pre-pubescent child, perhaps eight to ten years of age.
> > Illiteracy can be cured, if you truly try.
 
>  Nuff Sed.

No, not enough is said. You are childish, petty and
grasping at any lame excuse to afford yourself a
chance to be hateful. However, in reality, yours
is a display of egomania and jealousy manifested
as ignorant acts of hatred. I am truly beginning
to believe, man/woman of a thousand ugly mugs, 
you are psychotically obessessed with me. This is 
in evidence by your pretending to be quite literally
hundreds of people here, both male and female, all 
of whom, routinely harass me in the most lame arse
of ways, fitting only for an AOL lamebrain.

You will recall, the last person who became so
psychotically obsessed with me, earned himself
a free ninety day stay in the very famous and
infamous, Los Angeles County Gray Bar Hotel, 
featuring a staff of Bubba and his Buddies.

You make fools of these other fools but you do 
not and never have fooled me. However, quite
the opposite is so true, to my great delight.

Beat it little boy. You are laughable.

Godzilla!

-- 
Perl Monger's Perfect Perl Perl Land.
  http://la.znet.com/~callgirl/perlperl.cgi


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

Date: Mon, 28 Aug 2000 15:16:28 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: pattern matching question
Message-Id: <A0nq5.17$Ny3.2292@vic.nntp.telstra.net>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:39A9EE5C.960EA7C@stomp.stomp.tokyo...
>
> Beat it little boy. You are laughable.
>

Lbh ner guvpxre guna gjb fubeg cynaxf tyhrq gbtrgure!

Wyzelli




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

Date: Mon, 28 Aug 2000 01:50:59 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: pattern matching question
Message-Id: <Pine.LNX.4.21.0008280114470.1456-100000@hawk.ce.mediaone.net>

On Sun, 27 Aug 2000, Godzilla! quoth:

~~ Date: Sun, 27 Aug 2000 17:34:09 -0700
~~ From: Godzilla! <godzilla@stomp.stomp.tokyo>
~~ Newsgroups: comp.lang.perl.misc
~~ Subject: Re: pattern matching question
~~ 
~~ David Gay wrote:
~~ 
~~ > I'm trying to check a pattern to ensure that it's a 6 digit, hyphen
~~ > delimited set of numbers, each no less than 0 nor greater than 4 .
~~  
~~ > Example:
~~ > 0-1-2-3-4-4 or 1-2-1-3-4-0 is acceptable.
~~ > 02-1-2-3-4-4 or 0-1-2-3-4-5 is not acceptable.
~~  
~~ (snip)
~~ 
~~ A few weeks back, a number of experts here proclaimed
~~ " exit; " to be of little value, if any value at all.

I have just rejoined the group, but I doubt that the
experts here made that sort of categorical blanket statement,
perhaps you misunderstood something? :-)  exit() is handy
for usage subroutines for example:

sub help
{
print <<'EOH';

Usage: program [options] file

   -a  blah, blah
   -h  print usage and exit

EOH
exit(0);
}

This is just one example, something I do in just about every
program/script I write, so I springs to mind immediately.
exit() is not entirely without use, but why use it if it
is superflous, as in your test script?

~~ This meets your parameters precisely and affords an
~~ alternative to usual Perl 5 Cargo Cult. Do not respond
~~ with changed parameters and "This doesn't work."

Classical programming paradigm:

A good program is liberal in what it accepts, but strict
in what it emits.  

Your test script is entirely self contained, and provides 
little flexibility.

~~ TEST SCRIPT:
~~ ____________
~~ 
~~ #!/usr/local/bin/perl

-w, use strict

~~ print "Content-Type: text/plain\n\n";

I know why, but why? Not every program is a CGI.

~~ $string = "0-0-0-0-0-0";
~~ 
~~ if (${\length ($string)} > 11)
~~  { print "Boss, string is too long.\n $string"; exit; }

What if the input has leading or trailing white space?
Change that line to read:

my $string = "    0-0-0-0-0-0   ";

and your test script fails to handle that very feasible
input string.  Your test script is not practical as it
does not even attempt to simulate real world data, however
it would have been nice of the OP to provide some sample
input, along with his expected results.

~~ if (${\length ($string)} < 11)
~~  { print "Boss, string is too short.\n $string"; exit; }

Ditto.  Another note, instead of:

print "Boss, string is too short.\n $string"; exit;

why not just:

die "The input string is too short!\n $string\n";

~~ @Array = split (/-/, $string);

A solution using a regex here does save alot of code,
I would think it would be faster to as your method requires
building and iterating over a list.

~~ if (($#Array < 5) || ($#Array > 5))
~~  { print "Boss, string format is wrong.\n $string"; exit; }

Why not just:

   if ($#Array != 5) {

or even:

   my $len = @Array; # More code, but clearer.
   if ($len != 6) {

~~ foreach $element (@Array)
~~  { 
~~   if ($element > 4)
~~    { print "Boss, some numbers are too big.\n $string"; exit; }
~~  }

You certainly have an odd indentation style, inconsistent
at least.

~~ print "Your string passes all tests. Boss, you are a genius!",
~~       "\n  String: $string";
~~ 
~~ print "\n\n\n--\nGodzilla Rocks!\n",
~~       "  http://la.znet.com/~callgirl3/inagadda.mid";
~~ 
~~ exit;

It would have anyhow. :-)

[ snip printed results ]

Although it would appear your logic is for the most part
sound (read: the script works for your limited parameters),
you certainly have travelled around the world to walk next
door.  Have a nice day! :-)

Best Wishes,

anm
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Andrew N. McGuire                                                      ~
~ anmcguire@ce.mediaone.net                                              ~
~ "Plan to throw one away; you will, anyhow." - Frederick P. Brooks, Jr. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



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

Date: Mon, 28 Aug 2000 01:07:23 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Perl binary file download using octet-stream
Message-Id: <39A9BBC1.2DA0BF7@wsb.com>

See below:

rusty_mason@my-deja.com wrote:
> 
> Hello, Perl wizards, how are you? I hope you can help me, I've got a
> script here I can't get working. I'm trying to validate users before
> letting them download certain binary files.  The script below is the
> best thing I could piece together so far, but it doesn't work. Does
> anyone know why? This is running on Unix/Apache.
> 
> Thanks,
> Rusty
> 
> #!/usr/bin/perl
> 
> $binary = "robert_e_mason.doc";
> 
> $size = -s "$binary";
> 
> open(INFILE,"<$binary") or die $!;
> 
> print "Content-Type:application/octet-stream\n";
> print "Content-Disposition:attachment; filename=robert_e_mason.doc\n";
> print "Content-Length:$size\n\n";binmode(INFILE);binmode(STDOUT);
> 
> while(<INFILE>){

Here's your problem.  You've already declared that this is a binary
file, yet you are attempting to read it as though it were an ASCII
file.  The <> operator attempts to read a file one line at a time, but
in a binary file there are no obvious linebreaks.

A better option would be to use binmode() followed by the read() or
sysread() functions (type "perldoc perlfunc" at the command prompt for
further info).

I've actually written a module that deals with this dilemma, but I
haven't distributed it.  For more info, e-mail me.

JH

>   print $_;
> }
> 
> close(INFILE);
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: Mon, 28 Aug 2000 08:49:27 +0200
From: Javier Hijas <jhijas@yahoo.es>
Subject: removing a line from a file
Message-Id: <39AA0B77.4296B740@yahoo.es>

I am looking for a good short way to remove a password entry from the
passwd file


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

Date: 28 Aug 2000 06:49:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: selling perl to management
Message-Id: <slrn8qk2pb.bbg.abigail@alexandra.foad.org>

Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDLIII September
MCMXCIII in <URL:news:slrn8qhskl.3fr.mgjv@martien.heliotrope.home>:
,, 
,, But I can turn the argument around again. No standard out there
,, guarantees anything either. And again I can point to the java language
,, as well as the C language standards, and the various Unices. They change
,, too when necessary. No standard will stop that. What a standard does is
,, formalise what a given application should behave like during the
,, lifetime of that standard. It does hardly ever guarantee anything about
,, how long that lifetime is.

C and Unix don't change in the same way as Perl does. You can't compare
that.  And standardization does chance things. I've noticed a certain
behaviour change between 5.005 and 5.6.0. When I submitted a bugreport
for that, the only reply I got was "I don't know whether that's a bug or
a bugfix".  With a standard, you could at least determine whether the old,
or the new behaviour is "correct". Now, a patch could have an unintended
side effect that changes some behaviour, and without a standard, it's
not always possible to say that the side effect is a bug or a feature.

(The behavioural change I noticed was:

     sub AUTOLOAD {print $AUTOLOAD =~ /.*::(.*)/, "\n";}
     *foo = *bar;
     &foo;

 This prints 'foo' in 5.6.0 and 'bar' in 5.00503. It's nowhere documented
 what it should print, hence the question "bug or bugfix?").

,, Yes, obscure things broke. Abigail had one or two things break in her
,, one-liners againts 5.6.0. Most things will keep working. Hardly any
,, production code that has been written for maintainability breaks.

Really? I had everything that used dbmfiles break. I wouldn't want to
claim that use of dbmfiles is rare in production code. I had things
break in one liners that up till 5.6.0 I would not have hesitated to
use in production code. (map {$_ .= "a"} "b" broke). A chance that,
as far as I can tell, had no other justification than making Perl more
"orthogonal" - quite a non-Perl thing to do.

Every new version of Perl has broken code of me. The fact something that
break is a one-liner is irrelevant. One persons one-liner is another
persons production code.

But even if a new version of Perl doesn't break anything, there's still
"damage". Due to Perl having broken things repeatedly in the past with new
versions, people will have to spend a lot of time performing regression
tests before installing a new version.

,, And again, as before in the past, we agree on this. Perl needs better
,, and more formal documentation. But that is a point that is beside the
,, discussion at hand. perl is in no more or less danger of breaking things
,, between versions than other pieces of software are. Even standardised
,, pieces of software.

Most "other pieces" of software are stand alone programs. I would not want
to compare a language with any other piece of software.

Perl is continually evolving. Part of that process is that things that used
to work one way no longer work that way, or no longer work at all. I don't
want to go into the discussion whether that is an acceptable price to pay.

But I strongly disagree with the opinion that breakage doesn't occur,
or only occurs in "obscure" code (obscure by whose opinion?) or that it
doesn't hamper spreading of usuage of Perl. Denial of a problem is the
wrong way of fixing it.



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: Mon, 28 Aug 2000 00:27:58 -0400
From: "Greg Alton" <galton@dreamscape.com>
Subject: Syntax Error
Message-Id: <sqjqg768t9118@corp.supernews.com>

What's wrong with this? A syntax error is reported to be near ")  &&" on the
second line.

sub CheckAnswer {
if ($test_data{'question_sequence'} > 0) && (($test_data{'answer'}) =
($test_data{'correctanswer'})) {
    $number_of_correct = ($test_data{'number_of_correct'});
    ++$number_of_correct;
    print "Set-Cookie: number_of_correct=$number_of_correct; \n";
    $response_string = "Correct!";
    }

Thank you,
Greg Alton




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

Date: Mon, 28 Aug 2000 04:36:21 GMT
From: kumar1@home.com (Prasanth A. Kumar)
Subject: Re: Syntax Error
Message-Id: <m3ya1idmt6.fsf@C654771-a.frmt1.sfba.home.com>

"Greg Alton" <galton@dreamscape.com> writes:

> What's wrong with this? A syntax error is reported to be near ")  &&" on the
> second line.
> 
> sub CheckAnswer {
> if ($test_data{'question_sequence'} > 0) && (($test_data{'answer'}) =
> ($test_data{'correctanswer'})) {
>     $number_of_correct = ($test_data{'number_of_correct'});
>     ++$number_of_correct;
>     print "Set-Cookie: number_of_correct=$number_of_correct; \n";
>     $response_string = "Correct!";
>     }
> 
> Thank you,
> Greg Alton

The whole test condition portion of the 'if' statement needs to be in
parenthesis. In other words:

if (test1 && test2) {
	do_this;
}

-- 
Prasanth Kumar
kumar1@home.com


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

Date: Mon, 28 Aug 2000 14:18:29 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Syntax Error
Message-Id: <camq5.15$Ny3.2119@vic.nntp.telstra.net>

"Greg Alton" <galton@dreamscape.com> wrote in message
news:sqjqg768t9118@corp.supernews.com...
> What's wrong with this? A syntax error is reported to be near ")  &&"
on the
> second line.

Couple of things...

> sub CheckAnswer {
> if ($test_data{'question_sequence'} > 0) && (($test_data{'answer'}) =

^^^
Are you sure you want an assignment there?  It will always be true..
And is it a numeric comparison or a string comparison?

You have a redundant set of braces around the variables in the second
test, they won't hurt anything, but you are missing one enclosing set
around the whole 'if' conditional.

if (($test_data{'question_sequence'} > 0) && ($test_data{'answer'} ==
$test_data{'correctanswer'})){

OR

if (($test_data{'question_sequence'} > 0) && ($test_data{'answer'} eq
$test_data{'correctanswer'})){

> ($test_data{'correctanswer'})) {
>     $number_of_correct = ($test_data{'number_of_correct'});
>     ++$number_of_correct;
>     print "Set-Cookie: number_of_correct=$number_of_correct; \n";
>     $response_string = "Correct!";
>     }

You are also missing a closing brace here for the sub.

Wyzelli




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

Date: Sun, 27 Aug 2000 23:02:56 -0700
From: Rob Tanner <rtanner@onlinemac.com>
Subject: Re: Syntax Error
Message-Id: <39AA0090.265FADAF@onlinemac.com>

Greg Alton wrote:
> 
> What's wrong with this? A syntax error is reported to be near ")  &&" on the
> second line.
> 
> sub CheckAnswer {
> if ($test_data{'question_sequence'} > 0) && (($test_data{'answer'}) =
> ($test_data{'correctanswer'})) {

Misbalanced parens is your problem.
     
If I understand what you're trying to do, you probably want to say
something more like the following:

if ( 
     ($test_data{question_sequence} > 0) && 
     ($test_data{answer} == $test_data{correctanswer})
   ) {

>     $number_of_correct = ($test_data{'number_of_correct'});
>     ++$number_of_correct;
>     print "Set-Cookie: number_of_correct=$number_of_correct; \n";
>     $response_string = "Correct!";
>     }
> 
> Thank you,
> Greg Alton

-- Rob


       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)
  
  Rob Tanner
  McMinnville, Oregon
  rtanner@onlinemac.com


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

Date: Sun, 27 Aug 2000 23:30:06 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: Syntax Error
Message-Id: <GHnq5.881$SC1.548751@news.uswest.net>

if ($test_data{'question_sequence'} > 0) && (($test_data{'answer'}) =
($test_data{'correctanswer'}))

Your test operator should be '==' for numeric tests or 'eq' for string...
    Michael

"Greg Alton" <galton@dreamscape.com> wrote in message
news:sqjqg768t9118@corp.supernews.com...
> What's wrong with this? A syntax error is reported to be near ")  &&" on
the
> second line.
>
> sub CheckAnswer {
> if ($test_data{'question_sequence'} > 0) && (($test_data{'answer'}) =
> ($test_data{'correctanswer'})) {
>     $number_of_correct = ($test_data{'number_of_correct'});
>     ++$number_of_correct;
>     print "Set-Cookie: number_of_correct=$number_of_correct; \n";
>     $response_string = "Correct!";
>     }
>
> Thank you,
> Greg Alton
>
>




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

Date: 28 Aug 2000 04:37:00 GMT
From: is83024@cis.nctu.edu.tw (doco)
Subject: Re: use CGI to remove files
Message-Id: <8ocq9c$jo7$1@news.cis.nctu.edu.tw>

: If you are able to delete directly on system from the command line but
: not from browser is because the permission issue. the ownerships
: between the web browser and command line are different. To resolve
: this, you have to change permission by changing the "read, write" of
: the files which you want to delete, or change ownership of the file,
: such as "nobody or web-user-account".
: Van
first, thx all and i 'll try unlink.
second, the problem is not the permisson problem, i had chmoded and chowned
before .this maybe a system security concerning.
but i have to combine this CGI with java servlet.


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

Date: 28 Aug 2000 05:58:41 GMT
From: is83024@cis.nctu.edu.tw (doco)
Subject: Re: use CGI to remove files
Message-Id: <8ocv2h$ncg$1@news.cis.nctu.edu.tw>


Lincoln Marr (lincolnmarr@nospam.europem01.nt.com) ´£¨ì:
: Could you possibly use the 'unlink' command which is virtually a synonym for
: unix's 'rm' command?
it still canot work through web browser . >.<
it just like the command 'rm', it only can work correctly on unix system.


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4148
**************************************


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