[11821] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5421 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 19 17:12:34 1999

Date: Mon, 19 Apr 99 14:00:23 -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           Mon, 19 Apr 1999     Volume: 8 Number: 5421

Today's topics:
        [Perl For Win32] ActiveX control Question <swolfington@home.com>
    Re: Another bug in Perl? <dgris@moiraine.dimensional.com>
    Re: DateCalc not working properly <dgris@moiraine.dimensional.com>
        Djgpp or Activestate ? <Hubert.Toullec@wanadoo.fr>
    Re: FAQ 3.16: How can I make my Perl program run faster <cassell@mail.cor.epa.gov>
    Re: FAQ 3.16: How can I make my Perl program run faster <tchrist@mox.perl.com>
        Globdammit!!! <grichard@uci.edu>
    Re: Globdammit!!! <cassell@mail.cor.epa.gov>
    Re: help with Mail::Send <jtjuslin@wannabe.mit.edu>
        how to use local variables in code refs? <agianni@acsu.buffalo.edu>
    Re: how to use local variables in code refs? <tchrist@mox.perl.com>
    Re: how to use local variables in code refs? <rra@stanford.edu>
        Interpolating Variables for 'use' <kubla_khan@rocketmail.com>
    Re: Making a hash of 2-D and 3-D Associative Arrays <aqumsieh@matrox.com>
    Re: Making a hash of 2-D and 3-D Associative Arrays (Larry Rosler)
    Re: Number of elements of a hash table <aqumsieh@matrox.com>
        Perl Error Message??? <rdsys@inficad.com>
    Re: Perl Error Message??? <arnej@fc.hp.com>
    Re: Perl pipe under OS/2 broken? (Ilya Zakharevich)
        Poss bug in CGI.pm, Multipart, eval() and die() (Clinton Pierce)
        Problems installing perl module (DBI) jparker7345@my-dejanews.com
    Re: Random Integer creation <dgris@moiraine.dimensional.com>
    Re: Running CGI scripts OFFLINE <kram@techie.com>
    Re: Scripting language with LFN support? (Sylvan Butler)
        Solved (was Re: DateCalc not working properly) <tedder@pacifier.com>
    Re: Splitting length instead of delimiting character? (Larry Rosler)
        Stop posting twice! <tripix@tdi-net.freeserve.co.uk>
    Re: Stop posting twice! <tchrist@mox.perl.com>
    Re: Stop posting twice! matt@matt.com
        tie'd hashes <tpost@intelihealth.com>
    Re: Tool Reuse Considered Beneficial (was: New FAQ: How <dgris@moiraine.dimensional.com>
    Re: Top 10 newbie errors? (Clinton Pierce)
    Re: Top 10 newbie errors? (Larry Rosler)
    Re: Why does Perl do this? Not because of this <propart@mediaone.net>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 19 Apr 1999 20:22:21 GMT
From: "Scott W" <swolfington@home.com>
Subject: [Perl For Win32] ActiveX control Question
Message-Id: <1gMS2.18154$PI4.2191@news.rdc2.occa.home.com>

Hi!

Does Perl for Win32 currently support calling functions in ActiveX
controls?  If anyone knows if this is possible or how to do it then
any help would be much appreciated.  Thanks!

Scott





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

Date: 19 Apr 1999 14:19:53 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Another bug in Perl?
Message-Id: <m3676scqhi.fsf@moiraine.dimensional.com>

andy@-nospam-haveland.com (Andrew Haveland-Robinson) writes:

> You would think this works OK...

> 	$msgdec =~ s/(.)/uc sprintf("%02x",ord($1))/eg;

> Well, 99.61% of the time it does... until $msgdec contains an LF
> The LFs in the string are returned untouched.

 . does not match newlines unless you add the /s modifier to your
regular expression.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 19 Apr 1999 14:22:12 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: DateCalc not working properly
Message-Id: <m3zp44bbt7.fsf@moiraine.dimensional.com>

Ted Timmons <tedder@pacifier.com> writes:

> But now I've got it installed on a Caldera 1.3 box - that's a Linux
> flavor. First, it didn't install to a path in the @INC

If it installed in the wrong place then your perl installation
is broken.  Make sure that you are using the appropriate perl
to run Makefile.PL.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Mon, 19 Apr 1999 22:35:43 +0200
From: "Hubert Toullec" <Hubert.Toullec@wanadoo.fr>
Subject: Djgpp or Activestate ?
Message-Id: <7fg44a$rsp$1@wanadoo.fr>

I am a DJGPP Tools user since several years now.

I plan to begin to use the perl language but before, I would appreciate to
have some advice on which distribution to use : the DJGPP or the ACTIVESTATE
one ?

As far as I know, the present release level is 5.005_02 for DJGPP and a bit
higher for ACTIVESTATE.

At identical release level, what are the differences between these two
distributions ?

What about add-ons (perlscript, etc) and are they usable on both
distributions ?

Thanks for your opinions

hubert.toullec@wanadoo.fr





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

Date: Mon, 19 Apr 1999 12:12:33 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: FAQ 3.16: How can I make my Perl program run faster?
Message-Id: <371B8021.9C3586D2@mail.cor.epa.gov>

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc,
>     David Cassell <cassell@mail.cor.epa.gov> writes:
> :Would you consider an addition like this:
> :
> :If you are attempting to speed up your Perl programs on a web server,
> :you may want to look into mod_perl for the Apache webserver, or
> :PerlEx for Microsoft IIS.
> 
> Well, yes, but doesn't the other question answer that?

Yes.  FAQ 3.20 answers this in far more detail than I managed.
And with much better attention to clarifying the technical aspects.
Even though it only touches on Apache+mod_perl, and not on 
IIS+PerlEx.  [I wonder why? :-]

So is there any point in adding a pointer for FAQ 3.20 for the
less clueful?  Some other FAQ answers have pointers or leads to
later answers.

Just trying to help, if you can call it that,
David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: 19 Apr 1999 13:28:13 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 3.16: How can I make my Perl program run faster?
Message-Id: <371b83cd@cs.colorado.edu>

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

In comp.lang.perl.misc, David Cassell <cassell@mail.cor.epa.gov> writes:
:So is there any point in adding a pointer for FAQ 3.20 for the
:less clueful?  Some other FAQ answers have pointers or leads to
:later answers.

Patches speak louder that words. :-)

--tom
-- 
Those who do not fight the demons within themselves are destined to fight them 
 outside themselves...


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

Date: Mon, 19 Apr 1999 11:58:48 -0700
From: "Gabriel Richards" <grichard@uci.edu>
Subject: Globdammit!!!
Message-Id: <7ffu5e$ser@news.service.uci.edu>

Does glob not work right on win32 systems? There is a file named 1.dat which
should be assigned to @messagelist with the code below. It works on
unix/apache not on win32/pws or win32/apache.

 $messagedir = "c:/websites/openmic/forums/$forum";
 @messagelist = glob("$messagedir/*.dat");

The only difference between the working unix one and the non-working win32
is the path which I assure you is correct. print "$messagelist[0]"; prints
nothing (on win32) when it should print 1.dat. Again, all's well on Unix.

Gabe




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

Date: Mon, 19 Apr 1999 12:31:52 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Globdammit!!!
Message-Id: <371B84A8.3908D7EC@mail.cor.epa.gov>

Gabriel Richards wrote:
> 
> Does glob not work right on win32 systems?

No.  Yes.  I mean, it doesn't work right.

Well actually, the problem is that the *shell* doesn't do what Perl
is expecting it to, like the unixoid shells.

That leads to the two alternatives below:

>                                           There is a file named 1.dat which
> should be assigned to @messagelist with the code below. It works on
> unix/apache not on win32/pws or win32/apache.
> 
>  $messagedir = "c:/websites/openmic/forums/$forum";
>  @messagelist = glob("$messagedir/*.dat");
> 
> The only difference between the working unix one and the non-working win32
> is the path which I assure you is correct. print "$messagelist[0]"; prints
> nothing (on win32) when it should print 1.dat. Again, all's well on Unix.

You can use File::DosGlob, which comes with the ActiveState Perl 
installations.  Or, if you prefer, you can get a unix-ish shell for
win32, or go as far as CygWin32 or MKS, and get more Unix untility.
But if you keep going in that direction, you'll just have linux. :-)

HTH,
David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Mon, 19 Apr 1999 22:27:03 +0300
From: Jukka Juslin <jtjuslin@wannabe.mit.edu>
Subject: Re: help with Mail::Send
Message-Id: <371B8387.E6BDED35@wannabe.mit.edu>

luca wrote:

Your syntax seems not to be right. What kind of error message did the
interpreter give?

> 
> Please, can you help me?
> I tried to use the perl module Mail::Send
> in the following way:
> 
>      #!/usr/bin/perl
>      use Mail::Send;

Easier to do with $mail = Mail::Internet->new();

>      $mail = new Mail::Send Subject => "question" , To =>
> "lucab\@surf.it";
>      $fh = $mail->open;
>      print $fh "how can I... ";
>      $fh->close;

This could be:

$mail->add(	To => 'root@my.org',
		cc => 'all@my.org',
		Subject => 'Your account is deleted.'
	   );

$mail->body( "Now.");

 
> but it returns to me the following e-mail:
> 
>      Return-Path: <nobody>
>      Date: Sat, 17 Apr 1999 13:41:05 -0700
>      From: Nobody <nobody>
>      To: lucab@surf.it
>      X-Censor-LoC: -1
> 
>      ~s question
>      how can I...
> 
> also with null subject.
> And how can I specify the "from" field too?

++Jukka Juslin


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

Date: Mon, 19 Apr 1999 14:53:46 -0400
From: Andrew S Gianni <agianni@acsu.buffalo.edu>
Subject: how to use local variables in code refs?
Message-Id: <371B7BBA.482D95E9@buffalo.edu>

Maybe there's a better way to do this, so if there is then please
suggest it. Here's what I'm trying to do and how I'm trying to do it. I
have a subroutine that works for a few different things. I want to go
through an array (an array of hashes actually) and I need to stop at
various times and return to the main program. The problem is there are a
few different exit conditions which are totally unrelated. Things like
checking for a value in a hash, or checking for current array index.
Anyway I'm trying to deal with this by passing a code ref into the
subroutine that evaluates a conditional expression. My problem is that
sometimes, I need to access some of the subroutine's local variables
(my()'ed) from within the code ref. For example, these two calls to the
subroutine should work:

&sample_sub(\@array, sub{$next_record{'location'} ne 'l'});
&sample_sub(\@array, sub{$#{$array} > 100});

sub sample_sub{
  my ($array, $conditional) = @_;
  my $next_record;
  
  while($next_record = shift(@$array) && &$conditional){
    <do stuff>
  }
}

Unfortunately this won't work. (note that I threw this code together,
it's not actual code from my program and might not quite work anyway,
but you should get the idea) I have to explicitly put the local
variables and stuff in some other package so they're accessable by the
subroutine. Is there any way to get around this and keep the variables
truly local? I tried all sorts of stuff, but it doesn't seem to work. I
keep thinking I want to use closures, but this is backwards from that
right? Again, I'm thinking maybe there's a better way to pass these
conditionals into the subroutine, so if there is, please let me know.
TIA!

Andrew
-- 
Andrew Gianni - Developer      		"You are about to be told one
UNIX Guy/Juggler Extraordinaire		 more time that you are America's
SUNY at Buffalo ACS/CIT			 most valuable natural resource... 
ph:(716)645-3587x7009			 Have you seen what they do to
fx:(716)645-3588			 valuable natural resources?"
agianni@buffalo.edu					-Utah Phillips
http://www.cs.buffalo.edu/~agianni/


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

Date: 19 Apr 1999 13:07:49 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: how to use local variables in code refs?
Message-Id: <371b7f05@cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Andrew S Gianni <agianni@acsu.buffalo.edu> writes:
:&sample_sub(\@array, sub{$next_record{'location'} ne 'l'});
:&sample_sub(\@array, sub{$#{$array} > 100});
:
:sub sample_sub{
:  my ($array, $conditional) = @_;
:  my $next_record;
:  
:  while($next_record = shift(@$array) && &$conditional){
:    <do stuff>
:  }
:}

You're completely confusing lexical scoping, which is usually a force
of god, with dynamic scoping, which is often a force for wickedness.

Your closures should only mention lexicals in the scope they 
were created in.  Otherwise, you're looking for shallow binding,
not deep binding, which is naughty.

The solution is to use... ARGUMENTS!

--tom
-- 
If you want your program to be readable, consider supplying the argument.
            --Larry Wall in the perl man page 


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

Date: 19 Apr 1999 12:25:24 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: how to use local variables in code refs?
Message-Id: <ylg15wpg4b.fsf@windlord.stanford.edu>

Tom Christiansen <tchrist@mox.perl.com> writes:

> You're completely confusing lexical scoping, which is usually a force of
> god,

Yeah, that's kind of how I feel about lexical scoping too.  Although I
occasionally want to s/force/act/.

:)

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Mon, 19 Apr 1999 16:23:29 +0100
From: Kubla Khan <kubla_khan@rocketmail.com>
Subject: Interpolating Variables for 'use'
Message-Id: <371B4A71.EBC0B53E@rocketmail.com>

I am trying to 'use' modules dynamically.  I have the module name in a
variable and would like to interpolate the variable as a string for the
'use' call.
Does anyone know how to do this?

ex.
$module = "CGI";
use $module;

But the string is not interpolated correctly like that or with "$module"
or {$module}...

Thanks.



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

Date: Mon, 19 Apr 1999 13:33:30 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Making a hash of 2-D and 3-D Associative Arrays
Message-Id: <x3y676sh5w7.fsf@tigre.matrox.com>


"Clyde Ingram" <cingram@pjocs.demon.co.uk> writes:

> awk provides a simple mechanism for building and traversing
> multi-dimensional associative arrays.  I would like to do the same in perl.

You can do anything in Perl. You just need to know how.

> Apologies in advance, but I cannot decipher the FAQs discussions on hashes
> of lists, hashes of hashes, etc., which I suspect may answer my question.

Have you read 'perldsc', 'perlref' and 'perllol' yet? If not, then you
should do that first.

[snip some awk code]

> If some kind person could spell out how to rewrite this in perl, it would
> help me expand my horizons beyond awk.  Thanks for constructive responses.

Reading the docs I mentioned above should give you every bit of
information you need. But, here's a little preview.

Associative arrays are more commonly known as 'hashes' in the Perl
community. To construct a 1-D hash:

	# to populate the hash all in one shot.
	my %hash = ('Fred'   => 'Wilma',
		 'Barney' => 'Betty'
		);

	# to add key, value pairs
	$hash{'Homer'} = 'Marge';

	# to retrieve the keys
	@keys = keys %hash;

To construct 2-D (or whatever) hashes, just use more keys:

	$hash{'Homer'}{'Wife'} = 'Marge';
	$hash{'Homer'}{'Son'}  = 'Bart';

Perl will take care of the dirty work for you. The key thing to
remember is that, in Perl, hash values can only be scalars. So, you
can't have hashes of hashes, strictly speaking. In the above example, %hash
is actually a hash of references to hashes (since references are
scalars). Read 'perlref' for more info on references. So, if you:

	print $hash{'Homer'};

you will get something like:

	HASH(0xb7438)

which indicates that it is a hash reference. To access its keys, you
have to dereference it:

	@keys = keys %{$hash{'Homer'}};

If you still have any problems after reading more docs, then post
again, and someone will help you.

HTH,
Ala



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

Date: Mon, 19 Apr 1999 13:43:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Making a hash of 2-D and 3-D Associative Arrays
Message-Id: <MPG.1185353fc32a014f9898df@nntp.hpl.hp.com>

In article <x3y676sh5w7.fsf@tigre.matrox.com> on Mon, 19 Apr 1999 
13:33:30 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...
> You can do anything in Perl. You just need to know how.

Can I leap tall buildings in a single bound?  Even a Turing machine 
can't do that.  Wowee!!!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 19 Apr 1999 13:36:25 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Number of elements of a hash table
Message-Id: <x3y4smch5ra.fsf@tigre.matrox.com>


Federico Abascal <fabascal@gredos.cnb.uam.es> writes:

> Please, how can I know the number of elements of a hash in a fast way.

I suppose 'elements' means 'keys' ... so:

	$num = scalar keys %hash;



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

Date: Mon, 19 Apr 1999 19:38:13 GMT
From: "Ray A. Lopez" <rdsys@inficad.com>
Subject: Perl Error Message???
Message-Id: <371B8624.4C350057@inficad.com>

The script (sorts a list of numbers) works fine, but I get an error
message in my output which I don't seem to understand (or understand how
to fix appropriately).  Any idea on what I am doing wrong?

tia,

Ray

This is the output:

2 38 28 0 34 7 14 1
Use of uninitialized value at .//sort.pl line 12 (#1)

    (W) An undefined value was used as if it were already defined.  It
was
    interpreted as a "" or a 0, but maybe it was a mistake.  To suppress
this
    warning assign an initial value to your variables.

Use of uninitialized value at .//sort.pl line 19 (#1)

0  1 2 7 14 28 34 38

#########################################################

#!/usr/local/bin/perl -w
use diagnostics;
use strict;

my @numbers = (2, 38, 28, 0, 34, 7, 14, 1);
my $count = @numbers;
my $num;

print "@numbers\n";
while ( $count > 0 ) {
  for ($num = 0; $num < $count; $num++ ) {
    if ( $numbers[$num] > $numbers[$num+1] ) {
      @numbers = swapnums($num, @numbers);
    }
  }

  $count--;
}
print "\n@numbers\n";

sub swapnums {
  my ($ndx, @list) = @_;
  my $temp;

  $temp = $list[$ndx];
  $list[$ndx] = $list[$ndx+1];
  $list[$ndx+1] = $temp;

  return @list;
}






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

Date: Mon, 19 Apr 1999 14:54:25 -0600
From: Arne Jamtgaard <arnej@fc.hp.com>
Subject: Re: Perl Error Message???
Message-Id: <371B9801.12DB@fc.hp.com>

Ray A. Lopez wrote:

> The script (sorts a list of numbers) works fine, but I get an error
> message in my output which I don't seem to understand (or understand
> how to fix appropriately).  Any idea on what I am doing wrong?

This isn't meant to be harsh, but try reading the error message.

> 2 38 28 0 34 7 14 1
> Use of uninitialized value at .//sort.pl line 12 (#1)

Looks like the problem is on line 12 - let's look there...

> #########################################################

> #!/usr/local/bin/perl -w
> use diagnostics;
> use strict;

> my @numbers = (2, 38, 28, 0, 34, 7, 14, 1);
> my $count = @numbers;
> my $num;

> print "@numbers\n";
> while ( $count > 0 ) {
>   for ($num = 0; $num < $count; $num++ ) {
>     if ( $numbers[$num] > $numbers[$num+1] ) {

This is line 12.^^^^  When $num is pointing to the last element of the 
array, what element is $num+1 pointing to?

Options:  Stop the outer loop at $$count-1
          Use the perl sort 

HTH,

Arne


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

Date: 19 Apr 1999 20:55:44 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl pipe under OS/2 broken?
Message-Id: <7fg58g$7r6$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to J|rgen Ibelgaufts 
<ibelgaufts@gfc-net.de>],
who wrote in article <371B4FBA.E524165F@gfc-net.de>:
> unfortunately I have to migrate a Perl program which works well
> under Windows NT and Unix to OS/2. Here I find the stupid
> problem that piping the output of a command into perl does not
> work.

Time to look into the docs.

> The source code is as simple as this (and works fine under
> Windows NT):
> 
> 
>   $cmd = "dir | ";
> 
>   open ( F, $cmd);
>   while (<F>) {
>     print STDOUT "Pipe: $_";
>   }
> 
> Under Windows NT, it will print out the output of the dir
> command. 

This is a known flaw in WinNT port.

> Under OS/2 I first get the message SYS0002, The file cannot be
> found

Do you have dir.exe on your PATH?  If not

>       , and the header of the dir command, but no files. 

Apparently you are running 5.004_*, which had some bug.  In 5.005_*
you will get a correct answer: open() will fail.

If you want to ask shell to run 'dir' shell command, you need to do it
explicitly: 

  open F, 'cmd -c dir';

(as it is documented).

Ilya


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

Date: Mon, 19 Apr 1999 19:51:44 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Poss bug in CGI.pm, Multipart, eval() and die()
Message-Id: <371c8666.1661227789@news.ford.com>

Using Netscape Enterprise Server, Perl version 5.005-02, CGI.pm version
2.42. 

Submitting a form using the "MULTIPART/FORM-DATA" encoding seems to break
the die() mechanism.  

What we're doing: we're using eval{} to surround all of our CGI programs.
During execution, if an error is encountered we simply die() with an
appropriate message.  Control is sent back to the eval, we check $@, and
print an appropriate message.

When the MULTIPART/FORM-DATA encoding method is used, all of the die()
functions in our programs stop working.  The program execution stops at
the die() and control is transferred back to the eval{} which encloses it,
but $@ is never set.  The return value from the eval{} is undef.

When the form encoding isn't specified, everything works correctly.

Program control is clearly being interrupted with die(), $@ is never being
set.  Anyone run into this bug before?  Is there a fix/workaround?

Thanks



Stripped down sample which demonstrate the problem is included below.

--- Sample form -----
<HTML>
<FORM
ENCTYPE="MULTIPART/FORM-DATA"
ACTION=/valueweb/cgi-bin/testerr.cgi METHOD=POST>
<INPUT TYPE=SUBMIT VALUE="PUSH ME">
<input type=file name=file>
</FORM>
</HTML>


---- Sample CGI script ----
#!/bin/perl5.005-02

use CGI qw(:standard);

sub main {
        my $cgi=new CGI;

        print "Content-type: text/html\n\n";
        print "This is before the die.\n<BR>";
        die("This is an error message");   # Throw an error.
        print "Hello, World.";   # This line does not print.
}

my $retval=eval { main; };

print "The return value is $retval\n<BR>";

if ($@) {    # Is never "true" for multipart/form-data!!!! BUG!
        print "<HTML><BODY>This is the error: \"$@\"</BODY></HTML>"
}

-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Mon, 19 Apr 1999 20:14:33 GMT
From: jparker7345@my-dejanews.com
Subject: Problems installing perl module (DBI)
Message-Id: <7fg2r0$ubj$1@nnrp1.dejanews.com>

I'm trying to install the perl DBI module and am having difficulty setting my
compiler.  My original perl binary was compiled (on another machine) with cc.
 I have gcc available, however I have not been able to work around the
automatic assumption that I want to make DBI using the same compiler as perl
was.  I'm sure this is easy, but I can't find it in any documentation.	I'm
thinking I should be able to do something like

# perl Makefile.PL --cc=/usr/freeware/bin/gcc

 but of course this doesn't work.  Yes, I suppose I could recompile perl with
gcc (along with Apache, mysql and all the other tools I use to do my job), but
I'd really rather not if I don't have to.  Thanks.

John Parker

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 19 Apr 1999 14:17:33 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Random Integer creation
Message-Id: <m3btgkcqle.fsf@moiraine.dimensional.com>

Tim Connolly <kb8eht@access.mountain.net> writes:

> I'm not having much lunch getting only the integers from the output,
> any suggestions ?

Well, I had a turkey and ham sandwich for lunch, it certainly beat
the hell out of a plate of integers.  Maybe you could try that.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Mon, 19 Apr 1999 21:59:22 +0100
From: "Kram" <kram@techie.com>
Subject: Re: Running CGI scripts OFFLINE
Message-Id: <pLMS2.1409$_3.801@stones>

hi paul
a cheat? good way to setup perl is to install but use root dir c:\usr not
c:\perl
that way you get c:/usr/bin etc so sherbang #!/usr/bin/perl is left alone.
and i dont associate .pl ! makes it eaiser to edit them with "NOTEPAD"
that might upset some people.
or for local testing change sherbang to #!"c:/perl_dir/bin?"

HTH

kram

Paul Gregor <peej_79@yahoo.com> wrote in message
news:dmHS2.47$QO.1320@nswpull.telstra.net...
>
> Radiac <kenny@larkrise.force9.co.uk> wrote in message
> news:EebN2.1313$54.1191@wards...
> > I use tinyweb as my web server. it is literally tiny - less than 100k
> iirc.
> > I point that in the direction of a directory holding my website. in
there
> i
> > have a directory called cgi-bin. Having installed perl v5 and associated
> .pl
> > files with perl.exe, all i have to do is go to, for eg,
> > http://127.0.0.1/cgi-bin/script.pl in ie. very simple.
> >
> >
> I am running the same setup with TinyWeb and Perl v5. Every time I got to
> execute my pearl script I get I "document contains no data" error on the
> other PC on my 2 PC Win95 LAN. The script that I am using is to search a
> text file. I got it from http://www.technotrade.com/cgi/search.html
> Do I need to change the usr/local/bin line?, or doesn't that matter
because
> Perl v5 has associated with .pl extensions.
>
> Any help on this would be greatly appreciated
>
> Paul Gregor
>
>




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

Date: 19 Apr 1999 20:31:59 GMT
From: nospam+_no_Zs__9904@hpb13799z.zboi.hpz.com.invalid (Sylvan Butler)
Subject: Re: Scripting language with LFN support?
Message-Id: <slrn7hn4lv.ba.nospam+_no_Zs__9904@hpb13799z.zboi.hpz.com.invalid>

On Mon, 19 Apr 1999 08:39:05 +0000, Alexander Harth <harth@rz.uni-frankfurt.de> wrote:
>amacleod@altavista.net wrote:
>> Is there a scripting language in NT 
>> (akin to shell, batch, perl etc.) that
>> supports long file names?

>> I'm hoping to write platform independent 
>> install scripts that can manage files
>> on both NT and UNIXwith minimal change.

>I think perl is the best way to do it.

I'd probably pick perl as well, but my brother keeps raving about
python.  Both of those are available on Win32 and Unix platforms.
Perl is probably a bit more widespread default...

sdb
-- 
 | Sylvan Butler | Not speaking for Hewlett-Packard | sbutler-boi.hp.com |
 | Watch out for my e-mail address. Thank UCE.   #### change ^ to @ #### |
    They that can give up essential liberty to obtain a little temporary
    safety deserve neither liberty nor safety. --Benjamin Franklin, 1759
 "Don't Tread On Me!"


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

Date: 19 Apr 1999 13:26:48 PST
From: Ted Timmons <tedder@pacifier.com>
Subject: Solved (was Re: DateCalc not working properly)
Message-Id: <371b9188.0@news.pacifier.com>

Well, folks, I got my problems taken care of. Here's what I did:

* got rid of the symlinks (don't use them on Linux, I was told)
* removed the .pm's, rebuilt & installed DateCalc
* changed my code - I was using "Date::DateCalc", that's deprecated, I
needed "Date::Calc"
* found out that dates_difference doesn't exist, I need to use Delta_Days
instead.
* used my local manpages instead of the POD at perl.com that is out of
date (that solved the Date::Calc and Delta_Days problems)

No, I only have one version (and one installation) of perl, for those that
are wondering. :^)

Ted Timmons <tedder@pacifier.com> wrote:
> I've been using DateCalc for over a year now for various admin tasks, such
> as automatic reminders when our users passwords are about to expire - so
> they don't bug us after they expire :^)

> But now I've got it installed on a Caldera 1.3 box - that's a Linux
> flavor. First, it didn't install to a path in the @INC - it installed to
> /usr/lib/perl5/site-perl/Date/Calc.pm instead of
> /usr/lib/perl5/site_perl/5.005/i586-linux/Date/Calc.pm. So I put a symlink
> in the latter location for it. Now the "use" line works, and all the
> functions that I call work, but dates_difference doesn't! Why?!

> FWIW, "make test" was successful when I ran it.

> Undefined subroutine &Date::DateCalc::dates_difference called at
> ./check_expire.pl line 94.    

> Again, thanks for your help.


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

Date: Mon, 19 Apr 1999 13:24:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Splitting length instead of delimiting character?
Message-Id: <MPG.118530d134e381119898de@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <371B6FE3.2DBF6BF9@mail.cor.epa.gov> on Mon, 19 Apr 1999 
11:03:15 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
 ...
> A regex solution is usually a lot slower.  But not to worry.
> Larry R will Benchmark it and show you a better way.  :-)

OK;  I'd hate to disappoint you!  This was good practice.

I posted the following on Saturday, but it seems never to have made it 
out of our newsfeed.  I'll stand by it as the Best solution (compared to 
substr() and regex), for the reasons you and others have given 
(concision and maintainability, and BTW speed).

Here is my entire undistributed response ('An' changed in the benchmark 
to 'an' for consistency with the other solutions):

+ perldoc -f unpack
+ 
+ A format string like 'A7 A4 A4 A4 ...' should do what you want.

#!/usr/local/bin/perl -w
use strict;
use Benchmark;

my $x = '1999-01   6   4   2   1   7       5   3';
my $r = '(.{7})' . '(.{4})' x 8;
my @s = (7, (4) x 8);
my $u = 'a7' . 'a4' x 8;

timethese(1 << (shift || 0), {
  Regex  => sub { my @a = $x =~ /$r/o },
  Substr => sub { my $i = 0;
    my @a = map substr($x, ($i += $_) - $_, $_), @s },
  Unpack => sub { my @a = unpack $u, $x },
});

__END__

Benchmark: timing 16384 iterations of Regex, Substr, Unpack...
     Regex:  1 wallclock secs ( 1.41 usr +  0.00 sys =  1.41 CPU)
    Substr:  2 wallclock secs ( 2.25 usr +  0.00 sys =  2.25 CPU)
    Unpack:  2 wallclock secs ( 1.28 usr +  0.00 sys =  1.28 CPU)

My first attempts at substr() were twice as slow!  Precalculating an 
array of arrays of offsets and widths doesn't seem to make it faster, 
and is yucky IMO.  Any better (i.e., measured to be faster) ideas?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 19 Apr 1999 20:10:21 +0100
From: "Wayne Keenan" <tripix@tdi-net.freeserve.co.uk>
Subject: Stop posting twice!
Message-Id: <7ffvis$n6g$1@news8.svr.pol.co.uk>

ARRGGHH!
If your mailer keeps quite after the first post, then so should you.
You know who you are!




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

Date: 19 Apr 1999 13:30:26 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Stop posting twice!
Message-Id: <371b8452@cs.colorado.edu>

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

In comp.lang.perl.misc, 
    "Wayne Keenan" <tripix@tdi-net.freeserve.co.uk> writes:
:If your mailer keeps quite after the first post, then so should you.
:You know who you are!

First, shoot all the script-kiddies' stupid GUI all-in-one stupertools.
Make them use readnews for a while, and maybe after a few months
we'll give them a nice SUI instead.  :-)

--tom
-- 
 "If you steal from 1 you are plagarizing If you steal from 10 you
 are doing research If you steal from 100 you are an expert." -B Delaney


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

Date: Mon, 19 Apr 1999 19:49:06 GMT
From: matt@matt.com
Subject: Re: Stop posting twice!
Message-Id: <371b8879.513832093@news.infonent.com>

On Mon, 19 Apr 1999 20:10:21 +0100, "Wayne Keenan"
<tripix@tdi-net.freeserve.co.uk> wrote:

>ARRGGHH!
>If your mailer keeps quite after the first post, then so should you.
>You know who you are!
>
>

Sorry

My news server somehow managed to cache my post on a full disk spool.

Once I relieved it of a massive log file, it sent both off.

--matt hempel


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

Date: Mon, 19 Apr 1999 15:10:00 -0400
From: Tony Demark <tpost@intelihealth.com>
Subject: tie'd hashes
Message-Id: <371B7F88.D6840EBF@intelihealth.com>

I have two programs:

	(1) write.pl ties a hash to a file (using DB_File) and adds/deletes
keys from the hash
	(2) read.pl ties to the same hash and will read values from the hash

My observations show that the db file only seems to get updated on disk
when I untie the hash in write.pl.  Each time I modify the hash I have
to untie and tie again for the file to show the changes. Conversely,
each time I read from the hash I have to tie/untie to get the most
recent version of the file. Is this correct?

If so, is there a way around it?  That is, with allowance for sync's to
disk, is there a way that modifying a tied hash would cause the file to
be changed on disk without tie/untie?

TIA,
- Tony


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

Date: 19 Apr 1999 14:37:52 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Tool Reuse Considered Beneficial (was: New FAQ: How can I read in an entire file all at once?)
Message-Id: <m3u2ucbb33.fsf@moiraine.dimensional.com>

[posted and mailed]

Tom Christiansen <tchrist@mox.perl.com> writes:

> In comp.lang.perl.misc, 
>     Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
>
> :In real programs I _never_ shell out.
> 
> That's absolutely ridiculous.  I challenge you to implement the following
> operations without calling another program.  
<snip list of things that require shelling out>

I wouldn't use perl to do those things any more than I'd use C++ or
assembler to do those things.  When I need to write a shell script, I
use sh.  When I need to write a program, I usually use perl. :-)

> Use the commands from the toolkit.  That's what it's there for.  

Unix is a twisty maze of standards, all different.

If you want reliable code that can be moved from environment to
environment then you _shouldn't_ use the toolkit.  

Period.  Ever.  

You have no way of knowing exactly how the executable file
`cat' will act on any arbitrary system.  For all you know, the
user has a veterinary diagnostic program for felines under
that name.  Hope it does what you expect.

Besides, I don't have time to chase bugs in 15 million different
implementations of cat(1) when

    while(<>) { do_stuff($_) }>

works more reliably.

> Do *not* reinvent the wheel.

I find this rather amusing coming from the man who is busy
reinventing _all_ of the wheels in the unix toolbox.

> F u cn rd ths u cnt spl wrth a dm!

My spelling is certainly worth at least a dime. :-)

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Mon, 19 Apr 1999 19:17:06 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Top 10 newbie errors?
Message-Id: <371c7a70.1658166297@news.ford.com>

On Mon, 19 Apr 1999 10:40:22 -0700, Jerome O'Neil <jeromeo@atrieva.com>
wrote:

>John Callender wrote:
>> 
>> I'm putting together a list of the top 10 ways that people new to both
>> Perl and programming screw things up. (Screw things up in their
>> scripts, I mean. Thus, "Posting CGI questions to c.l.p.m." or "Asking
>> for advice without posting the suspect code" would not qualify.)
>
>1. Not using warnings and strict( #/bin/perl -w and use strict;).

Hmm... 

I (respectfully) disagree on adding "use strict" pragma to a list of
things that newbies fail do to that "screw[s] things up".  As for "-w", I
agree wholeheartedly.

For true newbies "use strict" only seems to get in the way of quickly
writing short, effective scripts that Do Something Useful.  "use strict"
makes a B&D Language out of an easy-to-hack glue language.  Once someone
is using modules, lots of functions, structures, and other more complex
language structures...THEN I think it's time for "use strict".

By then, they're not exactly perl/programming newbies.

I keep thinking about the Preface to the Camel, and its comparison of Perl
to a Human Language.  (Which is frequently overlooked in this group!)
Without permission:

	Most important, you don't have to know everything there is 
	to know about Perl before you can write useful programs.  You 
	can learn Perl "small end first".  You can program in Perl
	Baby-Talk, and we promise not to laugh.  Or more precisely, we
	promise not to laugh any more than we'd giggle at a child's
	creative way of putting things.  Many of the ideas in Perl
	are borrowed from natural language, and one of the best ideas
	is that it's okay to use a subset of the language as long as
	you get your point across.  Any level of language proficiency
	is acceptable in Perl culture.  We won't send the language
	police after you. A Perl script is "correct" if it gets the
	job done before the boss fires you.

Turning on "use strict" (especially vars & subs) pretty much makes
speaking Perl baby-talk impossible.  It's like a 2-year old speaking
baby-talk being constantly interrupted by an English PhD. correcting his
grammar and pronunciation.

-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Mon, 19 Apr 1999 13:53:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Top 10 newbie errors?
Message-Id: <MPG.118537c01ad60f8f9898e0@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <371c7a70.1658166297@news.ford.com> on Mon, 19 Apr 1999 
19:17:06 GMT, Clinton Pierce <cpierce1@ford.com> says...
+ On Mon, 19 Apr 1999 10:40:22 -0700, Jerome O'Neil 
<jeromeo@atrieva.com>
+ wrote:
+ >John Callender wrote:
+ >> I'm putting together a list of the top 10 ways that people new to 
both
+ >> Perl and programming screw things up. (Screw things up in their
+ >> scripts, I mean. Thus, "Posting CGI questions to c.l.p.m." or 
"Asking
+ >> for advice without posting the suspect code" would not qualify.)
+ >
+ >1. Not using warnings and strict( #/bin/perl -w and use strict;).
+ 
+ Hmm... 
+ 
+ I (respectfully) disagree on adding "use strict" pragma to a list of
+ things that newbies fail do to that "screw[s] things up".  As for
+ "-w", I agree wholeheartedly.
+ 
+ For true newbies "use strict" only seems to get in the way of quickly
+ writing short, effective scripts that Do Something Useful.  "use
+ strict" makes a B&D Language out of an easy-to-hack glue language.
+ Once someone
+ is using modules, lots of functions, structures, and other more
+ complex language structures...THEN I think it's time for "use strict".
 ...
+ Turning on "use strict" (especially vars & subs) pretty much makes
+ speaking Perl baby-talk impossible.  It's like a 2-year old speaking
+ baby-talk being constantly interrupted by an English PhD. correcting
+ his grammar and pronunciation.

If and only if the two-year-old can correctly communicate its intentions 
*to a compiler*, not to a tolerant human with intuitive pattern-
recognition skills.

I (respectfully) disagree entirely with what you say.  The effective 
communication rate with 'use strict;' must be immensely higher *for a 
beginner* than without it.

Consider 'use strict;' as training wheels.  Experts might get away 
without them; beginners can't.  The size of the program, like the 
distance the bicycle travels, is irrelevant.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 19 Apr 1999 16:03:32 -0400
From: PropART <propart@mediaone.net>
Subject: Re: Why does Perl do this? Not because of this
Message-Id: <371B8C14.A573CB38@mediaone.net>



George wrote:

>
> When you double-quote it, it tries to print an @ sign instead of printing
> each element of the array.  This means when you're writing an HTML page and
> you do a mailto, you need to write "mailto:joebob\@wherever.com" - but it
> doesn't look for the array whatever, do you follow?  If you wrote "print
> @whatever", then it WOULD look for that array and print all its values.
>
> So if you want to print the array, using no quotes or single quotes i think
> (') and if you want to actually print an @ sign, do whatever and use an
> escape \.
>
> Hope I'm not wrong, and Cheers,
> ^^^^^^^^^^^^^^^^

> George
>
> -

You are...



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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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