[7289] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 914 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 24 12:07:15 1997

Date: Sun, 24 Aug 97 09:00:27 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 24 Aug 1997     Volume: 8 Number: 914

Today's topics:
     Re: Building a (very?) complex data structure.... (Eric Bohlman)
     Re: Compiling perl5.004.01 on solaris 2.5.1 <ReplyTo__ychen@webspan.net>
     create a deamon in perl5 (Patrick BONNAVAUD)
     Re: create a deamon in perl5 (Jeremy D. Zawodny)
     easiier way to extract one field from a string <mlb@netpath.net>
     Re: efficient editing (M.J.T. Guy)
     Re: efficient editing <andrew@squiz.co.nz>
     Embedding Perl on Windows NT 4.0 bpm@minyos.its.rmit.edu.au
     Re: Getting index of array element (Andrew M. Langmead)
     Re: Help on Final Exam (Perl class) <youngej@magpage.com>
     Re: Help With Loading of Perl Modules <rootbeer@teleport.com>
     Re: Help!! my dbm file crash everytime I try to build i (M.J.T. Guy)
     Re: Help, Help, Help... This is killing me... <andrew@squiz.co.nz>
     Re: Help: Creating a datastructure. (Eric Bohlman)
     Re: Modem Control (Andrew M. Langmead)
     PB : Perl win32  and OLE <philippe.picard@hol.fr>
     Re: Perl Performance FAQ? <andrew@squiz.co.nz>
     Re: POP3 Mail <rootbeer@teleport.com>
     problem with openning file for appending <daveck@top.monad.net>
     Re: problem with openning file for appending (Jeremy D. Zawodny)
     Re: problem with openning file for appending <rootbeer@teleport.com>
     Re: Random Numbers (Bart Lateur)
     Re: Search Engine scripts ? (Anthony Boyd)
     Re: Setting subject in emails (Andrew M. Langmead)
     Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
     Re: Statistics for comp.lang.perl.misc (Greg Bacon)
     Re: Using passwd command inside a perl script <andrew@squiz.co.nz>
     Re: When is Perl interpreted? (Jeremy D. Zawodny)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 24 Aug 1997 07:40:28 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Building a (very?) complex data structure....
Message-Id: <ebohlmanEFEqnG.pD@netcom.com>

Zenin (zenin@best.com) wrote:
: 	Notice that "food-meat => $object" is not there.  The first use of
: 	food-meat is a reference to a hash that contains pork.  If you were
                                      ^^^^^^^^^^^^^^^^^^^^^^^
Is the next edition of the Camel book going to include a "Perl recipes" 
section after the "poetry" section?



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

Date: Sun, 24 Aug 1997 03:36:27 -0400
From: Youcai Chen <ReplyTo__ychen@webspan.net>
Subject: Re: Compiling perl5.004.01 on solaris 2.5.1
Message-Id: <33FFE47B.72C9C94A@webspan.net>

Patrick McPartland wrote:

> Hello,
>
> I am trying to get perl 5.004.01 to compile on solaris 2.5.1 with
> gcc-2.7.2.2 . Configure writes the Makefile, runs make depend, then
> fails make on util.c with this error:
>
> util.c: In function `Perl_form':
> util.c:1107: number of arguments doesn't match prototype

find the exact function which fails.

find in which header file it's declared.

In that header file, you normally will find how to declare a function as
one prototype instead of another one due to the incompatibility between
different implementations.

Hope it's helpful.

Y.C.

> proto.h:124: prototype declaration
> util.c: In function `Perl_die':
> util.c:1164: number of arguments doesn't match prototype
> proto.h:69: prototype declaration
> util.c: In function `Perl_croak':
> util.c:1231: argument `pat' doesn't match prototype
> proto.h:46: prototype declaration
> util.c:1231: number of arguments doesn't match prototype
> proto.h:46: prototype declaration
> util.c: In function `Perl_warn':
> util.c:1288: number of arguments doesn't match prototype
> proto.h:525: prototype declaration
> util.c: In function `Perl_my_popen':
> util.c:1818: warning: return makes pointer from integer without a cast
> *** Error code 1
> make: Fatal error: Command failed for target `util.o'
>
> I am accepting mostly all defaults, except I am specifying a different
> install directory. This is the configure command...
>
> sh Configure -Dcc=gcc -Dprefix=/home/pmcpartl/perl
> -Doptimize='-xpentium' -des
>
> Is this a bug?  Any advice?
>
> Please email me directly as I don't peruse the group frequently.
>
> Thanks,
> Pat
>
> --
>
> Patrick McPartland                                      (609) 722-4767





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

Date: Sun, 24 Aug 1997 13:59:35 +0100
From: bonnavau@mail.club-internet.fr (Patrick BONNAVAUD)
Subject: create a deamon in perl5
Message-Id: <19970824135935304659@ppp-116-91.neuilly.club-internet.fr>


Hello

I try to create a deamon in perl that can I execute with a rsh
from another station

My problem is with rsh, rsh is blocked and wait that my perl deamon
finish. 

I already do the same things in C, and I havn't this problem
my program is really a deamon, I first fork, then exit from the 
father, continue in the child and set the session leader setsid
then close all the file descriptor to be detatch from the shell

In C, it's work fine ans rsh don't block, it give me the hand
and my deamon run on the remote host

BUT, in perl I havn't the same behavior, WHY ? I do exactly the
same things as in my C program

my command is
rsh <remote-host> '/usr/bin/perl /home/my/bin/testrsh.pl'

How I can launch a perl deamon on a remote host with rsh ?
with rsh give me hand

Is someone can give my a squeleton of a perl deamon program ?

thanks

mailto:bonnavau@club-internet.fr


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

Date: Sun, 24 Aug 1997 13:59:30 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: create a deamon in perl5
Message-Id: <34003e0c.587196273@news.bgsu.edu>

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

On Sun, 24 Aug 1997 13:59:35 +0100, bonnavau@mail.club-internet.fr
(Patrick BONNAVAUD) wrote:

>I try to create a deamon in perl that can I execute with a rsh
>from another station
>
>My problem is with rsh, rsh is blocked and wait that my perl deamon
>finish. 
>
>I already do the same things in C, and I havn't this problem
>my program is really a deamon, I first fork, then exit from the 
>father, continue in the child and set the session leader setsid
>then close all the file descriptor to be detatch from the shell
>
>In C, it's work fine ans rsh don't block, it give me the hand
>and my deamon run on the remote host
>
>BUT, in perl I havn't the same behavior, WHY ? I do exactly the
>same things as in my C program
>
>my command is
>rsh <remote-host> '/usr/bin/perl /home/my/bin/testrsh.pl'
>
>How I can launch a perl deamon on a remote host with rsh ?
>with rsh give me hand
>
>Is someone can give my a squeleton of a perl deamon program ?

I have a few programs that do this on Solaris and Linux without
trouble. They begin with something like:

---snip---

use Socket;

$port           =       $ARGV[0];
$port           =       2345 unless $port;

push(@INC,"/export/pc/lab-tech/update-log/lib");
require "vars.pl";

# Setup the child signal handler

$SIG{'CHILD'} = wait;
waitpid(-1, 0100);

# Okay, it's safe to fork now.

$pid=(fork());

exit if $pid;

 ... do stuff

---snip---

Good Luck,

Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>

"That's an example of how Perl can bring school yard cruelty to new heights."
    -- Jon Orwant at the 1st Annual Perl Conference


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

Date: Sun, 24 Aug 1997 11:47:56 -0700
From: Marvin Blackburn <mlb@netpath.net>
Subject: easiier way to extract one field from a string
Message-Id: <340081DC.2192@netpath.net>

I am a beginner.  I want to know the easiest way to extract just 
one field from a white space delimited sting.  Preferablly something
analogous to *cut*.  I can get the single field using a long regular
expression match along with the $ operation; however, this gets quite 
long when the number of fields is high.  The other way using split
requires alot of needless variable assigments.  

for example, if wanted to get the 12 field from a 27 field string.
the fields are white space delimited, and can be described using reqular expressions.

Since the fields are
variable lenghth, subtr doesn not seem useful.
-- 
Marvin Blackburn
mlb@netpath.net
Burlington Industries
Burlington House MIS


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

Date: 24 Aug 1997 12:29:28 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: efficient editing
Message-Id: <5tp9f8$skh$1@lyra.csx.cam.ac.uk>

In article <slrn5vro18.dr.bsa@rushlight.kf8nh.apk.net>,
Brandon S. Allbery KF8NH <bsa@void.apk.net> wrote:
>On 20 Aug 1997 08:54:57 GMT, M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
>+-----
>| Dean Hoover  <dhoover@textwise.com> wrote:
>| >I'm trying to figure out the best way to change:
>| >  \ to \\ and | to \V and & to \A
>| >in one fell swoop, efficiently.
>| s/([\\|&])/+{qw:\ \\ | \V & \A:}->{$1}/ge;
>| Dunno if that's the most efficient, or even the most cryptic.
>+--->8
>
>    s/[\\|&]/\\\&/g;

That doesn't do anything resembling what was requested.   I suggest you
test your regexps before posting, as I sometimes do  :-)


Mike Guy


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

Date: Mon, 25 Aug 1997 01:38:41 +1200
From: "Andrew McNaughton" <andrew@squiz.co.nz>
Subject: Re: efficient editing
Message-Id: <andrew-2508970138410001@websmith.internet.co.nz>

In article <5tebd1$j3$1@lyra.csx.cam.ac.uk>, mjtg@cus.cam.ac.uk (M.J.T. Guy)
wrote:

>Dean Hoover  <dhoover@textwise.com> wrote:
>>I'm trying to figure out the best way to change:
>>  \ to \\ and | to \V and & to \A
>>
>>in one fell swoop, efficiently.
>
>s/([\\|&])/+{qw:\ \\ | \V & \A:}->{$1}/ge;
>
>Dunno if that's the most efficient, or even the most cryptic.
>
>
>Mike Guy

Probably not the most efficient, but less cryptic, and probably more
efficient (unless some optimization negates it):

%subst = ( '\' => '\\',
           '&' => '\V',
           '|' => '\A',
);

s/([\\|&])/subst{$1}/g;

using a sparse array of substitutions, might be faster than the hashing
function.  Suck it and See.

Andrew


Check out the newsroom:  http://www.newsroom.co.nz
 .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .
Andrew McNaughton         |       I tried to make it idiot proof,
Andrew@squiz.co.nz        |       but they just developed a  
http://www.squiz.co.nz    |       better idiot

 .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .


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

Date: 24 Aug 1997 07:11:56 GMT
From: bpm@minyos.its.rmit.edu.au
Subject: Embedding Perl on Windows NT 4.0
Message-Id: <5tomrs$8q$1@aggedor.rmit.edu.au>

I was wondering whether anyone knew where I could obtain a Perl
distribution for a Windows Nt 4.0 operating system that was able to be 
embedded into C++. I cannot managed to the full package. 

Thanks

Ben



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

Date: Sun, 24 Aug 1997 12:55:32 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Getting index of array element
Message-Id: <EFF58K.6LM@world.std.com>

stupid@wco.com (Eric Penn) writes:

>Let's suppose that I have an array of unique values.  The order of the
>values in significant.  Now, say I'd like to find the index of one value in
>the array.  The  way I've come up with is a brute force search, which to me
>seems both ugly and slow:


When you are filling the initial array, can you fill a parallel hash
that has the array element as the key and the array index as the
value?

@ary = (0,1,2,3,4,5,6,7,8,9);
@hash{@ary} = 0 .. $#ary;

$idx = $hash{7};
print "the index of 7 is $idx\n";

There is also the Tie::IxHash module <URL:http://www.perl.com/
CPAN-local/modules/by-module/Tie/Tie-IxHash-1.2.tar.gz> which created
ordered hashes, I haven't really looked at it yet, but it sounds like
just want you need, the order preserving capabilities of an array, and
lookup capabilities of a hash.


-- 
Andrew Langmead


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

Date: 24 Aug 1997 15:11:59 GMT
From: Ed Young <youngej@magpage.com>
To: Mike Elliott <mre@emerald.compata.com>
Subject: Re: Help on Final Exam (Perl class)
Message-Id: <5tpivv$fne$0@204.179.92.86>

Hmmm.  It would have to be a in a problem domain that is widely
understood, so folks could concentrate on perl, not on the problem
itself.  How about a personal time logger/reporter.  Might even be of
use after the class.  You could use Tk for the interface.  A tied hash
for logged activity selection that could be dynamically updated.  Write
a weekly report.  Could go after system calls like time.  Might even
extend it to include a to-do list, a calendar.  Many possibilities here.

Another idea is a simulation.  This might be a stretch for your class
depending on their backgrounds.  But creating a time driven simulation
of multiple interacting/dependent events (like simulating a shop floor,
or a small business) might be fun.  It would exercise the object part of
perl well.

And for the boneheads (like me) suggest:
ftp://ftp.sedl.org/pub/mirrors/CPAN/ports/win95/Gurusamy_Sarathy/
  perl5.00402-bindist04-bc.readme     10 Kb    Sun Aug 10 20:12:00 1997
  perl5.00402-bindist04-bc.tar.gz   5014 Kb    Mon Aug 11 05:01:00 1997

This excellent binary rendition of perl includes a very complete set
of html manuals, Tk, and a host of other perl modules.  It is up to date
- perl 5.004_02 as advertised.  Works on both Win95 and WinNT.

In truth I use perl on Win95, WinNT, HP-UX, and AIX.  I find the
downside to M$ operating systems are the pathetic MSDOS command line,
lack of forking, no error return on piping in Win95, and the inability
to do #! (you have to use pl2bat.bat to create a .bat file which you
can't pipe into or out of -- bummer).  Otherwise perl is perl (is
great).

Mike Elliott wrote:
> 
> I'm going to be teaching a ten-week Programming in Perl class next
> year, and I'd like to make the Final Exam a Perl project.  As this is
> University Extension, I can't expect more than perhaps 30 to 40 total
> hours (per student) expended on it spread out over the quarter.
> 
> What I'm looking for are suggestions as to what the problem should be.
> Besides the time constraint mentioned above, it should be something
> which is relatively platform independent -- that is, I think I have to
> accommodate bone-heads who insist on using Microsoft operating
> systems.
> 
> Any suggestions welcome --
> 
> Mike Elliott


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

Date: Sun, 24 Aug 1997 07:07:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Horan <horan@inetarena.com>
Subject: Re: Help With Loading of Perl Modules
Message-Id: <Pine.GSO.3.96.970824070350.15467E-100000@julie.teleport.com>

On 23 Aug 1997, Mark Horan wrote:

> 1) Is it essential to have dynamic loading enabled,

No, but it's highly recommended if you're going to be building new
modules. A Linux-specific newsgroup can probably give you the best help
with compiling Perl (or anything else) with dynamic loading under Linux. 
It may even be in their FAQs. 

> How to I build a new Perl executable with the Msql module
> statically linked to it?

This should be covered in the MakeMaker docs. Hope this helps!

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



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

Date: 24 Aug 1997 12:25:37 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Help!! my dbm file crash everytime I try to build it.
Message-Id: <5tp981$sk0$1@lyra.csx.cam.ac.uk>

Mike D. Kail <mdkail@fv.com> wrote:
>did you look at what errno 28 is?
>
>   #define ENOSPC  28      /* No space left on device              */
>
>my guess is you're running out of disk space

Probably not, actually.   ndbm confusingly uses error 28 to mean
"key+data too long" (i.e. more than 1024 bytes).   If practical, change to
using DB_File which doesn't have this restriction.   Otherwise, you'll
have to reorganise your data to make the values smaller.


Mike Guy


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

Date: Mon, 25 Aug 1997 01:56:01 +1200
From: "Andrew McNaughton" <andrew@squiz.co.nz>
Subject: Re: Help, Help, Help... This is killing me...
Message-Id: <andrew-2508970156010001@websmith.internet.co.nz>

>Perhaps it's aborting early. Error messages will be in the log file
>(what a pain). Behold my _favourite_ piece of CGI debugging code,
>prepended to every script:
>
>BEGIN   { open(STDERR,"|/usr/local/script/mailif -s test-ts2.cgi-err
cameron");
>        }
>
>mailif is a script which emails the named user with the specified
>subject line _if the email is not empty_. That way you get nicerly
>packaged error reports and silence when things work.
>        - Cameron Simpson, cs@zip.com.au, DoD#743
>          http://www.zip.com.au/~cs/

with my server I can just print the http header at the start, not worrying
too much about duplication while debugging, and then I get error messages in
my browser.

I also use a short script which includes something like:

	$out = `tail /local/servers/squiz/logs/errors 20` ;
	$out =~ s|(.*)\n(.*)|<B>$1</B><BR>\n$2<BR>|g;
	print $out;

For twiddly extra bits I have an encrypted cookie based authentication
feature which turns debugging features on and off.


Check out the newsroom:  http://www.newsroom.co.nz
 .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .
Andrew McNaughton         |       I tried to make it idiot proof,
Andrew@squiz.co.nz        |       but they just developed a  
http://www.squiz.co.nz    |       better idiot

 .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .


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

Date: Sun, 24 Aug 1997 07:43:33 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Help: Creating a datastructure.
Message-Id: <ebohlmanEFEqsL.vv@netcom.com>

the Thief of Always (omard@blue.seas.upenn.edu) wrote:

: I want to create an array of lists.
: as in I have X amount of the following 
: fields:

: ($ind, $name,$date,$horse, $cat)
: and I want to store them in an associative
: called REF with $ind as they key;  I dont
: particularly wanna concat'em into a string and resplit
: every single time, nor do I wish to reread them.
: the dilemma in essence is that I know the $ind, and I want
: to access $name or $date or $horse or whatever.

: So how do I go about doing this?

man perllol(1).



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

Date: Sun, 24 Aug 1997 12:41:14 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Modem Control
Message-Id: <EFF4Kr.2r0@world.std.com>

forster@na-cp.rnp.br writes:

>Hello Folks!

>I was wondering... Is there any module or something to control modems?

On perl systems that have a POSIX module, there is POSIX::Termios.

If you need more details on Termios, you might want to take a look at
the book "Advanced Programming in the Unix Environment" by WR
Stevens. He does all of his examples in C, but the concepts should be
able to be translated into perl easily.

-- 
Andrew Langmead


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

Date: 21 Aug 1997 02:55:46 GMT
From: "phipic" <philippe.picard@hol.fr>
Subject: PB : Perl win32  and OLE
Message-Id: <01bcadde$d8fdfc00$baab95c2@cybernateure.eure.fr>

hello nice people,
i try to use OLE with perl 5.003 win32 but it does'nt work 

the beginning of the programm is :
###########################
use OLE;


#   -4100 is the value for the Excel constant xl3DColumn.

$ChartTypeVal = -4100;

#   Creates OLE object to Excel
$ExcelApp = CreateObject OLE "excel.application" || die "Unable to create
Excel Object: $!\n";

# Create and rotate the chart

$ExcelApp->{'Visible'} = 1;
$ExcelApp->Workbooks->Add();
####################################"


i have tried to debug this programm and i have seen that the function 
"olecreateobject in OLE module" return undef as object ( $ExcelApp in my
programm)
is it normal ?
help me !  thanks 




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

Date: Mon, 25 Aug 1997 01:11:09 +1200
From: "Andrew McNaughton" <andrew@squiz.co.nz>
Subject: Re: Perl Performance FAQ?
Message-Id: <andrew-2508970111090001@websmith.internet.co.nz>

In article <5tcf0u$gc$1@taurus.fccc.edu>, edmonson@chlccs.fccc.edu (Michael
N. Edmonson) wrote:

>- When passing large arrays or hashes to subroutines, pass 
>  references to the objects intead.  There may be a little more
>  expense associated with dereferencing, but at least Perl won't have
>  to make a copy of the whole thing with every subroutine call.

maybe.  Sometimes it's just extra complexity.


@foo = (1..1000);

$start = time();
foreach $iter (1..1000) {
  &without_ref(@foo);
}
  print "sum = $sum\n";

$time_taken = time() - $start;
print "without_ref: $time_taken\n";


$start= time();
foreach $iter (1..1000) {
  &with_ref(\@foo);
}
print "sum = $sum\n";

$time_taken = time-$start;
print "with_ref: $time_taken\n";

exit;

sub without_ref {
  $sum=0;
  foreach (@_){
    $sum += $_;
  }
}

sub with_ref {
  $bar= @_[0];
  $sum=0;
  foreach (@$bar){
    $sum += $_;
  }
}


################
OUTPUT

sum = 500500
without_ref: 10
sum = 500500
with_ref: 10


Executed on a PowerMac 7500/100


Check out the newsroom:  http://www.newsroom.co.nz
 .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .
Andrew McNaughton         |       I tried to make it idiot proof,
Andrew@squiz.co.nz        |       but they just developed a  
http://www.squiz.co.nz    |       better idiot

 .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .




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

Date: Sun, 24 Aug 1997 07:01:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Marty D. Cudmore" <cudmores@gte.net>
Subject: Re: POP3 Mail
Message-Id: <Pine.GSO.3.96.970824065956.15467D-100000@julie.teleport.com>

On 24 Aug 1997, Marty D. Cudmore wrote:

> I'm wondering if it's possible to use the Net::POP3 module on my
> Win32 system.

If it's not documented whether it works there or not, you should ask the
author to include that information in the docs. Of course, the author may
ask your help in porting it. :-)  Good luck!

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



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

Date: Sun, 24 Aug 1997 09:49:38 -0400
From: David Eck <daveck@top.monad.net>
Subject: problem with openning file for appending
Message-Id: <34003BF2.E060EC9D@top.monad.net>

This is the bit of code:

open(FILE,">>$filename") or &CgiDie("Could not open file");

I'm using the readparse function from cgi-lib.pl to get the value for
$filename from a html form.

My next step is to assign the value to $filename:

$filename = &input{'file'};

Lets say the value is 'file';

The only way I can open the file with $filename is by doing something
like this:

$_ = $filename;
if(m/(.)(.)(.)(.)/) {
   $filename = "$1$2$3$4";  }

Then it will work.

Anyone have any ideas?  Its driving me crazy!

Thanks,
David Eck


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

Date: Sun, 24 Aug 1997 14:09:36 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: problem with openning file for appending
Message-Id: <34004051.587777008@news.bgsu.edu>

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

On Sun, 24 Aug 1997 09:49:38 -0400, David Eck <daveck@top.monad.net>
wrote:

>This is the bit of code:
>
>open(FILE,">>$filename") or &CgiDie("Could not open file");
>
>I'm using the readparse function from cgi-lib.pl to get the value for
>$filename from a html form.
>
>My next step is to assign the value to $filename:
>
>$filename = &input{'file'};
>
>Lets say the value is 'file';
>
>The only way I can open the file with $filename is by doing something
>like this:
>
>$_ = $filename;
>if(m/(.)(.)(.)(.)/) {
>   $filename = "$1$2$3$4";  }
>
>Then it will work.
>
>Anyone have any ideas?  Its driving me crazy!

Hmm... It's been quite a while since I hacked with cgi-lib.pl, but
should you be using "$filename = $input{'file'}?

Also, consider upgrading to CGI.pm for your CGI development. I think
you'll find that it saves you loads of time on even simple scripts.

Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>

"That's an example of how Perl can bring school yard cruelty to new heights."
    -- Jon Orwant at the 1st Annual Perl Conference


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

Date: Sun, 24 Aug 1997 08:08:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: David Eck <daveck@top.monad.net>
Subject: Re: problem with openning file for appending
Message-Id: <Pine.GSO.3.96.970824074742.15467I-100000@julie.teleport.com>

On Sun, 24 Aug 1997, David Eck wrote:

> This is the bit of code:
> 
> open(FILE,">>$filename") or &CgiDie("Could not open file");

It's even better to make the message include the magical $! variable,
something like this. (That var holds a message which you can find in the
perldiag(1) manpage for more information on what went wrong.) 

	or &CgiDie("Could not open file '$filename': $!");

> I'm using the readparse function from cgi-lib.pl to get the value for
> $filename from a html form.

It's even better to use CGI.pm than cgi-lib.pl.

> My next step is to assign the value to $filename:

Waitaminute! Don't you have this backwards? You'll have to have $filename
before you open the file. So I'll assume that you're now telling us what
came before that open statement.

> $filename = &input{'file'};
> 
> Lets say the value is 'file'; The only way I can open the file with
> $filename is by doing something like this: 
> 
> $_ = $filename;
> if(m/(.)(.)(.)(.)/) {
>    $filename = "$1$2$3$4";  }

Sounds as if you're doing taint checking. That's good! You probably want
to make a pattern that will match permitted filenames, so here's a way I
sometimes use, adapted for what (I think) you're doing. This lets someone
have some freedom in choosing a filename, but restricts it to a small set
of known-good, known-safe filenames.

    ($filename) = (&input{'file'} =~ /
	^			# Starts with
	(			# (start memory one)
	    [A-Za-z]		# a letter
	    \w{0,7}		# up to seven more alphanumerics
	    (?:			# non-memory parens
		\.		# a period
		\w{0,3}		# up to three extension chars
	    )?			# extension is optional
	)			# (end memory one)
	$			# end of string
    /x);
    &CgiDie("Filename has invalid form") unless defined $filename;

Now you should have a good, safe filename in $filename. (Of course, you're
not going to open anything in the same directory as your script, right? 
That's not good for security reasons.) Be sure to check out the perlsec(1) 
manpage to learn more about taint checking. Have fun with it!

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



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

Date: Sun, 24 Aug 1997 10:53:56 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Random Numbers
Message-Id: <34060986.3700956@news.tornado.be>

Arthur Merar <amerar@unsu.com> wrote:

>I am trying to generate a random integer that is between 0 and the size
>of an array.  I tried using the RAND command, but that does not seem to
>be working correctly.....

To all the jokers: this is a quote from the POD, item *rand*:

Note: If your rand function consistently returns numbers that are too
large or too small, then your version of Perl was probably compiled
with the wrong number of RANDBITS.

A porting problem, I'd say.

In the meantime (not everybody can make their own Perl port), you could
try building your own pseudo-random generator.

	sub random ($) {
		my ($a,$c,$m) = (16807,0,(1<<31)-1);
		$seed = ($seed * $a + $c) mod $m;
		return int($_[0] * $seed / $m);
	}

$seed is a STATIC variable, so it's value should be retained between
subsequent function calls. For this, it might be a good idea to put this
into a separate package (or module).

Randomize is done by assigning an integer value to $seed.

HTH,
Bart.


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

Date: Sat, 23 Aug 1997 00:23:50 -0700
From: anthony@outshine.com (Anthony Boyd)
Subject: Re: Search Engine scripts ?
Message-Id: <anthony-2308970023510001@anthony.outshine.com>

Eli the Bearded <usenet-tag@qz.little-neck.ny.us> wrote:
> Peter Douglas <rmanocha@rocketmail.com> wrote:
> 
> > I am developing a search engine for a company. The search engine is
> > probably going to be in a similar format as yahoo or search.com where you
> > can search through many categories. 
> > 
> > I am looking for a script (preferably free) which does a similar thing.
> 
> So let me get this straight,
> 
> (1) You are being paid to do some work
> (2) You would like to steal someone else's code as a framework

Be nice Eli, he didn't say what he was going to do with it.  He may want
to steal code and get paid for it, but he may also want to write the
entire thing himself, learning by example.  I myself have had the concept
of indexing explained many times, but until I saw the actual code for
building an index, I couldn't visualize a practical implementation.


-Anthony Boyd
 www.borland.com


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

Date: Sun, 24 Aug 1997 12:30:48 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Setting subject in emails
Message-Id: <EFF43C.2r@world.std.com>

Dan_Margalit@brown.edu (Dan_Margalit) writes:

>	Can anyone tell me how to send an email with a specific subject from 
>perl? 

Since perl has no built in feature for connecting to mail transport
agents, it would depend on what program or library you are using to
send the mail message.

For example, if you used the Mail::Send module that is available at
<URL:http://language.perl.com/CPAN-local/modules/by-module/Mail/
MailTools-1.09.tar.gz> then it is a matter of calling the "subject"
method this a scalar containing your subject as a parameter.

$msg->subject("questionnaire completed");

If your are piping to sendmail, then you must be using the "-t" option
and writing the header yourself. just add a subject header. (and if
you aren't using the "-t" option, then you are probably opening up a
huge security hole by allowing users to enter fake e-mail addresses
that will allow them to run commands on the server.)

If you are piping to a BSD derived "mail" program, then you can set
the subject with the "-s" option, but again, web clients can execute
shell escapes to execute programs on the server. So I don't think you
want that, either.

>	Please email me (juggler@brown.edu) if you can help, as I do not 
>frequent this newsgroup.  Thank you very much.

But on the other hand, the people who respond to articles are trying
to help everyone who might have a similar question, not just help one
individual. Maybe you could search the newsgroup for articles whose
subject line match yours. (Or if you have a threaded newsreader, even
better. Read the articles that are responses to yours.)
-- 
Andrew Langmead


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

Date: 24 Aug 1997 15:05:07 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <5tpij3$n6r$2@info.uah.edu>

Following is a summary of articles spanning a 7 day period,
beginning at 16 Aug 1997 08:48:39 GMT and ending at
23 Aug 1997 06:28:56 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" e-mail address and name.
    - Original Content Rating is the ratio of the original content volume
      to the total body volume.
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Find the NewsScan junkyard at http://www.cs.uah.edu/~gbacon/clpm/

Excluded Posters
================

perlfaq-suggestions@mox.perl.com

Totals
======

Total number of posters:  391
Total number of articles: 802 (262 with cutlined signatures)
Total number of threads:  360
Total volume generated:   1320.0 kb
    - headers:    552.7 kb (11,019 lines)
    - bodies:     719.1 kb (22,775 lines)
    - original:   523.6 kb (16,881 lines)
    - signatures: 46.4 kb (1,013 lines)
Original Content Rating: 0.7282

Averages
========

Number of posts per poster: 2.1
Number of posts per thread: 2.2
Message size: 1685.4 bytes
    - header:     705.6 bytes (13.7 lines)
    - body:       918.2 bytes (28.4 lines)
    - original:   668.6 bytes (21.0 lines)
    - signature:  59.3 bytes (1.3 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   32    52.6 ( 28.0/ 19.3/ 11.6)  Tom Phoenix <rootbeer@teleport.com>
   24    42.8 ( 13.9/ 21.4/ 15.0)  Mike Stok <mike@stok.co.uk>
   22    39.3 ( 14.4/ 25.0/ 13.7)  Tad McClellan <tadmc@flash.net>
   20    32.7 ( 15.2/ 17.5/ 10.6)  Doug Seay <seay@absyss.fr>
   16    23.4 ( 10.3/ 13.1/  6.4)  M.J.T. Guy <mjtg@cus.cam.ac.uk>
   14    21.9 ( 10.2/ 10.3/  6.7)  polone@sanasys.com
   11    20.5 (  5.7/ 14.6/  7.5)  Andrew M. Langmead <aml@world.std.com>
   10    11.0 (  5.4/  5.6/  2.9)  Eric Bohlman <ebohlman@netcom.com>
   10    15.6 (  6.5/  8.6/  5.0)  Tom Grydeland <tom@mitra.phys.uit.no>
    9    19.3 (  6.5/ 12.8/ 10.5)  Terry Michael Fletcher - PCD ~ <tfletche@pcocd2.intel.com>

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

  52.6 ( 28.0/ 19.3/ 11.6)     32  Tom Phoenix <rootbeer@teleport.com>
  42.8 ( 13.9/ 21.4/ 15.0)     24  Mike Stok <mike@stok.co.uk>
  39.3 ( 14.4/ 25.0/ 13.7)     22  Tad McClellan <tadmc@flash.net>
  32.7 ( 15.2/ 17.5/ 10.6)     20  Doug Seay <seay@absyss.fr>
  23.4 ( 10.3/ 13.1/  6.4)     16  M.J.T. Guy <mjtg@cus.cam.ac.uk>
  21.9 ( 10.2/ 10.3/  6.7)     14  polone@sanasys.com
  20.5 (  5.7/ 14.6/  7.5)     11  Andrew M. Langmead <aml@world.std.com>
  19.7 (  0.6/ 19.1/ 19.1)      1  Realmz Mud Account <dragon2@endo.mudservices.com>
  19.3 (  6.5/ 12.8/ 10.5)      9  Terry Michael Fletcher - PCD ~ <tfletche@pcocd2.intel.com>
  15.6 (  6.5/  8.6/  5.0)     10  Tom Grydeland <tom@mitra.phys.uit.no>

Top 10 Posters by OCR (minimum of five posts)
==============================================

          (kb)    (kb)
OCR       orig /  body  Posts  Address
------  --------------  -----  -------

1.0000     1.7 /   1.7      6  temp.ed.vanderbush@bentley.com
0.9916    12.4 /  12.6      5  Aaron Sherman <ajs@lorien.ajs.com>
0.9857     3.2 /   3.3      6  bsa@void.apk.net
0.9387     8.9 /   9.4      6  Nathan V. Patwardhan <nvp@shore.net>
0.8814     2.8 /   3.2      6  Ulrich Pfeifer <pfeifer@ls6.informatik.uni-dortmund.de>
0.8415     2.8 /   3.3      5  Terje Bless <link@tss.no>
0.8202     7.0 /   8.5      5  David Bauman <davey@harvard.edu>
0.8185    10.5 /  12.8      9  Terry Michael Fletcher - PCD ~ <tfletche@pcocd2.intel.com>
0.7847     2.1 /   2.7      6  Joshua Marotti <jpm@iti-oh.com>
0.7284     1.5 /   2.1      5  Xu Chu <xuchu@iscs.nus.edu.sg>

Bottom 10 Posters by OCR (minimum of five posts)
=================================================

          (kb)    (kb)
OCR       orig /  body  Posts  Address
------  --------------  -----  -------

0.5777     5.0 /   8.6     10  Tom Grydeland <tom@mitra.phys.uit.no>
0.5502    13.7 /  25.0     22  Tad McClellan <tadmc@flash.net>
0.5216     2.9 /   5.6     10  Eric Bohlman <ebohlman@netcom.com>
0.5161     7.5 /  14.6     11  Andrew M. Langmead <aml@world.std.com>
0.4865     6.4 /  13.1     16  M.J.T. Guy <mjtg@cus.cam.ac.uk>
0.4832     1.5 /   3.1      5  Jim Trocki <trockij@transmeta.com>
0.4622     2.3 /   5.0      8  Ajitesh Das <ajiteshd@wiproge.med.ge.com>
0.4412     3.2 /   7.1      9  Simon Fairey <sfairey@adc.metrica.co.uk>
0.3263     2.4 /   7.4      8  Thad Welch <tw36027@glaxowellcome.com>
0.1793     1.0 /   5.4      7  Darin Burleigh <burleigh@hackberry.chem.niu.edu>

Top 10 Threads by Number of Posts
=================================

Posts  Subject
-----  -------

   14  How do I find the system date/time?
   10  How do I create a directory and then create a directory within that directory?
   10  naming arrays
   10  Chars into Array
    9  emacs?  No thank you
    8  HTML --> Perl conversion
    8  *Really* dynamic function loading?
    7  readig a file into an array
    7  Hash + Regex
    6  how to parse only the lines between <pre> and </pre>

Top 10 Threads by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Subject
--------------------------  -----  -------

  19.7 (  0.6/ 19.1/ 19.1)      1  Chat Program (PERL), Many Errors....
  19.6 ( 11.5/  7.4/  5.1)     14  How do I find the system date/time?
  16.1 (  7.9/  7.3/  4.8)      9  emacs?  No thank you
  16.0 (  5.9/  9.7/  7.3)      8  *Really* dynamic function loading?
  15.9 (  7.7/  6.9/  4.6)     10  How do I create a directory and then create a directory within that directory?
  15.4 (  4.4/ 10.1/  4.5)      7  Hash + Regex
  15.3 (  2.4/ 12.8/ 11.4)      4  TCL 8.0: A whole lot of perl
  13.6 (  6.3/  6.8/  3.2)     10  naming arrays
  12.0 (  6.6/  4.8/  3.3)      8  HTML --> Perl conversion
  11.9 (  2.7/  8.9/  8.0)      4  Statistics for comp.lang.perl.misc

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      24  comp.lang.perl.modules
      10  comp.lang.perl.tk
       9  comp.lang.perl
       5  comp.unix.solaris
       5  alt.fan.e-t-b
       4  comp.lang.tcl
       3  comp.sys.sun.admin
       2  comp.lang.java.help
       2  comp.unix.shell
       2  comp.lang.javascript

Top 10 Crossposters
===================

Articles  Address
--------  -------

      17  Alastair Todd <alastair@net7.co.uk>
       8  buckner@halcyon.com
       5  Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
       4  Andrew Beckett <andrewb@cadence.com>
       4  "Richard J. Finn" <rfinn@houston-interweb.com>
       4  Doug Seay <seay@absyss.fr>
       3  Jerome Schevingt <jpc@avo.fr>
       3  Matthew Cravit <mcravit@best.com>
       3  Ilya Zakharevich <ilya@math.ohio-state.edu>
       3  Tom Grydeland <tom@mitra.phys.uit.no>


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

Date: 24 Aug 1997 15:01:13 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
To: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <5tpibp$n6r$1@info.uah.edu>

[Posted and mailed]

In article <33fd49b0.634273@news.tornado.be>,
	bart.mediamind@tornado.be (Bart Lateur) writes:
: Note that you get a "good" OCR if you only ask questions, and a "bad"
: OCR ratio if you only answer them. As in my case.

IMHO, OCR is an amoral attribute. :-)  Never lose sight of the wisdom of
Mark Twain: "There are three kinds of deceit: lies, damn lies, and
statistics".  An example of this (pointed out by Marilyn vos Savant a
couple of years ago) is a good survey will show a correlation between
ear size and math proficiency.  The reason for this is that a truly
random sample will include babies and small children who, of course,
have smaller ears than the rest of us.

If anyone has suggestions for more useless but interesting statistics
for inclusion in the weekly report, please feel free to send them my
way.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Mon, 25 Aug 1997 01:23:54 +1200
From: "Andrew McNaughton" <andrew@squiz.co.nz>
Subject: Re: Using passwd command inside a perl script
Message-Id: <andrew-2508970123540001@websmith.internet.co.nz>

I think you'll find that passwd will be pretty picky about where it accepts
input from.  You'll probably need to manipulate the passwd file directly.

I'd reccomend though that this is the sort of job that gets done thousands
of times, and you'd be better to find a script that either does what you
want or at least provides useful subroutines.  There are of course major
security implications to doing this at all so be very careful.

eg check user entries for colons and null values, and escape regexp stuff.

From: bwiren@bs.wa.gov.au (Brian Wiren)
>
>
>Hi
>
>I am trying to use the UNIX /usr/bin/passwd command within a script.
>
>I am setting up a system to allow people to administer their POP Email 
>accounts.
>
>I have tried to open passwd as a file handle then print the info to the
pipe - 
>but alas no worky.
>
>Any help would be appreciated.
>
>Regards Brian


Check out the newsroom:  http://www.newsroom.co.nz
 .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .
Andrew McNaughton         |       I tried to make it idiot proof,
Andrew@squiz.co.nz        |       but they just developed a  
http://www.squiz.co.nz    |       better idiot

 .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .




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

Date: Sun, 24 Aug 1997 13:56:03 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: When is Perl interpreted?
Message-Id: <34003c9a.586826241@news.bgsu.edu>

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

On 15 Aug 1997 12:04:59 GMT, "Larry Long" <ljlong@wcom.com> wrote:

>I need to if perl is interpreted at execution and held in memory 
>or
>is it interpreted a line at a time at execution?

The first one.

For more info, see the following:

http://perl-com.songline.com/CPAN-local/doc/FMTEYEWTK/comp-vs-interp.html

Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>

"That's an example of how Perl can bring school yard cruelty to new heights."
    -- Jon Orwant at the 1st Annual Perl Conference


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

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

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