[7674] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1300 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 11 08:07:15 1997

Date: Tue, 11 Nov 97 05:00:43 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 11 Nov 1997     Volume: 8 Number: 1300

Today's topics:
     Re: @ARGV Limits or Attempts to avoid "glob: Too many a <jamesr@aethos.co.uk>
     Re: Any Ideas... <qdtcall@esb.ericsson.se>
     can set default path? <niwa@ultinet.net>
     Re: fixes I made for sfio on Solaris 2.6 (Casper H.S. Dik - Network Security Engineer)
     Re: Foo - Bar (Tad McClellan)
     Re: Help/newtoPERL/Input files <mikrich@ibm.net>
     Re: Help/newtoPERL/Input files <mikrich@ibm.net>
     how do i append todays date to the end of a filename? <Mitzi.Withrow@cwi.cablew.com>
     Re: How do I create a random number with Perl? <dformosa@st.nepean.uws.edu.au>
     Re: How do I create a random number with Perl? (Charles DeRykus)
     Re: How to assign values to arrays? (Toutatis)
     Re: multithreading (Charles DeRykus)
     Re: ODBC and Apostrophe (Mike Heins)
     odd difference between C and Perl <jd@mukh.asc.ox.ac.uk>
     Re: odd difference between C and Perl (Tom Grydeland)
     Re: odd difference between C and Perl <temme@kosmo.cgk.sni.de>
     Re: odd difference between C and Perl <pm@katz.cc.univie.ac.at>
     Re: odd difference between C and Perl (Mike Heins)
     Re: Perl->Java? Java->Perl? Gaaaaa! lvirden@cas.org
     q: s/const/CONST/o  or  s/const/CONST/  ? (Petr Prikryl)
     Re: q: s/const/CONST/o  or  s/const/CONST/  ? (Tad McClellan)
     Re: scalar function weird <mehta@mama.indstate.edu>
     sendmail? <niwa@ultinet.net>
     Re: Single and Double quotes (Charles DeRykus)
     Tuning Perl 5.004_03 <simon@fastfare.co.uk>
     Where can I get the pre-compiled binariy "undump" for L <mustun@active.ch>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 11 Nov 1997 10:38:25 GMT
From: "James Richardson" <jamesr@aethos.co.uk>
Subject: Re: @ARGV Limits or Attempts to avoid "glob: Too many arguments" message
Message-Id: <01bcee8e$0fae9e40$26c0a4c1@kitkat.aethos.co.uk>

Casper H.S. Dik - Network Security Engineer <Casper.Dik@Holland.Sun.Com>
wrote in article <casper.879164277@uk-usenet.uk.sun.com>...
> "James Richardson" <jamesr@aethos.co.uk> writes:
> 
> >Well, its OS dependent, but on Solaris its about 1000 files....
> 
> On Solaris the limit is 1 MB worth of @ARGV + %ENV, not 1000 files
> (The maximum filename length is 1024, typical filenames are (much)
shorter,
> so "thousands of files" would be more accurate)
> 
> Casper

Hmm... well if you say so... certainly when writing Perl that has to run
under SunOS4.1.3U1 and Solaris2.3/4/5,  I ran into this problem when globs
gave more than about 1000 files.......

Whatever :-)

James



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

Date: 11 Nov 1997 10:02:49 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Any Ideas...
Message-Id: <iswwifiz0m.fsf@godzilla.kiere.ericsson.se>

<itootall@earthlink.net> writes:

> [an error occurred while processing this directive]
> What on earth does this mean??

It means that an error occured while processing that directive. This
has absolutely nothing to do with Perl. Go read the documentation for
your webserver, and/or post in a relevant newsgroup.

-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: Tue, 11 Nov 1997 01:59:47 -0500
From: Tsuyoshi Niwa <niwa@ultinet.net>
Subject: can set default path?
Message-Id: <34680263.6E49@ultinet.net>

I wonder if perl has any function that you can say
this is the base (or default) path it's gonna use
anytime it handles files. I'm looking for something like
<Base Target="">thing in HTML


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

Date: 11 Nov 1997 11:39:07 GMT
From: Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer)
Subject: Re: fixes I made for sfio on Solaris 2.6
Message-Id: <casper.879248641@uk-usenet.uk.sun.com>

[[ Reply by email or post, don't do both ]]

Andy Cohan <afc@c2o.com> writes:

>After fixing that, I couldn't compile anything.  There was a syntax
>error due to an undefined macro in a header file called mmap.h.  After
>looking around a bit, I added a -D_LARGEFILE64_SOURCE to the compile
>statement via the CCFLAGS variable in all the makefiles and everything
>compiled just peachy keenly.  Perhaps somebody out there has an idea
>of what this define means?


See largefile(5) and releated manual pages.

The fact that you need that change makes me think that you
didn't fix gcc for 2.6.

The solaris FAQ says:

6.27) I can't seem to get gcc to work under Solaris 2.6


    As with all new Solaris releases, you need to reinstall gcc after
    upgrading.  Unfortunately, Solaris 2.6 include files don't get
    properly fixed by fixincludes.  To fix this, apply the following
    patch to fixinc.svr4 before building gcc.

	*** ./fixinc.svr4.org	Thu Jun 15 23:03:29 1995
	--- ./fixinc.svr4	Thu Sep  4 13:41:29 1997
	***************
	*** 189,194 ****
	--- 189,195 ----
		  s/__STDC__[ 	][ 	]*==[ 	][ 	]*1/defined (__STRICT_ANSI__)/g
		  s/__STDC__[ 	][ 	]*!=[ 	][ 	]*0/defined (__STRICT_ANSI__)/g
		  s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
	+ 	  s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g
		  /^typedef[ 	][ 	]*[unsigned 	]*long[ 	][ 	]*[u_]*longlong_t;/s/long/long long/
		' $2/$file > $2/$file.sed
		mv $2/$file.sed $2/$file

    --- end of excerpt from the FAQ

Questions marked with a * or + have been changed or added since
the FAQ was last posted

The most recently posted version of the FAQ is available from
<http://www.wins.uva.nl/pub/solaris/solaris2/>
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.


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

Date: Tue, 11 Nov 1997 06:33:56 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Foo - Bar
Message-Id: <kbj946.9r5.ln@localhost>

Georg Edelmayer (ged@fortec.tuwien.ac.at) wrote:

: This might be out of subject (and if it is, please ignore this posting)
: but as one who is not a -programmer- but interested in programming i
: once again found 'foo' and 'bar' mentioned in some examples.

: I realise that nearly every programming language manual or doc or
: whatever uses foo and bar when explaining code.
: Like 'hello world' is the first thing everyone codes ;-)

: So can any of you tell me where this names come from? 
: It could be any names, so why foo and bar?


It comes from World War II.  FUBAR = Fucked Up Beyond All Recognition.

Spelling changed to protect delicate sensibilities.


: Thanks in advance

You asked for it ;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Tue, 11 Nov 1997 08:59:01 +0000
From: mike rich <mikrich@ibm.net>
To: Creede Lambard <fearless@io.com>
Subject: Re: Help/newtoPERL/Input files
Message-Id: <34681E55.7F137F93@ibm.net>

Many thanks for that - cracks it - actually not with associative - but with the
name array
(co detail file has no company name or identifier in it - merely relying on
order in the file!)
Someone has lost a database - wd you believe - and only has the Quark files used
to print a directory -
i am trying to rebuild the db from these.
much appreciated

Creede Lambard wrote:

> Congratulations! You'll find (as perhaps you already have) that MacPerl
> solves a lot of the problems created by not having an accessible command
> line.
>
> I'd like to help you with this but I don't really have a clear picture of
> what you're trying to do. Sometimes I find it useful (as I do with Visual
> Basic) to get an idea of both what the program (and/or its data) looks like
> at the beginning, and what I want it to end up looking like. For instance,
> if your company names file (preA.csv) looks like this:
>
> FirstCo
> National Second Company
> ThirdCorp
>
> and your data file (tagtxt.ps) looks like this:
>
> FirstCo;my first company
> FourCom;this won't be in the list
> Amalgamated Five;neither will this
> National Second Company;company #2
> The Aptly Named Company Not Appearing In This List;owned by Python (Monty)
> ThirdCorp;you guessed it, the third company
> 3Com;very big, but not in this list
>
> and you want to end up with a file looking like this:
>
> "UK","FirstCo","my first company"
> "UK","National Second Company","company #2"
> "UK","ThirdCorp","you guessed it, the third company"
>
> you might do something like this, which will save you a great deal of time
> since you don't have to read the data file every time you look something up:
>
> #!/usr/bin/perl;
>
> %info = ();
>
> open(DESCRIPTIONS,"tagtxt.ps") or die "Can't read from tagtxt.ps";
> while(<DESCRIPTIONS>) {
>     my($input) = $_;
>     chomp($input);
>     my($name,$desc) = split(/;/,$input);
>     $info{$name} = $desc;
>     }
> close DESCRIPTIONS;
>
> open(COMPANIES,"preA.csv") or die "Can't read from preA.csv";
> open(OUTPUT,">miketest.csv") or die "Can't write to miketest.csv";
> while (<COMPANIES>) {
>     chomp;
>     print OUTPUT q!"UK","! , $_ , q!","! , $info{$_} , q!"!, "\n";
>     }
> close OUTPUT;
>
> This reads the lines from the company information file, splits them in two
> at the semicolon, and assigns them places in the %info associative array.
> Then it "looks up" the descriptions for the company names in your preA file
> in this associative array (thereby saving you from having to run through the
> file every time) and prints them out.
>
> Hope this helps to point you in the right direction!
>
> -- Creede Lambard
> Minister of Irregular Expressions
> Programming Republic of Perl
>
> mike rich wrote in message <3465D413.18FFE99B@ibm.net>...
> >4 days into Perl - have the camel & llama books - can't find the answer
> >to my problem.
> >Have used MacPerl  to extract clean data from Quark & EPS files - (great
> >language!)
> >Have two files - one containing company names - the second containing
> >company data.
> >Want to read a company name from one file/ read the co. data from
> >another file
> >-combine the two into one record and write it out to a third file.
> >Script at moment looks like this:
>
> open(NFILE, "preA.csv");
> open(PSFILE, "tagtxt.ps");
> open (CSVFILE, ">miketest.csv");
>
> $mark1=0;
> while($conam=<NFILE>) {
>     while(<PSFILE>) {
>         if($mark1==0){
>             $/="syzergy";
>             $desc=$_;
>             $mark1=2;
>         }
>     }
>     $newlin="\"UK,\"".$conam."\",".$desc;
>     print CSVFILE "NEWLINE $newlin\n";
>     $/=";";
>     $mark1=0;
> }
>
> close PSFILE;
> close NFILE;
> close CSVFILE;
>
> >
> >Apart from the cumsiness, obviously missed something blindingly obvious!
> >
> >What this does - as you all realise - is print the co. names with the
> >same bit
> >of company detail
> >
> >Cd some kind soul point me in the right direction.
> >
> >Many thx.
> >
> >
> >
> >





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

Date: Tue, 11 Nov 1997 09:00:17 +0000
From: mike rich <mikrich@ibm.net>
To: Creede Lambard <fearless@io.com>
Subject: Re: Help/newtoPERL/Input files
Message-Id: <34681EA0.1674616A@ibm.net>

Many thanks for that - cracks it - actually not with associative - but with the
name array
(co detail file has no company name or identifier in it - merely relying on
order in the file!)
Someone has lost a database - wd you believe - and only has the Quark files used
to print a directory -
i am trying to rebuild the db from these.
much appreciated

Creede Lambard wrote:

> Congratulations! You'll find (as perhaps you already have) that MacPerl
> solves a lot of the problems created by not having an accessible command
> line.
>
> I'd like to help you with this but I don't really have a clear picture of
> what you're trying to do. Sometimes I find it useful (as I do with Visual
> Basic) to get an idea of both what the program (and/or its data) looks like
> at the beginning, and what I want it to end up looking like. For instance,
> if your company names file (preA.csv) looks like this:
>
> FirstCo
> National Second Company
> ThirdCorp
>
> and your data file (tagtxt.ps) looks like this:
>
> FirstCo;my first company
> FourCom;this won't be in the list
> Amalgamated Five;neither will this
> National Second Company;company #2
> The Aptly Named Company Not Appearing In This List;owned by Python (Monty)
> ThirdCorp;you guessed it, the third company
> 3Com;very big, but not in this list
>
> and you want to end up with a file looking like this:
>
> "UK","FirstCo","my first company"
> "UK","National Second Company","company #2"
> "UK","ThirdCorp","you guessed it, the third company"
>
> you might do something like this, which will save you a great deal of time
> since you don't have to read the data file every time you look something up:
>
> #!/usr/bin/perl;
>
> %info = ();
>
> open(DESCRIPTIONS,"tagtxt.ps") or die "Can't read from tagtxt.ps";
> while(<DESCRIPTIONS>) {
>     my($input) = $_;
>     chomp($input);
>     my($name,$desc) = split(/;/,$input);
>     $info{$name} = $desc;
>     }
> close DESCRIPTIONS;
>
> open(COMPANIES,"preA.csv") or die "Can't read from preA.csv";
> open(OUTPUT,">miketest.csv") or die "Can't write to miketest.csv";
> while (<COMPANIES>) {
>     chomp;
>     print OUTPUT q!"UK","! , $_ , q!","! , $info{$_} , q!"!, "\n";
>     }
> close OUTPUT;
>
> This reads the lines from the company information file, splits them in two
> at the semicolon, and assigns them places in the %info associative array.
> Then it "looks up" the descriptions for the company names in your preA file
> in this associative array (thereby saving you from having to run through the
> file every time) and prints them out.
>
> Hope this helps to point you in the right direction!
>
> -- Creede Lambard
> Minister of Irregular Expressions
> Programming Republic of Perl
>
> mike rich wrote in message <3465D413.18FFE99B@ibm.net>...
> >4 days into Perl - have the camel & llama books - can't find the answer
> >to my problem.
> >Have used MacPerl  to extract clean data from Quark & EPS files - (great
> >language!)
> >Have two files - one containing company names - the second containing
> >company data.
> >Want to read a company name from one file/ read the co. data from
> >another file
> >-combine the two into one record and write it out to a third file.
> >Script at moment looks like this:
>
> open(NFILE, "preA.csv");
> open(PSFILE, "tagtxt.ps");
> open (CSVFILE, ">miketest.csv");
>
> $mark1=0;
> while($conam=<NFILE>) {
>     while(<PSFILE>) {
>         if($mark1==0){
>             $/="syzergy";
>             $desc=$_;
>             $mark1=2;
>         }
>     }
>     $newlin="\"UK,\"".$conam."\",".$desc;
>     print CSVFILE "NEWLINE $newlin\n";
>     $/=";";
>     $mark1=0;
> }
>
> close PSFILE;
> close NFILE;
> close CSVFILE;
>
> >
> >Apart from the cumsiness, obviously missed something blindingly obvious!
> >
> >What this does - as you all realise - is print the co. names with the
> >same bit
> >of company detail
> >
> >Cd some kind soul point me in the right direction.
> >
> >Many thx.
> >
> >
> >
> >





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

Date: Mon, 10 Nov 1997 15:37:42 -0500
From: Mitzi <Mitzi.Withrow@cwi.cablew.com>
Subject: how do i append todays date to the end of a filename?
Message-Id: <34677096.30808898@cwi.cablew.com>

i cant seem to get the date into a string format, i am a very new perl
programmer. thanks.



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

Date: 11 Nov 1997 08:39:52 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: How do I create a random number with Perl?
Message-Id: <879237517.967161@cabal>

In <645e6b$kqq@camel21.mindspring.com> "Eric Phillips" <e.phillips@mindspring.com> writes:

>Hello all, I have a question about Perl.  I am no expert, just an amateur,
>so please explain in detail.

>How do I create a random number with Perl, so it can be use later in the
>script?

The question is how random do you want?  rand will give you a nice
pydorandom number.  Getting real random numbers is a little more difficalt 
linux is has a '/dev/random' wich may be usefull for this perpose.  I
don't know how random it is though.


--
Please excuse my spelling as I suffer from agraphia see the url in my header. 
Never trust a country with more peaple then sheep. 
Save the ABC Is $0.08 per day too much to pay?   ex-net.scum and proud
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Mon, 10 Nov 1997 17:33:02 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: How do I create a random number with Perl?
Message-Id: <EJFy32.45M@bcstec.ca.boeing.com>

In article <645e6b$kqq@camel21.mindspring.com>,
Eric Phillips <e.phillips@mindspring.com> wrote:
>Hello all, I have a question about Perl.  I am no expert, just an amateur,
>so please explain in detail.
>
>How do I create a random number with Perl, so it can be use later in the
>script?
>
>
You can progress rapidly by helping yourself to the online documentation,
e.g, perldoc -f rand. In this case, that's not the best tutorial.
I'd advise getting "Learning Perl" by R.Schwartz and T.Christiansen 
to fill the gaps. You'll thank yourself everytime you look at it. 
 
Here's a example from "Learning Perl" which prints a random string 
from a list input from the terminal: 


srand:    # not needed if Perl version 5.004 or higher 
print "List of strings: "; @b = <STDIN>;
print "Answer: $b[rand(@b)]"; 



HTH,
--
Charles DeRykus


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

Date: 11 Nov 1997 11:21:36 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: How to assign values to arrays?
Message-Id: <toutatis-ya023180001111971221400001@news.euro.net>

waqar.hafiz@virgin.net (Waqar Hafiz) wrote:

> The output of an application gives me the following string of data:
> 
> 1. Category subcategory1 data1 data2 subcategory2 data3 data4 data5
> subcategory3 ...
> 
> or it may output like this:
> 
> 2. Category subcategory3 data1 data2 subcategory1 data3 data4 data5
> subcategory2 ...
> 
> I know the keywords - subcategory1, subcategory2, subcategory3 ....
> 
> How can I go through the list and assign all data values for a subcategory
> to an array? In the 2nd example above:
> 
> @subcategory1 would contain data3, data4 & data5
> @subcategory3 would contain data1 & data2

You could create the arrays, and access them through @{$catagory_name}, but
a hash of lists is a more obvious option in your case:

my $line = "Catagory data etc";
my %HoL;
my $catagory = "defaultcatagory";
for(split / /,$line){
   if (/^(subcatagory.*)/){  #or: /^(name1|name2|name3|name4)$/
       $catagory = $1;
   }
   else {
       push @{$HoL{$catagory}},$_;
   }
}

-- 
Toutatis


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

Date: Mon, 10 Nov 1997 17:13:06 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: multithreading
Message-Id: <EJFx5v.2pr@bcstec.ca.boeing.com>

In article <01bced60$074f1d80$18b186cf@cyberus.cyberus.ca>,
Thane & Leslie Eisener <thaneles@removethis.cyberus.ca> wrote:
>I have a script that gathers data from the network for me three times.
>Currently these are performed in series.  How can I make these three
>function all at the same time?
>

perldoc -f fork  or look for fork in "Learning Perl" by R.Schwartz
and T.Christiansen.   

(Multithreading based on POSIX threads coming soon with 5.005 
 Perl Release...) 


HTH,
--
Charles DeRykus


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

Date: 11 Nov 1997 11:03:39 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: ODBC and Apostrophe
Message-Id: <649e2b$k48$1@vixen.cso.uiuc.edu>

Steve Kilbane (Steve_Kilbane@cegelecproj.co.uk) wrote:
: In article <slrn66eq7k.sq1.wkc@amanda.dorsai.org>, wkc@dorsai.org (Wesley) writes:
: > Replace all of the ' with '' works.  It's a SQL thing.  s/'/''/g becomes a
: > standard line in all my sql lines.
: 
: I missed the original post, so I don't know which ODBC interface
: the poster's using, but if it's DBI, then they should be quoting
: strings using the quote() method:
: 
: my $dbh = DBI->connect(...);
: $field = $dbh->quote($field);
: my $sth = $dbh->prepare("SELECT * FROM table WHERE col = $field");
: 
: Note that quote() is supposed to escape quotes itself, and is supposed
: to wrap the result in the required quotes too, so you'd use
: $field, rather than '$field'.

You are absolutely correct.

I posted the above as the first response to the article, quite a long
time ago, and for some reason these additional "answers" kept popping
up.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: Tue, 11 Nov 1997 09:49:13 +0000
From: John Davis <jd@mukh.asc.ox.ac.uk>
Subject: odd difference between C and Perl
Message-Id: <34682A19.3A74@mukh.asc.ox.ac.uk>

I've written a routine to convert Islamic
dates to Gregorian ones. For internal reasons,
I've done a version in C and another in Perl.

At one stage you have to multiply the Islamic
year by 0.970224 and add 622.54.

Given the Islamic year 1367

the C code 

	x = (Hy * 0.970224) + 622.540000;

produces 1948.836182 (x is declared as a float)

whereas the Perl code

	 $x = ($Hy * 0.970224) + 622.540000;


produces 1948.836208

The second of these is confirmed by my HPCalculator.
which at 9 decimal places gives 1948.836208000.

I haven't yet discovered an input for which this
makes a difference to the final result, but it may
exist (you have to do further calculations with the
fractional result, to calculate the month and day).

But it would be interesting to know why the difference
occurs.


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

Date: 11 Nov 1997 10:59:58 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: odd difference between C and Perl
Message-Id: <slrn66gele.iv1.Tom.Grydeland@mitra.phys.uit.no>

On Tue, 11 Nov 1997 09:49:13 +0000,
John Davis <jd@mukh.asc.ox.ac.uk> wrote:

> 	x = (Hy * 0.970224) + 622.540000;
> produces 1948.836182 (x is declared as a float)

> But it would be interesting to know why the difference
> occurs.

Perl floatin point numbers are doubles.  Try a double in C.

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 11 Nov 1997 10:45:43 GMT
From: "Rainer Temme" <temme@kosmo.cgk.sni.de>
Subject: Re: odd difference between C and Perl
Message-Id: <01bcee8f$0a1fc700$c48bca95@samos_pc2>



John Davis wrote:
> the C code 
> 
> 	x = (Hy * 0.970224) + 622.540000;
> 
> produces 1948.836182 (x is declared as a float)
> 
> whereas the Perl code
> 
> 	 $x = ($Hy * 0.970224) + 622.540000;
> 
> 
> produces 1948.836208
> 
> The second of these is confirmed by my HPCalculator.
> which at 9 decimal places gives 1948.836208000.

I suppose that pearl uses double variables to calculate the
result, and that you used float for your C programm.
 ...
try double instead of float in your C programm.
I think that should work fine.



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

Date: 11 Nov 1997 11:29:36 GMT
From: pm <pm@katz.cc.univie.ac.at>
Subject: Re: odd difference between C and Perl
Message-Id: <649fj0$29ds$1@ftp.univie.ac.at>

In comp.lang.perl.misc John Davis <jd@mukh.asc.ox.ac.uk> wrote:

: Given the Islamic year 1367
: the C code 

: 	x = (Hy * 0.970224) + 622.540000;

: produces 1948.836182 (x is declared as a float)

: whereas the Perl code

: 	 $x = ($Hy * 0.970224) + 622.540000;

: produces 1948.836208

Nothing odd about it, just the ordinary effects of floating point
arithmetic. C's floats are usually 32-bit numbers in IEEE format, which
gives you about 7 significant decimal digits. So forget the digits
after 1948.836, they are meaningless. If you declare your numbers
double rather than float you should get about 15 significant digits
and the same results as with perl, which uses double internally.

-- 
Peter Marksteiner                       e-mail: Peter.Marksteiner@univie.ac.at
Vienna University Computer Center                   Tel: (+43 1) 4277 14055
Universitaetsstrasse 7, A-1010 Vienna, Austria      FAX: (+43 1) 4277 9140


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

Date: 11 Nov 1997 11:32:04 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: odd difference between C and Perl
Message-Id: <649fnk$k48$2@vixen.cso.uiuc.edu>

John Davis (jd@mukh.asc.ox.ac.uk) wrote:
: I've written a routine to convert Islamic
: dates to Gregorian ones. For internal reasons,
: I've done a version in C and another in Perl.
: 
: At one stage you have to multiply the Islamic
: year by 0.970224 and add 622.54.
: 
: Given the Islamic year 1367
: 
: the C code 
: 
: 	x = (Hy * 0.970224) + 622.540000;
: 
: produces 1948.836182 (x is declared as a float)
: 
: whereas the Perl code
: 
: 	 $x = ($Hy * 0.970224) + 622.540000;
: 
: 
: produces 1948.836208
: 
: The second of these is confirmed by my HPCalculator.
: which at 9 decimal places gives 1948.836208000.
: 
: I haven't yet discovered an input for which this
: makes a difference to the final result, but it may
: exist (you have to do further calculations with the
: fractional result, to calculate the month and day).
: 
: But it would be interesting to know why the difference
: occurs.

It is just precision. Try:


void main () {
    double x;
    double Hy;
    double k;
    double adder;

    Hy = 1367;
    k = 0.970224;
    adder = 622.54;

    x = (Hy * k) + adder;
    printf ("%f\n", x);
}

It gives the correct answer.

You can verify with Perl:

use Math::BigFloat;
$k = new Math::BigFloat "0.970224";
$Hy = 1367;
$adder = "622.540000";
$x = ($Hy * $k) + $adder;
print "$x\n";

Math::BigFloat will give an answer at an arbitrary
precision.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: 11 Nov 1997 12:52:03 GMT
From: lvirden@cas.org
Subject: Re: Perl->Java? Java->Perl? Gaaaaa!
Message-Id: <649kdj$im8$1@srv38s4u.cas.org>


According to Jeff Melrose  <jeff.melrose@quintus.com>:
:Wrong Java is a complete paradigm shift. Write once run anywhere.
:really means write once debug everywhere. Yes even with the same
:browser.

Actually, setting aside the seemingly popular Java bashing sledgehammer
for a moment, I don't find Java any more of this "Write once, debug everywhere"
paradigm than any other language.  It's been that way for folk trying
to write portable C, C++, Tcl, Perl, Python, etc. for years.

The primary reason Java gets bashed isn't that it isn't portable but that
it's the most recent language to claim that it is portable. Shrug.

-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: 11 Nov 1997 10:47:39 GMT
From: prikryl@dcse.fee.vutbr.cz (Petr Prikryl)
Subject: q: s/const/CONST/o  or  s/const/CONST/  ?
Message-Id: <649d4b$ph7$1@boco.fee.vutbr.cz>

I have found in the Perl FAQ ("What is /o really for?") the following
information:

    Use of /o is irrelevant unless variable interpolation is used 
    in the pattern...

Does it mean, that when the constant pattern (here `const') is used
then /o makes no difference in the speed of evaluation?

Thanks for the answer,

Petr

--
Petr Prikryl (prikryl@dcse.fee.vutbr.cz)   http://www.fee.vutbr.cz/~prikryl/
TU of Brno, Dept. of Computer Sci. & Engineering;    tel. +420-(0)5-7275 218


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

Date: Tue, 11 Nov 1997 06:43:13 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: q: s/const/CONST/o  or  s/const/CONST/  ?
Message-Id: <1tj946.9r5.ln@localhost>

Petr Prikryl (prikryl@dcse.fee.vutbr.cz) wrote:
: I have found in the Perl FAQ ("What is /o really for?") the following
: information:

:     Use of /o is irrelevant unless variable interpolation is used 
:     in the pattern...

: Does it mean, that when the constant pattern (here `const') is used
: then /o makes no difference in the speed of evaluation?

: Thanks for the answer,


Yes. That is exactly what it means.


Similarly:

/m is irrelevant unless anchors (^ and/or $) are used in the pattern

/s is irrelevant unless dot (.) is used in the pattern



--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Tue, 11 Nov 1997 03:09:29 GMT
From: Miten S Mehta <mehta@mama.indstate.edu>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: scalar function weird
Message-Id: <Pine.LNX.3.96.971110220830.7217D-100000@mama.indstate.edu>


Hello guys,

I apologize for misunderstanding scalar.  I confirmed for me that it works
fine.  Thanks guys.

On Mon, 10 Nov 1997, Tom Phoenix wrote:

> Date: Mon, 10 Nov 1997 14:06:50 -0800 (PST)
> From: Tom Phoenix <rootbeer@teleport.com>
> To: mehta@mama.indstate.edu
> Newsgroups: comp.lang.perl.misc
> Subject: Re: scalar function weird
> 
> On Fri, 7 Nov 1997 mehta@mama.indstate.edu wrote:
> 
> > Subject: scalar function weird
> 
> No, it's not weird. It's not even a function. :-)
> 
> 'scalar' is merely a clue to the compiler that what follows is to be
> evaluated in a scalar context. That's all. It merely _looks_ like a
> function. :-)
> 
> -- 
> 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/
>               Ask me about Perl trainings!
> 
> 


Have a good day !!!

Best Regards,

Miten Mehta.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
Res:                                            |
Miten S Mehta                                   |
311 S Lasalle St, 39E,		                |
Durham, NC 27705                                |
Tel: 919 416 3889                               |             
e-mail: mehta@mama.indstate.edu                 |
resume url:                                     |
ftp://mama.indstate.edu/users/mehta/resume.html | 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             





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

Date: Tue, 11 Nov 1997 02:01:47 -0500
From: Tsuyoshi Niwa <niwa@ultinet.net>
Subject: sendmail?
Message-Id: <346802DC.D17@ultinet.net>

Where can I learn how to write scripts using
sendmail? I have a trouble that only To: shows up
in the header and the rest becomes a part of message.

Tsuyoshi


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

Date: Mon, 10 Nov 1997 17:03:04 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Single and Double quotes
Message-Id: <EJFwp4.1t1@bcstec.ca.boeing.com>

In article <3467389f.610808@netnews.nyu.edu>,
Ryuji Yokoyama <rqy1319@is4.nyu.edu> wrote:
 >Hello All!
 >
 >I just started to learn Perl by myself and have a question about
 >strings.  What is the different single quote and double quote?  When
 >do I have to use single quote and double? 

man perlop and look for the "Quote and Quote-like Operators" but
I'd recommend "Learning Perl" by R.Schwartz and T.  Christiansen. 
Without that excellent introduction, you're trying to learn Perl 
the hard way ... 


HTH,
--
Charles DeRykus


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

Date: Tue, 11 Nov 1997 12:39:41 +0000
From: Simon <simon@fastfare.co.uk>
Subject: Tuning Perl 5.004_03
Message-Id: <3468520D.9DBE6730@fastfare.co.uk>

Background:

I'm using Perl 5.004_03 and Solaris 2.5.1

I would like to know how to tune the perl interpreter to be
less memory hungry, as the memory taken up by the perl script
after taking into account of the interpreter is 7 meg, this
of course doubles when the script forks.

Initially when I tested the script, I could run 6 invocations
before running into out of memory errors. (This is with
64 Meg Ram (approx 40meg free) and 150 Meg Swap (free swap))

I've recompiled the sources for shared libraries and managed to
get up to 10 invocations. (I also set sticky bit on the executable)

In the documentation (& config prog) I have read that you can
enable 'vfork' and disable perls own memory manager.

Questions:
1. Are shared libraries truly shared between all invocations ?
2. Is setting the sticky bit a red herring, or does it help ?
3. vfork ... has solaris/perl have problems with this enabled ?
4. Perls internal memory manager ... should I disable it ????

BTW ... For the moment assume that rewriting perl script
        in C is not an option :-/

Thanks for your time

   Simon

PS. *** POSTING THIS MESSAGE ON USENET IS NOT PERMISSION TO SPAM ME
        WITH GET RICH SCHEMES OR ANY FORM OF ADVERTISING OR ANY OTHER
        SO CALLED OFFERS
        SPAMMING IS UNSOCIABLE AND WILL NOT BE TOLERATED AT THIS SITE
        THANKYOU


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

Date: Tue, 11 Nov 1997 10:01:53 +0100
From: "M. Mustun" <mustun@active.ch>
Subject: Where can I get the pre-compiled binariy "undump" for Linux?
Message-Id: <34681F01.5E352E11@active.ch>

<HTML>
<TT>Hello!</TT><TT></TT>

<P><TT>Where can I get the precompiled binariy "undump" for Linux?</TT>
<BR><TT>Many thanks,</TT>
<PRE>--&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M. Mustun
&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="mailto:mustun@active.ch">mailto:mustun@active.ch</A>
&nbsp; <A HREF="http://www2.active.ch/~mustun">http://www2.active.ch/~mustun</A></PRE>
&nbsp;</HTML>



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

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

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