[6339] in Perl-Users-Digest
Perl-Users Digest, Issue: 961 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 17 02:17:12 1997
Date: Sun, 16 Feb 97 23:00:16 -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 Sun, 16 Feb 1997 Volume: 7 Number: 961
Today's topics:
$ls = `ls $file`; but not in NT Perl <bgraham@bgraham.com>
Re: $ls = `ls $file`; but not in NT Perl (Dave Thomas)
Re: $ls = `ls $file`; but not in NT Perl (Nathan V. Patwardhan)
Compiling Perl on UnixWare KMAGLOUGHLIN@delphi.com
Help on Perl5.003 on Aix 4.2 (Mike Alvarez)
Re: HELP: a newbie question <dean@tbone.biol.sc.edu>
Re: HELP: a newbie question (Tad McClellan)
Re: HOW TO SPLIT A SIMPLE STRING (I R A Aggie)
Re: Learning perl from scratch <dean@tbone.biol.sc.edu>
Re: Perl question, re: POSIX setpgrp <roderick@gate.net>
Re: Pig Latin (Dave Thomas)
Re: Problem with Curses and 5.003 <wsetzer@babylon5.unity.ncsu.edu>
problem writing to files (Mark Schneider)
Re: PROGRAM: how to check for nice/valid email address <dean@tbone.biol.sc.edu>
Q: int(1.0) = 0 ????? <pareis@cs.tu-berlin.de>
Re: Q: int(1.0) = 0 ????? (Dave Thomas)
Re: s/// Quesiton (Jim Reynolds)
Re: Searching for Perl-supported Linux database <marten.mickos@solidtech.com>
undump binary for solaris (Philip Chen)
Re: using sendmail <bgraham@bgraham.com>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 16 Feb 1997 17:23:18 -0800
From: Bo Graham <bgraham@bgraham.com>
Subject: $ls = `ls $file`; but not in NT Perl
Message-Id: <3307B306.439F@bgraham.com>
Hello,
I'd like help translating this into something that the binary version
(NT) of Perl can cope with. #$ls = `ls $file`; works in unix but not
in Windows version of perl... How do I do this then?
Thanks
Bo Graham
------------------------------
Date: 17 Feb 1997 03:46:16 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: $ls = `ls $file`; but not in NT Perl
Message-Id: <slrn5gfkv5.vu7.dave@fast.thomases.com>
On Sun, 16 Feb 1997 17:23:18 -0800, Bo Graham <bgraham@bgraham.com> wrote:
> Hello,
>
> I'd like help translating this into something that the binary version
> (NT) of Perl can cope with. #$ls = `ls $file`; works in unix but not
> in Windows version of perl... How do I do this then?
Do you have a 'ls' command under your NT (bring up a cmd window and type
ls). You may have if you've got the cygnus stuff. Otherwise, under NT its
'dir'.
However, you'd normally not want to do either an ls or a dir within Perl -
it handles that kind of thing internally much more efficiently and
gracefully.
What exactly is the rest of the script trying to do?
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 17 Feb 1997 04:58:07 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: $ls = `ls $file`; but not in NT Perl
Message-Id: <5e8ogv$7jc@fridge-nf0.shore.net>
Bo Graham (bgraham@bgraham.com) wrote:
: I'd like help translating this into something that the binary version
: (NT) of Perl can cope with. #$ls = `ls $file`; works in unix but not
: in Windows version of perl... How do I do this then?
Why not do something like:
@values = grep(/whatever/, readdir(DIR));
For example, if you want all the files ending with .html [ducking!] from
a certain directory you might do:
opendir(DIR, "$dirname");
@matches = grep(/\.html$/, readdir(DIR));
closedir(DIR);
HTH!
--
Nathan V. Patwardhan
nvp@shore.net
"[news:alt.fan.jwz]"
------------------------------
Date: 17 Feb 1997 02:16:32 GMT
From: KMAGLOUGHLIN@delphi.com
Subject: Compiling Perl on UnixWare
Message-Id: <5e8f20$ath@news2.delphi.com>
But the problem is, the freebird version puts the package in /opt rather than
/usr/local/. Can this be reworked to be put in /usr/local/ like everyone
else? This would make adding packages like tkperl and linking everything
together much easer due to tk, tcl and expect already being there in /usr/local.
Also, related issue, is there a tkperl package ready for Unixware? If so,
where?
Quoting tma from a message in comp.lang.perl.misc
>david.getchell@paonline.com (David Getchell) writes:
>>I am having a hard time getting Perl to compile on UnixWare 2.1. The
>>version of Perl is 5.003. It fails several of the tests during the
>>self-check. I also was unable to use dynamic loading. Suggestions?
>Why bother ? It has been done on www.freebird.org://..///utils/
>--
>Thanh Ma
>tma@encore.com
>.
The only that stays the same is change. - Melissa Etheredge
------------------------------
Date: 17 Feb 1997 05:34:10 GMT
From: malvarez@ix.netcom.com (Mike Alvarez)
Subject: Help on Perl5.003 on Aix 4.2
Message-Id: <5e8qki$444@dfw-ixnews11.ix.netcom.com>
Hello everyone. I've encountered problems during the make process of ver.
5.003 on AIx 4.2. The make dies on a module called toke.c. Has anyone
compiled this version of perl on 4.2 of AIX? Any help will greatly be
appreciated. I also welcome e-mail responses at malvarez@isinet.com. Thank
you all in advance.
------------------------------
Date: 16 Feb 1997 19:50:20 -0500
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: HELP: a newbie question
Message-Id: <x0lo8o45o3.fsf@tbone.biol.sc.edu>
tom <shiu@lis.pitt.edu> writes:
> I'm new to Perl and looking for someone who can help me out. I got a
> program called "simulate" which runs with two args(input_file and
> output_file) and need to run it 10 times. Here is my shell script :
>
> #!/bin/sh
> for i in 1 2 3 4 5 6 7 8 9 10
> do
> echo 10,$i,30 > input_file
> simulate input_file output_file
> done
>
> This script runs well. Now I want to rewrite it by Perl and couldn't
> find a way to do it by browsing the book "Programming Perl". My
> question is how to execute my program ? I know `command` can be
> executed under Perl, but it didn't work for my case `simulate input_file
> output_file`. I did try two simple lines such as @out=`ls`; print
> @out;, and it did execute and print all the files in the current
> directory. Can anyone tell me how to execute my program?
>
> Thanks for any help,
The glib answer is as follows... Suppose that shell script is named
"dosimulate.sh". You could run it using the following program in
Perl:
#!/usr/local/bin/perl -w
use strict;
system("dosimulate.sh");
Actually, that's not such a bad idea. If it runs, and does what you
want, why take a chance of breaking it?
But if you wanted it embedded into a larger Perl program for example,
my first pass at it might be something like (warning: untested code follows):
#!/usr/local/bin/perl -w
use strict;
for (1 .. 10) {
open(IN, "> input_file") || die("Failed to open input_file");
print IN "10,$_,30\n";
close IN;
system("simulate input_file output_file");
}
Hope that's helpful!
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org> WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83 A0 BF CB C0 D1 0E 76 C0
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"
------------------------------
Date: Sun, 16 Feb 1997 20:46:50 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: HELP: a newbie question
Message-Id: <qqg8e5.vs3.ln@localhost>
tom (shiu@lis.pitt.edu) wrote:
First, please put a subject in your Subject: (there is an article
posted here regularly about how to choose a Subject that won't
be ignored by most folks)
Everybody wants "HELP" here (you don't need to shout at us either).
"newbie" adds no useful information, you could just leave that out.
Everybody has a "question" here too.
See? We cannot tell what the subject of your post is from scanning
the Subject: header that you provided.
I do not have time to read all the posts to c.l.p.m. I only read
about 25-50% of them. How do I eliminate the other 50-75%? By
reading the Subject: header.
If I can't even determine _what_ the subject is, then they also
get skipped. Must be bored tonight to have even read this one...
Subject: how to run external programs
would have been soooo much better...
: I'm new to Perl and looking for someone who can help me out. I got a
: program called "simulate" which runs with two args(input_file and
: output_file) and need to run it 10 times. Here is my shell script :
: #!/bin/sh
: for i in 1 2 3 4 5 6 7 8 9 10
: do
: echo 10,$i,30 > input_file
: simulate input_file output_file
: done
: This script runs well. Now I want to rewrite it by Perl and couldn't
: find a way to do it by browsing the book "Programming Perl". My
^^^^^^^^^^^^^^^^
: question is how to execute my program ? I know `command` can be
^^^^^^^
When I look up 'execute' in the index I see "executing other programs
from Perl", it points to pg 230 which has the answer to your question.
Are you, perchance, stuck with the first edition?
: executed under Perl, but it didn't work for my case `simulate input_file
^^^^^^^^^^^
Come on man! Are we supposed to know what you mean by this?
dumped core
hung forever
appeared to do nothing
ran but didn't do what you wanted (tell what you _did_ want then)
got error message (tell us the error message text)
got syntax error message
got operating system error message
I would call any of the above "didn't work"...
Where's the code that 'didn't work'? Awful hard for us to troubleshoot
your code when we can't see it...
: output_file`. I did try two simple lines such as @out=`ls`; print
: @out;, and it did execute and print all the files in the current
: directory. Can anyone tell me how to execute my program?
: Thanks for any help,
Now that my griping is over, I'll get to answering your question ;-)
man perlfunc search for 'system LIST'
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 14 Feb 1997 13:47:44 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: HOW TO SPLIT A SIMPLE STRING
Message-Id: <fl_aggie-ya02408000R1402971347440001@news.fsu.edu>
In article <5e254b$to6$1@news.nyu.edu>, donahue@acf2.nyu.edu (Adam M.
Donahue) wrote:
+I have a a six character string,
+ say 012345, that I want to split into three variables, $one, $two, $three
+ that would then have 01, 23, 45. The original string has no
+ delimiters, though.
+ What's the best way to do this? It seems like an easy task, but I can't
+ figure it out.
$var1=substr($string,0,2);
$var2=substr($string,2,2);
$var3=substr($string,4,2);
?? This presumes that you'll only have a 6 character string...
James - which may be good, may be bad, may be indifferent
--
Consulting Minster for Consultants, DNRC
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 16 Feb 1997 19:55:00 -0500
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: Learning perl from scratch
Message-Id: <x0k9o845gb.fsf@tbone.biol.sc.edu>
posenj@lancet.co.za (Kevin Posen) writes: I've recently started to
> learn Perl using an HTML manual that I received with the Perl5 .zip
> file (it contains perl.html, perltoc.html, perldata.html, etc.). The
> problem is that, although I have been programming for about 5 years,
> I have only used Pascal and BASIC for DOS -- never Unix, sed, awk or
> C. The manual assumes a fair amount of background from those and so
> I have run into many incomplete explanations and I'm finding it very
> difficult to follow the manual.
>
> Does anyone know of a manual that would be better? Or can anyone
> suggest a route/method for me to go about learning it more easily?
>
> (One of the things I'm having trouble on is why does
> /^\d+$/;
> check if something is a whole number?)
>
> Thanks a lot.
Run, don't walk, to your local technical bookstore and buy the
following two books:
Schwartz, R.L. 1993. Learning Perl. O'Reilly & Associates.
Wall, L., Christiansen, T., and Schwartz, R.L. 1996. Programming
Perl. O'Reilly & Associates.
Alternately, visit O'Reilly at <URL:http://www.ora.com>. These books
are written by people who wrote the Perl language, and who make a
living by teaching it. They're good. The first is a warm'n'fuzzy
tutorial (uh, well, kind of), and the second is The Standard Reference
(you'll recognize a lot of it (but not all, by any means) from the
standard documentation).
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org> WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83 A0 BF CB C0 D1 0E 76 C0
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"
------------------------------
Date: 16 Feb 1997 23:21:12 -0500
From: Roderick Schertler <roderick@gate.net>
To: Chris Vo <chrisv@on.bell.ca>
Subject: Re: Perl question, re: POSIX setpgrp
Message-Id: <pzraigyshr.fsf@eeyore.ibcinc.com>
On Fri, 14 Feb 1997 16:31:53 GMT, Chris Vo <chrisv@on.bell.ca> said:
>
>>> POSIX setpgrp can't take an argument at ./check_ntp line 21.
>
> where line 21 reads as:
> setpgrp (0, $$);
Replace that with just
setpgrp;
This does the same thing and will work on all systems.
I think there's a bug here. Perl is expecting a pgrp arg of 0 to mean
$$, but it doesn't allow an explicit $$. Even this seems a little odd,
as on neither system I've got available at the moment is it mentioned
that a 0 pgrp means getpid() (they both mention that a 0 pid means
getpid(), though).
Porters, what do you think of this patch?
--- pp_sys.c.~1~ Thu Feb 13 17:00:55 1997
+++ pp_sys.c Sun Feb 16 23:13:49 1997
@@ -3048,7 +3048,7 @@
#ifdef BSD_GETPGRP
value = (I32)BSD_GETPGRP(pid);
#else
- if (pid != 0)
+ if (pid != 0 && pid != getpid()) {
DIE("POSIX getpgrp can't take an argument");
value = (I32)getpgrp();
#endif
@@ -3078,7 +3078,7 @@
#ifdef BSD_SETPGRP
SETi( BSD_SETPGRP(pid, pgrp) >= 0 );
#else
- if ((pgrp != 0) || (pid != 0)) {
+ if ((pgrp != 0 && pgrp != getpid())) || (pid != 0 && pid != getpid())) {
DIE("POSIX setpgrp can't take an argument");
}
SETi( setpgrp() >= 0 );
--
Roderick Schertler
roderick@gate.net
------------------------------
Date: 17 Feb 1997 03:34:16 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Pig Latin
Message-Id: <slrn5gfk8h.vu7.dave@fast.thomases.com>
On 16 Feb 1997 22:47:39 GMT, Greg Bacon <gbacon@cs.uah.edu> wrote:
> [Posted and mailed]
>
> In article <slrn5gf0sk.v4t.dave@fast.thomases.com>,
> dave@fast.thomases.com (Dave Thomas) writes:
> : Suddenly, regex is cheapest (I guess because its anchored,
>
> I hope you didn't get the impression that I was saying that my solution
> was in any way better than Chris's
> I come but to advocate open minded programming. :-)
Hell no - I guess I was just playing with your timings and was surprised to
see regex's come to the top of the heap under what I guess would be typical
circumstances. When I come across something counter-intuitive like that I
thought it might be interesting to post.
To be honest, I think that 99% of this talk of efficiency is misguided - if
we needed real-time performance, we wouldn't be hackin' Perl.(*) Whether a
comparison takes 200 or 300 microseconds makes not a jot of difference
unless you do it a million times. Mostly, its just fun to talk about :-)
Regards
Dave
(*) And before I start another thread on "Perl can be efficient, you moron",
let me in my defence say that I'm just coming to the end of a project where
we're trying to break records for a particular kind of data warehouse load,
writing the entire front-end in Perl (and Perl that generates Perl on the
fly). So far, we're doin' pretty good.
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 16 Feb 1997 22:28:42 -0500
From: William P Setzer <wsetzer@babylon5.unity.ncsu.edu>
Subject: Re: Problem with Curses and 5.003
Message-Id: <lzypvy0dsb9.fsf@babylon5.unity.ncsu.edu>
sstarr@skypoint.com (Susan Starr) writes:
:
: I would like to upgrade from perl 5.002 to perl 5.003. I compiled
: 5.003 but I can't get my programs that use curses to work with 5.003.
Extensions compiled for perl5.002 must be recompiled for perl5.003,
because the embed issue has changed. From INSTALL:
B<NOTE>: Starting with 5.002_01, all functions in the perl C source
code are protected by default by the prefix Perl_ (or perl_) so that
you may link with third-party libraries without fear of namespace
collisons. This breaks compatability with the initially released
version of 5.002, so once you install 5.002_01 (or higher) you will
need to re-build and install all of your dynamically loadable
extensions.
Hope this helps.
William
------------------------------
Date: Mon, 17 Feb 97 06:22:21 GMT
From: mark@markschneider.com (Mark Schneider)
Subject: problem writing to files
Message-Id: <5e8t5c$65n@news.interaccess.net>
I'm running into a problem I've never seen before while reading and
writing files in Perl. (My operating system is Solaris 2.5.)
My program reads in a sample file, replaces some text as it reads in
the file, and outputs the replaced text to another file. For some
reason:
(1) my program isn't writing to the output file until the
program ends (even though it reaches the "close" command much
before the program ends.
(2) although the input file ($generic_analog_Runstats_file) is less
than 1K, the output file is always 8K in size, and approximately
the last 7K is filled with what looks like chr$(0)
Has anyone else run into this problem? Where you able to fix it?
Some more observations:
When the program reaches the "open (SPECIFIC2..." command, it creates
the output file fine. However, if I pause the program when it reaches
the "sleep" command, I find that the file has 0 bytes. Furthermore,
the "ls -la" and "cat" lines produce no output to the screen.
Thanks for any help.
------------------------------- begin -----------------------------------
#!/usr/local/bin/perl
MAIN: {
# Set some variables for now
$website_runstats_file =
"/home/mas/public_html/My_Pages/Logs/runstats-test";
$generic_analog_Runstats_file =
"/usr/local/etc/httpd/analog/generic_Runstats";
$analog_directory = "/usr/local/etc/httpd/analog";
$analog_program = "/usr/local/etc/httpd/analog/analog";
$website_config_file = "www.whatever.com.cfg;
$stats_file = "Feb-97.html";
$title = "Server Statistics for Whatever.com";
# Done setting variables
open (GENERIC2, "< $generic_analog_Runstats_file") || die "\nERROR: Cannot
open $generic_analog_Runstats_file.\n";
open (SPECIFIC2, "> $website_runstats_file") || die "\nERROR: Cannot open
$website_runstats_file\nExiting program.\n";
while (<GENERIC2>) {
s/insert_analog_directory_here/$analog_directory/;
s/insert_analog_program_here/$analog_program/;
s/insert_server_config_file_here/$website_config_file/;
s/insert_stats_file_here/$stats_file/;
s/insert_title_here/$title/;
print SPECIFIC2;
}
close (<SPECIFIC2>);
close (<GENERIC2>);
sleep 5; # the op sys shouldn't need this much time to close the files.
print `ls -la /export/home/users/mas`; # why doesn't this line isn't
output anything to the console?
print "website_runstats_file = $website_runstats_file\n"; # just to make
sure this variable hasn't changed
open (GENERIC3, $website_runstats_file); # for some reason, this 3
while (<GENERIC3>) { print ; } # line routine doesn't
close (<GENERIC3>); # output anything
`cat $website_runstats_file`; # why doesn't this line output anything to
the console?
}
--------------------------------- end -----------------------------------
------------------------------
Date: 16 Feb 1997 22:24:38 -0500
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: PROGRAM: how to check for nice/valid email address
Message-Id: <x0eneg3yix.fsf@tbone.biol.sc.edu>
duplanti@enstb.enst-bretagne.fr (DUPLANTIER Bastien) writes:
> where could i get the Tom Christiansen's article about this subject?
> 'cause i'm a new news reader, so i can't get it...
>
> thank you for reply...
To save you the trouble: you can't. There is no way to check for the
validity of an email address except by sending the mail and seeing if
it gets there. No way. Email is store-and-forward by its very
nature, so there is no assurance that any "live" contact will tell you
anything. SMTP hosts lie about the existence of various login IDs
(for good security reasons). Systems bounce up and down. Sites may
be on the other end of bizarrely non-compliant email parsers that work
despite non-standard addressing.
Send the mail. Call the recipient. If it got there, it got there.
If not, it didn't.
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org> WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83 A0 BF CB C0 D1 0E 76 C0
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"
------------------------------
Date: Mon, 17 Feb 1997 02:45:33 +0100
From: Andre Pareis <pareis@cs.tu-berlin.de>
Subject: Q: int(1.0) = 0 ?????
Message-Id: <3307B83D.56EBD9DD@cs.tu-berlin.de>
Hi,
I've done some numeric calculations with perl 5.003.
Strange things happened with my numbers. Thus, I tried to figure out
what the int() function exactly does, using this very simple script:
#!/usr/bin/perl
$f = 0.1;
for( $i=0.0; $i <= 2.0; $i=$i+$f ) {
print "int(", $i, ") = ", int($i), "\n";
}
A run of perl with this script gives the following result:
int(0) = 0
int(0.1) = 0
int(0.2) = 0
int(0.3) = 0
int(0.4) = 0
int(0.5) = 0
int(0.6) = 0
int(0.7) = 0
int(0.8) = 0
int(0.9) = 0
int(1) = 0
int(1.1) = 1
int(1.2) = 1
int(1.3) = 1
int(1.4) = 1
int(1.5) = 1
int(1.6) = 1
int(1.7) = 1
int(1.8) = 1
int(1.9) = 1
The output is the same both on my Linux box at home and on a HP-UX
at work. Neither int(1) is calculated correct nor the loop does run
until $i is LARGER THAN 2.0, it stops when $i is 2.0.
Do I have to install a newer perl version? I used to use the latest
official release, no betas.
Thanx,
Andre
------------------------------
Date: 17 Feb 1997 03:42:41 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Q: int(1.0) = 0 ?????
Message-Id: <slrn5gfkoe.vu7.dave@fast.thomases.com>
On Mon, 17 Feb 1997 02:45:33 +0100, Andre Pareis <pareis@cs.tu-berlin.de> wrote:
> #!/usr/bin/perl
>
> $f = 0.1;
>
> for( $i=0.0; $i <= 2.0; $i=$i+$f ) {
> print "int(", $i, ") = ", int($i), "\n";
> }
...
> int(1) = 0
0.1 is not directly epressable as a binary fraction, so .1 * 10 is not quite
exactly one. If you run the following instead:
#!/usr/bin/perl
$f = 0.1;
for( $i=0.0; $i <= 2.0; $i=$i+$f ) {
printf "int(%1.20lf) = %d\n", $i, int($i);
}
You'll get:
...
int(0.89999999999999991118) = 0
int(0.99999999999999988898) = 0 #<<-- this was your int(1)=0
int(1.09999999999999986677) = 1
int(1.19999999999999995559) = 1
int(1.30000000000000004441) = 1
...
Ah-ha! Mystery explained.
Actually, if you had an older version of Perl, you probably wouldn't have
got the rounding you see, so this would have been more apparent.
This is why its always dangerous to use floating point numbers for
calculations wher you need fixed decimal accuracy.
Regards
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Mon, 17 Feb 1997 03:12:32 GMT
From: reynolds-j@mindspring.com (Jim Reynolds)
Subject: Re: s/// Quesiton
Message-Id: <3307caf8.57221519@news.mindspring.com>
kompas@galaxy.uci.agh.edu.pl (Piotr Piatkowski) wrote:
>Jim Reynolds <reynolds-j@mindspring.com> wrote:
>: I am trying to do the following string conversion and am stuck.
>: Thank You in advance!
>
>: I would like to use the s/// function to covert the string:
>: [link=http://www.foo.com/]
>
>: to...
>
>: <a href="http://www.foo.com/">http://www.foo.com/</a>
>
>s!\[link=(.*?)\]!<a href="$1">$1</a>!
>
>So what was your problem?
>
>--
>Piotr Pi1tkowski, Uczelniane Centrum Informatyki, AGH Krakow, POLAND
That didn't help. >So what was your problem? Nice Person
Somebody else.
I got this far...
s/\[link=(.*)\]/<a href="$1">$1<\/a>/ig;
but this only changes the first occurance in the string...
What if the string has more than one occurrance like:
$ln = "[link=http://foo.com/] Text here [link=http://faa.net/]";
The above
(s/\[link=(.*)\]/<a href="$1">$1<\/a>/ig;)
only changes the first link????
Help on changing the string to:
<a href="http://foo.com/">http://foo.com/</a> Text Here <a
href="http://faa.net">http://faa.net/</a>
------------------------------
Date: Mon, 17 Feb 1997 08:22:02 +0200
From: Marten Mickos <marten.mickos@solidtech.com>
Subject: Re: Searching for Perl-supported Linux database
Message-Id: <3307F90A.685D@solidtech.com>
Chris Schoenfeld wrote:
>
> I'm in the market for a database with the following features:
>
> 1. Native Linux and Spac Solaris support (i.e. share binary db's).
> 2. A thoroughly tested Perl 5 module interface.
> 3. Speedy, for CGI work.
> 4. Either commercial or well-supported PD.
> 5. Native file/record locking.
>
Try out SOLID Server at
http://www.solidtech.com
Runs on Linux, Solaris, and more.
Perl info at
http://www.solidtech.com/market/products/web/3rdparty.htm
Fast.
Commercial.
Database files are binary compatible across platforms.
Marten Mickos
Solid Information Technology Ltd
------------------------------
Date: 17 Feb 1997 01:17:50 GMT
From: handtran@kabuki.EECS.Berkeley.EDU (Philip Chen)
Subject: undump binary for solaris
Message-Id: <5e8bju$biu@agate.berkeley.edu>
Does anyone know where I can find undump binary for solaris?
undump turns core dumps into executables. Please copy me
via email. Thanks in advance.
--
________ __ __
/_ __/ / ___ ____ / /__ ___ / /
/ / / _ \/ _ `/ _ \/ '_/(_-</_/
/_/ /_//_/\_,_/_//_/_/\_\/___(_)
------------------------------
Date: Sun, 16 Feb 1997 16:23:15 -0800
From: Bo Graham <bgraham@bgraham.com>
Subject: Re: using sendmail
Message-Id: <3307A4F3.3CD4@bgraham.com>
I'd love to know what *will* work on NT Neil. Please send me that pm If
you don't mind.
Neil S. Briscoe wrote:
>
> In article <33003678.E86@student.tuwien.ac.at>,
> e8726057@student.tuwien.ac.at (Klaus Johannes Rusch) wrote:
>
> > Sean W. Ellis wrote:
> >
> > > B: Will not be on the NT system the page will eventually end up on.
> > > I need to take information and send an email or save this information
> > > to a file to be downloaded.
> > >
> > > I would rather have the email, how do I implement with something other
> > > than sendmail or how do I implement on NT server?
> >
> > Probably a good question on a Windows NT newsgroup [FUP to
> > comp.os.ms-windows.nt.misc], as this is not at all related to Perl,
> > unless you intend to re-implement sendmail for Windows NT.
> >
>
> Its related to Perl if the script is written in Perl. Don't talk sendmail
> - talk SMTP. As you're on NT, you'll need my ugly, but functional, hack
> of the smtp.pm module - which doesn't [yet] work under NT. Just send me
> a request and I'll chuck it right back at you.
>
> Oh, my hack is an smtp.pl perl library - and it works just fine under the
> effected patient. ;-))
>
> Regards
> Neil
Thanks,
Bo Graham
http://bgraham.com
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 V7 Issue 961
*************************************