[12816] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 226 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 22 12:25:34 1999

Date: Thu, 22 Jul 1999 09:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 22 Jul 1999     Volume: 9 Number: 226

Today's topics:
        Aliasing long expresions <sfedi@dc.uba.ar>
    Re: Array problem <swiftkid@bigfoot.com>
    Re: authentication and getting  HTTP_REMOTE_USER <flavell@mail.cern.ch>
        Better Question re:File Parsing Difficulty <lojeck@mizar.usc.edu>
        Can't modify array deref in addition <tomas.karlsson@andover.net>
    Re: Compressed data-resources - like java-jars??? <swiftkid@bigfoot.com>
    Re: doing an ls in PERL (globbing) <swiftkid@bigfoot.com>
    Re: Executing system commands <swiftkid@bigfoot.com>
    Re: gethostbyname on NT <gehring@politik.uni-mainz.de>
    Re: getting the decimal portion of a floating point num <bivey@teamdev.com>
    Re: Help me ..; databases ... <mlopresti@bigfoot.com>
    Re: Help me ..; databases ... <cyberjeff@sprintmail.com>
    Re: Help me ..; databases ... <swiftkid@bigfoot.com>
    Re: Help requested with my "paging" script. <portboy@home.com>
        How can I check if someone is logged in? <garym@soi.city.ac.uk>
    Re: How can I check if someone is logged in? (Andreas Fehr)
    Re: How can I check if someone is logged in? <vonhubenu@post.ch>
    Re: HTML on NT; how do I add docs? <mlopresti@bigfoot.com>
    Re: macros in perl? (Sean McAfee)
        output of print map ( { unless (/^#/) {} } ("#") ); (Michael Wang)
    Re: Perl CGI vs VB ASP <mlopresti@bigfoot.com>
    Re: Perl CGI vs VB ASP <upsetter@ziplink.net>
        Perl Math Calculation vs. FORTRAN Calculations <scott.dummer@noaa.gov>
        Perl Math Calculation vs. FORTRAN Calculations <scott.dummer@noaa.gov>
        Perl Math Calculation vs. FORTRAN Calculations <scott.dummer@noaa.gov>
    Re: Perl Math Calculation vs. FORTRAN Calculations (Larry Rosler)
        perl vs. FORTRAN Caculations <sdd@ls1-krf.krf.noaa.gov>
    Re: perl vs. FORTRAN Caculations (Larry Rosler)
    Re: PGP and Mail <upsetter@ziplink.net>
    Re: problem with <input type="image"..... <moreau@objectif.fr>
        reading files on IIS4.0 <zotje@my-deja.com>
    Re: regular Expression <bivey@teamdev.com>
    Re: RFC 1867, file upload skao@my-deja.com
    Re: RFC 1867, file upload <gellyfish@gellyfish.com>
    Re: SSI in Perl CGI output <swiftkid@bigfoot.com>
    Re: Stipping HTML and loosing memory (Flint Slacker)
    Re: Stipping HTML and loosing memory <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Thu, 22 Jul 1999 15:13:15 GMT
From: Sergio Bruno Fedi de Oro <sfedi@dc.uba.ar>
Subject: Aliasing long expresions
Message-Id: <7n7ce0$tpt$1@nnrp1.deja.com>

I want to alias a long dereferencing expresion, but it doesn't work...

This sub receives a reference to a hash or references to arrays [of
scalars].
I want to iterate over the array's elements without using the long
dereference expresion, that's why I want to alias it (and to make it
more mantainable too).

This function is exported (in case this is an issue)

package ConfigIO;
use strict;

sub purgar_config ($) {
	my($ref_paquetes) = shift;
	my($paquete_actual);
	my($archivo_actual);
	my($i);
	local(*files);

	foreach $paquete_actual ( keys( %$ref_paquetes ) ) {
		print "paquete: $paquete_actual\n";
		$i = 0;

		# Here's where I alias the array
		*files = \@{$$ref_paquetes{$paquete_actual}};

#	Instead of:
#		foreach $archivo_actual ( @{$$ref_paquetes{$paquete_actual}} ) {
#	I want to use:
		foreach $archivo_actual ( @files ) {
			if (-r $archivo_actual) {
				print "Se puede backupear: $archivo_actual\n";
			} else {
				print "No se puede acce


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 22 Jul 1999 19:00:45 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Array problem
Message-Id: <7n8bgg$eva9@news.cyber.net.pk>

Jimtaylor5 <jimtaylor5@aol.com> wrote in message
news:19990722080342.03340.00000724@ng-fx1.aol.com...
: >
: >@items = split '\|' , $line;
: >
: >foreach ( @items ) ... blah
: >
: >$total = @items; # count
: >
: >etc
:
: But what is ... blah, and I still don't understand how I would get those
items
: from the list into my program without knowing how many there are. maybe
I'm
: missing something..

There are many flowers on the read, you walk through and collect flowers....
its a long read and there are many flowers, you don't know how many they
are but you collected them all, and you can count them too, once you have
all of them.

Perl walks through the string and splits out all ... blah ... and puts it in
an array (just like basket when collecting flowers) and you can easily
count them through perl unlike counting flowers, which is time consuming :)


Hey, I don't speak english normally and also I am not good at philosophy
are what you might call that... so don't rag if I have a very bad example :P




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

Date: Thu, 22 Jul 1999 17:30:21 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: authentication and getting  HTTP_REMOTE_USER
Message-Id: <Pine.HPP.3.95a.990722172130.23473F-100000@hpplus03.cern.ch>

On Thu, 22 Jul 1999, Jon Ratcliffe wrote:

> I have 'secure' folder setup on my apache (unix) server and am using a
> .htaccess file to force users to enter a username and password. The
> passwords are stored in a .htpasswd file. If the user enters a correct
> username and password. they continue into the site.

This doesn't seem to be a Perl language question.

> I would like to 'capture' the username that the user enters into the dialog
> box 

You get it, if your CGI script is under password control; otherwise you
don't. 

> I have tried to get this information (using the CGI module) as follows:
> 
> use CGI;
> $query = new CGI;
> $username= $query->remote_user();
> 
> This just seems to return an empty string.

Then it's a fair bet that your script isn't under password control.

Common mistake: you put an HTML page under password control, but you
submit it to a script that isn't.  Doesn't work.

That's my guess, anyhow.  This kind of question would be more at home on
the comp.infosystems.www.authoring.cgi group, I'd say. 

good luck



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

Date: Thu, 22 Jul 1999 08:43:45 -0700
From: Brian Lojeck <lojeck@mizar.usc.edu>
Subject: Better Question re:File Parsing Difficulty
Message-Id: <Pine.GSO.4.10.9907220831050.14463-100000@mizar.usc.edu>


I can't figure out why this code prints the first "print" but not the
second. a representative (short) of the file is copied to the bottom of
the message.

I have determined the code is reading the lines in one at a time (I though
perhaps it was bad carriage returns or similar), but for some reason it
doesnt' like to match. ;-(

thanks again for your assistance...
(ps: just for the record, I DO NOT use Hotdog to design web pages. ;-)

-------------- code starts here -----------------

         #just a simple test to make sure my code isnt hinky
		if ('<MarkHere>' =~ /MarkHere/) {
		   print ('<br><br><br>This Will Print<br><br><br>');
		}
		
	 #now the check of $_
                open(HPe, "$filename") 
                while (<HPe>){
		  if (/MarkHere/){
		    print ('<br> This Will Not Print <br>');
		    }
		}  

----------- code ends, file begins --------------
<HTML>
<HEAD>
<TITLE> Participant Directory </TITLE>
<META NAME="generator" CONTENT="Sausage Software HotDog Professional 5">
</HEAD>
<BODY text="#000000" bgcolor="#FFFFFF" link="#1834A0" VLINK="#D89830"
ALINK="#B06480">
<Center><FONT FACE="Trebuchet MS" Size="+3">Participant
Directory</center><BR>
<font size="+1">
<MarkHere>
more data goes here....


Brian Lojeck, lojeck@mizar.usc.edu 
Learn as if you will live forever; live as if you will die tomorrow.




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

Date: Thu, 22 Jul 1999 11:47:58 -0400
From: Tomas Karlsson <tomas.karlsson@andover.net>
Subject: Can't modify array deref in addition
Message-Id: <37973D2E.DEB2FBEF@andover.net>

Hi,

A short question about references. I would like to make changes to 3
elements at the same time, but Perl doesn't like my code. I have:

   @{$totals{$dateref}}  += @{$table{$site}{$dateref}} foreach my
$dateref (keys %{$table{$site}});

and I get the error message: "Can't modify array deref in addition".  Ok
so that clearly doesn't work. The only solution that I came up with is

   $totals{$dateref}->[0] += $table{$site}{$dateref}->[0];
   $totals{$dateref}->[1] += $table{$site}{$dateref}->[1];
   $totals{$dateref}->[2] += $table{$site}{$dateref}->[2];

It works, but with more elements it will become cumbersome. Could anyone
show me a neater way to solve my problem? Thanks in advance!

Tomas Karlsson








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

Date: Thu, 22 Jul 1999 19:10:27 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Compressed data-resources - like java-jars???
Message-Id: <7n8c2l$eva12@news.cyber.net.pk>

: hi,
:
: I was wondering if it was possible to store files, like plain-text, html
: etc. which would benefit from compression, in "containers", like
: java-jars. they`re compressed zip-files, renamed to jar to which the
: user only has to define an interface and use the contents of the
: compressed archive like it was a plain folder. Could something like this
: be done with Gzip og Info-Zip, perhaps using a module??

Look at CPAN

http://www.cpan.org/modules/by-module/Compress/
http://www.cpan.org/modules/by-module/Archive/

:
: Thomas Weholt




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

Date: Thu, 22 Jul 1999 19:15:38 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: doing an ls in PERL (globbing)
Message-Id: <7n8ccb$g741@news.cyber.net.pk>

: I'm trying to do the UNIX command - ls - in PERL script
: what I orginally was doing was globbing by assigning a directory to an
: array :
:
:
: @directory = </some/path/name/>

@directory = </some/path/name/*>;

:
: #Then I walked thru the array:
: foreach $i (@directory){
: #here is where my problem is:
: @directory2 = <$i>;

@directory2 = <$i/*>;

You better check if its a dir or not and then

Like this:

foreach ( @directory )
{
    @directory2 = <$i/*> if -d;





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

Date: Thu, 22 Jul 1999 19:07:58 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Executing system commands
Message-Id: <7n8bu0$eva11@news.cyber.net.pk>

: Good day,
:
: How can I execute an O/S command with perl?

system(), qx() (backticks), exec()

:
: Ie.: Call a Unix script (c Shell) that generates an output into a file so
: the Perl script would then access.

You don't need to redirect it to file, Perl solves that problem for you :)

$output = `ls -lista`;

And you get the output which was supposed to by on terminal in your
variable ($output)

Hurray for: qw/Perl Larry/;




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

Date: Thu, 22 Jul 1999 16:11:09 +0200
From: "Uwe W. Gehring" <gehring@politik.uni-mainz.de>
To: HC <carvdawg@patriot.net>
Subject: Re: gethostbyname on NT
Message-Id: <3797267D.2A6FAB49@politik.uni-mainz.de>



HC schrieb:
> 
> try this:
> 

> try this:
> 
[stuff deleted]

Hi,

thanks a lot for commenting on my little problem. I tried your perl
script without change. The local host is bienlein.politik.uni-mainz.de
with 134.93.160.187 (NT) and the target is ipofa.politik.uni-mainz.de
with 134.93.160.129 (Linux). See what happend:

Running "perl name.pl 134.93.160.129"

Output:

Using inet_aton() to determine IP address of target host...
IP:  134.93.160.129

Using Sys::hostname to determine IP address of localhost...
IP:  134.93.160.187

Using gethostbyaddr() to determine hostname...
Hostname:	ipofa.Politik.Uni-Mainz.DE

OK, so far. Now running "perl name.pl ipofa.politik.uni-mainz.de"

Output:

Using inet_aton() to determine IP address of target host...
IP:  134.93.160.128

Using Sys::hostname to determine IP address of localhost...
IP:  134.93.160.187

Using gethostbyaddr() to determine hostname...
Hostname:	hp4.politik.uni-mainz.de

Oops. Not right. hp4 is our printer who has the 134.93.160.128...

Might that be a problem with the DNS?

-- 

Sincerely
Uwe W. Gehring

Research Assistant
****************************************************
University of Mainz - Institute of Political Science
Saarstr. 21          55099 Mainz             Germany
Tel.: +49 6131 39-5485         Fax: +49 6131 39-2996
E-Mail:                 gehring@politik.uni-mainz.de
WWW:        http://www.politik.uni-mainz.de/~gehring
****************************************************


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

Date: 22 Jul 1999 14:59:35 GMT
From: "William" <bivey@teamdev.com>
Subject: Re: getting the decimal portion of a floating point number
Message-Id: <01bed452$e8c53e40$583c08cf@bill.jump.net>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in article
<7n5sd6$tdo$1@lublin.zrz.tu-berlin.de>...
> William <bivey@teamdev.com> wrote in comp.lang.perl.misc:
> >
> >Because on my system that operation on that number yields
> >	0.678900000000795
> >which isn't exactly what the original poster had in mind,
> >I'm sure. 
> 
> Probably not, but it is what they *should* have had in mind.  If
> the extra places are unwanted, use sprintf and friends.

You mean they should expect that
	12345.6789 - int(12345.6789) == 0.678900000000795

On what planet? As far as sprintf goes, it will work, but I
suspect its overhead is overkill for such a simple problem.
You're suggesting that sprintf( "%.4f", $value-int($value) )
is an efficient solution compared to $value =~ m{(\.\d)}?


> >           (I tend to avoid math function solutions to
> >floating point problems if there's a string solution because
> >of the possibility of results like the one above.) 
> 
> ...thereby introducing the possibility that the computer and
> you disagree about what a particular number means.  I think
> manipulating numbers as strings is in general not a good idea,
[...]

So why did you suggest sprintf above? It does treat the number as
a string though it hides some of the gritty details. And it's not
a matter of disagreement, it's a matter of the computer just being
plain wrong, knowing when it's likely to be wrong, and arranging
things so it can't be wrong. (I figured that one out 26 years
ago on a machine about as bright as a pocket calculator and
computers haven't gotten a lot more foolproof since then,
they just screw up with greater precision :-)

-Wm



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

Date: Thu, 22 Jul 1999 10:11:26 -0400
From: matt <mlopresti@bigfoot.com>
Subject: Re: Help me ..; databases ...
Message-Id: <3797268E.282B3394@bigfoot.com>

What are you trying to do? There are alot of ways to use Perl with dbs. Web,
reports, etc.


danny wrote:

> hi,
>
> my server supports this
>
> Windows NT Server
>                                                        Database and CGI
>
> ColdFusion 4 Enterprise
>
> Chili!ASP
>                                                                  PhP3
>                                                                  Perl 5,
> Visual Basic & C++ CGI
>                                                                  ODBC
> Support
>
> whats the best way to use a database in perl ?
>
> (i used dbmopen, but this is garbage!)
>
> sincerly,
>
> danny






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

Date: Thu, 22 Jul 1999 10:26:06 -0400
From: Jeff Thies <cyberjeff@sprintmail.com>
Subject: Re: Help me ..; databases ...
Message-Id: <379729FE.AB7A6B66@sprintmail.com>

> Windows NT Server
>                                                        Database and CGI
> 
> ColdFusion 4 Enterprise
> 
> Chili!ASP
>                                                                 PhP3
>                                                                  Perl 5,
> Visual Basic & C++ CGI
>                                                                  ODBC
> Support
> 
> whats the best way to use a database in perl ?

DBI::DBD and DBD::ODBC  

Check the DBI man page... You might just want to run CF instead, easy
but not as flexible.

Jeff



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

Date: Thu, 22 Jul 1999 19:13:26 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Help me ..; databases ...
Message-Id: <7n8c89$eva13@news.cyber.net.pk>

: my server supports this
:
: Windows NT Server

get Apache! :P

:                                                                  Perl 5,
: Visual Basic & C++ CGI
:                                                                  ODBC
: Support
:
: whats the best way to use a database in perl ?
:
: (i used dbmopen, but this is garbage!)

you are right! its deprecated

use tie() with DB_File

or DBI with a nice SQL server (i prefer MySQL) (you can
use ODBC with Win32::ODBC i guess)





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

Date: Thu, 22 Jul 1999 15:58:53 GMT
From: Mitch <portboy@home.com>
Subject: Re: Help requested with my "paging" script.
Message-Id: <3796CFC2.421D2840@home.com>

I've gotten help from JS, however, I've been unable to get the script to
work that he submitted to me.  Well, let me put it this way, maybe the
script works and I'm just doing something wrong.  Below is a copy of the
script that JS submitted to me.  When I run the script with a 'cat foofile |

perl5 page.pl' everything just seem to scroll away.  I can't seem to figure
out why this is happening.  I've asked JS, but haven't gotten any response.
Can someone show me or tell me how to make this run the way i want?

THANKS

#!/usr/bin/perl5

require Term::Screen;

my $terminal = new Term::Screen;


$lines = $terminal->{ROWS};

$terminal->clrscr();

while(<>)
{
  chomp;
  $terminal->at($done,0)->puts($_);

  if(++$done == ($lines-1))
   {

     $terminal->at($lines,0)->reverse()->puts("--More--")->normal();

     my $blah = $terminal->getch();

     $done = 0;

     $terminal->clrscr();
   }
}
$terminal->at($lines,0)->reverse()->puts("--Done--")->normal();
my $blah = $terminal->getch();
$terminal->clrscr();





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

Date: Thu, 22 Jul 1999 15:18:54 +0100
From: Gary Mullen <garym@soi.city.ac.uk>
Subject: How can I check if someone is logged in?
Message-Id: <3797284E.EFFFDE3B@soi.city.ac.uk>

Hi,

Does anyone know a way I can check if someone is logged on to an NT
workstation?

I want to run a process only when no-one is logged on to the
workstation. I've already written something that checks to see if a user
drive is mapped, it seems to work but surely there must be a better way
of doing it. Any ideas?

Thanks

Gary

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

Gary Mullen   http://www.soi.city.ac.uk/~garym
Technical Support Group
School Of Informatics  E-mail: garym@soi.city.ac.uk
City University



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

Date: Thu, 22 Jul 1999 14:37:03 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: How can I check if someone is logged in?
Message-Id: <37972ad9.33002465@news.uniplus.ch>

On Thu, 22 Jul 1999 15:18:54 +0100, Gary Mullen <garym@soi.city.ac.uk>
wrote:

>Does anyone know a way I can check if someone is logged on to an NT
>workstation?
>

Check on http://www.roth.net/perl/

Andreas


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

Date: Thu, 22 Jul 1999 16:42:38 +0200
From: Urs Vonhuben <vonhubenu@post.ch>
Subject: Re: How can I check if someone is logged in?
Message-Id: <37972DDE.19AEBDD7@post.ch>

Gary Mullen schrieb:
> 
> Hi,
> 
> Does anyone know a way I can check if someone is logged on to an NT
> workstation?

nbtstat -n gives you (amongst machine name and nt-domain)
the user name of a logged in user.

Urs from Swizzy


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

Date: Thu, 22 Jul 1999 10:08:21 -0400
From: matt <mlopresti@bigfoot.com>
Subject: Re: HTML on NT; how do I add docs?
Message-Id: <379725D5.DC8C6DA4@bigfoot.com>

point your browser to read the new .html file. Is this what you're
asking?

kiansp@my-deja.com wrote:

> I have installed AvticePerl "version 5.005_03 built for
> MSWin32-x86-object", build 518.
> With this comes documentation in HTML format.
> Now I want to have a couple of HTML files added to the "perltoc.html"
> file. This is additional info for a couple of modules.
> I created a new folder under "C:\Perl\html\lib" and dropped the
> HTML files into the folder.
>
> How do I incorporate new html files into the TOC?
>
> The PPM does this during an install, how is the documentation
> maintained?
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.






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

Date: Thu, 22 Jul 1999 14:31:08 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: macros in perl?
Message-Id: <MWFl3.1873$nB.231406@news.itd.umich.edu>

In article <7n521o$3a5$1@nnrp1.deja.com>,  <mda@discerning.com> wrote:
>How does one write a "macro" in perl -- a function whose
>arguments are not evaluated before invoking the caller.

When you think "deferred execution", think "eval".

>This would be useful for a debug/trace function (the only
>case i use macros in C):
>  debuglog "something expensive: ", expensive();
>so i don't have to sprinkle "if $debug_on" everywhere, nor
>worry about expensive() being called needlessly.

sub debuglog {
    return unless $debug_on;
    my ($str, $func) = @_;
    print STDERR $str, eval $func, "\n";
}

debuglog "something expensive: ", "expensive()";

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: 22 Jul 1999 14:40:07 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: output of print map ( { unless (/^#/) {} } ("#") );
Message-Id: <7n7ag7$5re$1@news.ml.com>

What should be the output of the following?

(1) map ( { unless (/^#/) {} } ("#") );
(2) print map ( { if (/^#/) {} } ("#") );
(3) print map ( { if ( !/^#/) {} } ("#") );

And why? Thanks. 

It is my opinion that neither of the 3 above should produce ANYTHING.
but (1) produce "1" which I do not know why. How can I prevent it
from produce this unwanted "1". Thanks again. 
-- 
Michael Wang
http://www.mindspring.com/~mwang


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

Date: Thu, 22 Jul 1999 10:16:15 -0400
From: matt <mlopresti@bigfoot.com>
Subject: Re: Perl CGI vs VB ASP
Message-Id: <379727AF.ABA0A758@bigfoot.com>

Reliablity!!!!!! Learning curve(You know it already)

Eisen Chao wrote:

> Hi All:
>
> I'm familiar with using Perl within CGI,
> but not with VB & ASP.
>
> What are the advantages of the Perl/CGI
> combination over using the Micro$oft
> product ?
>
> We are going over to an M$ Web Server and
> I have to justify the further use of perl.
>
> Thanks in Advance,
>
> Eisen






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

Date: Thu, 22 Jul 1999 15:35:00 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Perl CGI vs VB ASP
Message-Id: <ESGl3.882$ui4.277838@news.shore.net>

matt <mlopresti@bigfoot.com> wrote:
: Reliablity!!!!!! Learning curve(You know it already)

Well, except that the learning curve for VBScript isn't that steep,
especially if you know a language like Perl already.

--Art


-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Thu, 22 Jul 1999 08:51:43 -0500
From: Scott Dummer <scott.dummer@noaa.gov>
Subject: Perl Math Calculation vs. FORTRAN Calculations
Message-Id: <379721EE.C40937D1@noaa.gov>

I have wrote a series of equations to calculate something (like the
distance on an oblate spheroid "earth") in FORTRAN and perl.  Does
anybody know why their answers differ slightly?  I would tend to believe
the FORTRAN calculation since one of it's strengths is intensive
accurate mathematical number crunching.  The FORTRAN program is using
double precession (16 decimal places).  The perl to the best of my
knowledge is using 16 decimal places as well, although I am currently
not using the perl math module, as I do not know what I would gain with
it.

I have a hunch that the rounding techniques employed by each are
slightly different.

Any thoughts are very much welcome.



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

Date: Thu, 22 Jul 1999 08:53:21 -0500
From: Scott Dummer <scott.dummer@noaa.gov>
Subject: Perl Math Calculation vs. FORTRAN Calculations
Message-Id: <37972250.425697FC@noaa.gov>

I have wrote a series of equations to calculate something (like the
distance on an oblate spheroid "earth") in FORTRAN and perl.  Does
anybody know why their answers differ slightly?  I would tend to believe
the FORTRAN calculation since one of it's strengths is intensive
accurate mathematical number crunching.  The FORTRAN program is using
double precession (16 decimal places).  The perl to the best of my
knowledge is using 16 decimal places as well, although I am currently
not using the perl math module, as I do not know what I would gain with
it.

I have a hunch that the rounding techniques employed by each are
slightly different.

Any thoughts are very much welcome.



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

Date: Thu, 22 Jul 1999 08:59:11 -0500
From: Scott Dummer <scott.dummer@noaa.gov>
Subject: Perl Math Calculation vs. FORTRAN Calculations
Message-Id: <379723AE.FA4FF740@noaa.gov>

I have wrote a series of equations to calculate something (like the
distance on an oblate spheroid "earth") in FORTRAN and perl.  Does
anybody know why their answers differ slightly?  I would tend to believe
the FORTRAN calculation since one of it's strengths is intensive
accurate mathematical number crunching.  The FORTRAN program is using
double precession (16 decimal places).  The perl to the best of my
knowledge is using 16 decimal places as well, although I am currently
not using the perl math module, as I do not know what I would gain with
it.

I have a hunch that the rounding techniques employed by each are
slightly different.

Any thoughts are very much welcome.



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

Date: Thu, 22 Jul 1999 08:25:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Math Calculation vs. FORTRAN Calculations
Message-Id: <MPG.1200d7a51fcf3577989d19@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <37972250.425697FC@noaa.gov> on Thu, 22 Jul 1999 08:53:21 -
0500, Scott Dummer <scott.dummer@noaa.gov> says...
> I have wrote a series of equations to calculate something (like the
> distance on an oblate spheroid "earth") in FORTRAN and perl.  Does
> anybody know why their answers differ slightly?  I would tend to believe
> the FORTRAN calculation since one of it's strengths is intensive
> accurate mathematical number crunching.  The FORTRAN program is using
> double precession (16 decimal places).  The perl to the best of my
> knowledge is using 16 decimal places as well, although I am currently
> not using the perl math module, as I do not know what I would gain with
> it.
> 
> I have a hunch that the rounding techniques employed by each are
> slightly different.

Probably not.  Both are using the native hardware in its natural 
rounding mode.

One likely source of the difference is the order of evaluation of 
complex expressions.  Fortran is required to honor parentheses, so

  (a + b) + c

and

  a + (b + c)

may give different results because of loss of significance if two of the 
numbers are close in magnitude but opposite in sign.  On the other hand, 
C isn't required to honor the parentheses.  I would assume Perl is like 
C in this respect -- a test would resolve this.

But fundamentally you are asking too much of either language.  Even 
within one programming language, comparing floating-point numbers that 
are the results of calculations for absolute equality is like asking 
whether the numbers of grains of sand in two piles is the same.  You'll 
never know, and you shouldn't care.  Comparing the results from *two* 
languages for absolute equality is utter folly.

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


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

Date: Thu, 22 Jul 1999 10:02:57 -0500
From: Scott Dummer <sdd@ls1-krf.krf.noaa.gov>
Subject: perl vs. FORTRAN Caculations
Message-Id: <Pine.HPP.3.96.990722095441.1664F-100000@ls1-krf>

I have written a series of equations to perform some distance calculations
in both perl and FORTRAN.  The results differ slightly (by 0.3%, or 161m).
This is very uncomforting to me.  Both programs use the exact same
constants and equations, although the FORTRAN is using implicit double
precision.  I am not using anything special in perl other than what is
basic in version 5.005_03.  I tend to trust what the FORTRAN is giving
over perl, since FORTRAN's strength is in accurate quick number crunching,
although if I could get the a % difference of around .03% I would use the
perl script.  Any help would be very much appreciated.

Just another perl novice.




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

Date: Thu, 22 Jul 1999 08:43:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: perl vs. FORTRAN Caculations
Message-Id: <MPG.1200dbf277a45bf0989d1a@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <Pine.HPP.3.96.990722095441.1664F-100000@ls1-krf> on Thu, 22 
Jul 1999 10:02:57 -0500, Scott Dummer <sdd@ls1-krf.krf.noaa.gov> says...
> I have written a series of equations to perform some distance calculations
> in both perl and FORTRAN.  The results differ slightly (by 0.3%, or 161m).
> This is very uncomforting to me.  Both programs use the exact same
> constants and equations, although the FORTRAN is using implicit double
> precision.  I am not using anything special in perl other than what is
> basic in version 5.005_03.  I tend to trust what the FORTRAN is giving
> over perl, since FORTRAN's strength is in accurate quick number crunching,
> although if I could get the a % difference of around .03% I would use the
> perl script.  Any help would be very much appreciated.
> 
> Just another perl novice.

Are you a Usenet novice too?  This is a slight variation of a message 
that you have posted three times already.  However, this one is more 
specific.

If you are doing distance calculations, you may be running into small 
differences in the evaluation of sqrt or x**0.5 .  But these shouln't 
affect more than the last bit of significance.  Again, you may be 
expecting too much precision if you are subtracting numbers of 
approximately equal magnitude.

You are right about Fortran being quick.  Don't expect speed from Perl -
- it's not designed for that.  But there is no intrinsic reason why 
Fortran should be more accurate.

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


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

Date: Thu, 22 Jul 1999 15:31:29 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: PGP and Mail
Message-Id: <lPGl3.881$ui4.277838@news.shore.net>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
:>
:>This seems to work fine for my purposes. Am I missing something obvious by
:>not using Open3?

: Probably not.  perdoc IPC::Open3 tells you

:        IPC::Open3, open3 - open a process for reading, writing,
:        and error handling

: Now explain why you prefer reading this on a newsgroup to reading
: it locally.

Gee, thanks so much for your help. If you read my message, you read that I
*already* read the documentation for IPC::Open3. My question was: "The
documentation is unclear; what are the important differences between using
this module vs. simply opening a pipe to the program in question?" The
only answer I've gotten so far is that "Open3 does things that open
doesn't" but no indication of what those things might be, or when they
might be important.

Do you have anything useful to add, or do you just like sniping from the
sidelines?

--Art


-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Thu, 22 Jul 1999 15:23:17 GMT
From: Vincent Moreau <moreau@objectif.fr>
To: bobby <bobby@alpstreet.net>
Subject: Re: problem with <input type="image".....
Message-Id: <379738D9.7D8AEBCC@objectif.fr>

First :
In <INPUT TYPE="Submit">, the VALUE parameter contains the button text.
In <INPUT TYPE="Image">, the VALUE parameter has no sense.

Second, try this :
<FORM ACTION="my-action">
<INPUT TYPE="Text" NAME="MyTextKey" VALUE="MyTextDefaultValue">
<INPUT TYPE="Image" NAME="Add" SRC="add.gif">
<INPUT TYPE="Image" NAME="Remove" SRC="remove.gif">
</FORM>

When the user clicks the "Add" image, the form submit() function is invoked
and the complete target URL is :
http://www.currentsite/currentdir/my-action?MyTextKey=Hello+World&Add.x=23&Add.y=45

Good luck.
Vincent Moreau, Objectif TECHnologie, Paris, France
<moreau@objectif.fr>


bobby wrote:

> Hi,
>
>         Would anyone be able to help me with this
>
> From within a html page created from a script i have a submit button but
> im using image instead of submit. ie:
>
> <input type="image" src="/images/add.gif" name="add" value="add">
>
> instead of:
>
> <input type="submit" name="add" value="add"
>
>         When i use the <input type="image" instead of <input
> type="submit" the
> script just reprints the page im already on instead of taking me to the
> "add" screen.
>
>         Does anyone know why?
>
>         thanks for any help
>
>                 bob



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

Date: Thu, 22 Jul 1999 15:35:52 GMT
From: G&K F <zotje@my-deja.com>
Subject: reading files on IIS4.0
Message-Id: <7n7don$ubu$1@nnrp1.deja.com>

Hi,

I am a newbie to Perl.  I wanted to read in a simple textfile from our
server and print out the last line of the file on a web page.  I got it
to work on an apache server, but I can't seem to connect to the file on
our IIS server.  Does anybody have any ideas.

Here is the code that works in unix:

#!/usr/local/bin/perl
#
# Program to grab a stock quote from a file
#
open (INFO, "../investors/testfile.txt");
@lines = <INFO>;
close (INFO);
$index = $#lines;
$stock = $lines[$index];
print $stock;
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>Stock Ticker</TITLE></HEAD><BODY>\n";
print "<h1>Today's stock value</h1><br><br>";
print "index is \'$stock\'<HR>";
print "</body></html>";

exit;

Thanks,
Glenn


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 22 Jul 1999 14:28:40 GMT
From: "William" <bivey@teamdev.com>
Subject: Re: regular Expression
Message-Id: <01bed44e$947b51c0$583c08cf@bill.jump.net>


Abigail <abigail@delanet.com> wrote in article
<slrn7pcqph.oqh.abigail@alexandra.delanet.com>...
> William (bivey@teamdev.com) wrote on MMCL September MCMXCIII in
> ?? I like one-liners myself
> ?? (($str =~ tr/\(//) == ($str =~ tr/\)//) )) or die "Not balanced";
> 
> 
> I prefer correct algorithms.
> 
> 
> 
> Abigail

Actually, it's _a_ correct algorithm, but wrong problem, which makes
it _the_ wrong algorithm :-) -Wm


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

Date: Thu, 22 Jul 1999 15:44:55 GMT
From: skao@my-deja.com
Subject: Re: RFC 1867, file upload
Message-Id: <7n7e9l$ui3$1@nnrp1.deja.com>

You seem to have truncated part of my original post:

"I've attempted utilizing a simple Perl script, but the file transfer
will only work on ASCII text.  Any help would be appreciated."

I am just reading in w/ STDIN.

If you could perhaps direct me to where I could go to find a solution,
since I know not where to look at this point, I would appreciate it.
Forgive me for not knowing the answer, I have been learning Perl for a
relatively short period of time.

In article <Pine.HPP.3.95a.990722011035.17832B-100000@hpplus03.cern.ch>,
  "Alan J. Flavell" <flavell@mail.cern.ch> wrote:
> On Wed, 21 Jul 1999 skao@inteliant.com wrote:
>
> > Does anyone know of a CGI program that enables form-based file
uploading
> > to a Solaris 2.6?
>
> Does anyone _not_ know CGI.pm?
>
> Of course, you also need a browser that supports it, but neither of
> these aspects is a Perl language question.
>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 22 Jul 1999 16:59:35 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: RFC 1867, file upload
Message-Id: <37973fe7@newsread3.dircon.co.uk>

skao@my-deja.com wrote:
> In article <Pine.HPP.3.95a.990722011035.17832B-100000@hpplus03.cern.ch>,
>   "Alan J. Flavell" <flavell@mail.cern.ch> wrote:
>> On Wed, 21 Jul 1999 skao@inteliant.com wrote:
>>
>> > Does anyone know of a CGI program that enables form-based file
> uploading
>> > to a Solaris 2.6?
>>
>> Does anyone _not_ know CGI.pm?
>>
>> Of course, you also need a browser that supports it, but neither of
>> these aspects is a Perl language question.
>>

> You seem to have truncated part of my original post:
> 
> "I've attempted utilizing a simple Perl script, but the file transfer
> will only work on ASCII text.  Any help would be appreciated."
> 
> I am just reading in w/ STDIN.
> 
> If you could perhaps direct me to where I could go to find a solution,
> since I know not where to look at this point, I would appreciate it.
> Forgive me for not knowing the answer, I have been learning Perl for a
> relatively short period of time.
> 

Alan *did* give you a solution - the module CGI.pm which is part of the
distribution for all recent Perl. The module has a section in its
documentation that specifically addresses this question.


-- 
"I came on the train but I think I managed to pass it off as an asthma
attack" - Jenny Eclair


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

Date: Thu, 22 Jul 1999 19:04:22 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: SSI in Perl CGI output
Message-Id: <7n8bn6$eva10@news.cyber.net.pk>

: Can't you read and then print the contents of the file in your CGI ?

SSI in the output of your CGI not the real source...

You can make your own ssi parser and:

# redirect STDOUT to $sout (use IO::Scalar or IO::String)
require 'script_to_call.pl'; #so we can pass $ENV...

and run ssi parser on $sout...

Or make changes in Apache source yourself.


$this_whole_message =~ s/ssi/SSI/gs; # :D

--
Use the force, read the source!




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

Date: Thu, 22 Jul 1999 17:08:47 GMT
From: flint@tcn.net (Flint Slacker)
Subject: Re: Stipping HTML and loosing memory
Message-Id: <37a145c7.2101878@news.remarq.com>


Its seems that both Jonathon and Faisal are more concerned with making
my program shorter with less brackets.  I thank you both for your tips
on programming and style but neither one of you paid any attention to
my question, or don't understand circular lists and garbage
collection.

>memory.  I searched around and found that it uses a circular list, how
>do I free it?

Jonathon and Faisal:

A circular list is when a parent node points to a child and the child
points back.  hmmmmm.... I think that works.  If you want to free this
memory you have to break the circle or perl's garbage collection will
miss it.  Once out of scope, this memory is locked away, I don't
believe it can be accessed or freed at that point(I might be wrong)
until the program exits.

Anyways, I found the answer, just haven't tried it yet.

Flint




On Wed, 21 Jul 1999 19:22:09 GMT, flint@tcn.net (Flint Slacker) wrote:

>
>The code below seems to strip the HTML tags out but never frees the
>memory.  I searched around and found that it uses a circular list, how
>do I free it?
>
>sub RemoveHTML {
>
>        my($htmlref);
>
>        $htmlref = HTML::FormatText->new;
>        $_[0] = $htmlref->format(parse_html($_[0]));
>
>        undef $htmlref;		# Free memory ????
>
>        return($_[0]);
>
>}
>
>Flint



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

Date: 22 Jul 1999 15:53:14 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Stipping HTML and loosing memory
Message-Id: <3797305a@newsread3.dircon.co.uk>

Flint Slacker <flint@tcn.net> wrote:
> 
> Its seems that both Jonathon and Faisal are more concerned with making
> my program shorter with less brackets.  I thank you both for your tips
> on programming and style but neither one of you paid any attention to
> my question, or don't understand circular lists and garbage
> collection.
> 

Except your code doesnt have a 'circular list' in it - I have no way of
knowing what the module does without looking at the code.  Your code
exhibit some other elements of incorrectness which I corrected.  

>>memory.  I searched around and found that it uses a circular list, how
>>do I free it?
> 
> Jonathon and Faisal:
> 
> A circular list is when a parent node points to a child and the child
> points back.  hmmmmm.... I think that works.  If you want to free this
> memory you have to break the circle or perl's garbage collection will
> miss it.  Once out of scope, this memory is locked away, I don't
> believe it can be accessed or freed at that point(I might be wrong)
> until the program exits.
> 

It doesnt behove you to be patronizing - 

*plonk*

/J\
-- 



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

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

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


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