[17629] in Perl-Users-Digest
Perl-Users Digest, Issue: 5049 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 6 18:16:54 2000
Date: Wed, 6 Dec 2000 15:10:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976144218-v9-i5049@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 6 Dec 2000 Volume: 9 Number: 5049
Today's topics:
How to insert Perl Code inside E-mail text? <alaghaout@trentu.ca>
Re: How to insert Perl Code inside E-mail text? WA Support
Re: How to read files from the end? dtbaker_dejanews@my-deja.com
Re: How to set the write permission of Perlscript <bujuzu@crosswinds.net>
Re: Lost in a sea of obfuscation... <elijah@workspot.net>
Re: perl & graphics <bujuzu@crosswinds.net>
Re: perl & graphics dtbaker_dejanews@my-deja.com
Re: PERL based Web Application Servers dtbaker_dejanews@my-deja.com
Perl SQL Array <support@REMOVEdotmatrix.net>
Re: Perl SQL Array <dontspamme@awdang.com>
Re: Perl SQL Array <jeff@vpservices.com>
Re: perl under win98 but no win98 directory. <mischief@velma.motion.net>
Re: Problem with warn,next,if combinations (Anno Siegel)
Re: Problem with warn,next,if combinations (Abigail)
Re: Problem with warn,next,if combinations (Anno Siegel)
Re: Reading Data from STDIN <crowj@aol.com>
Re: Reading Data from STDIN <william.c.nelson@gte.net>
Re: Reading Data from STDIN <crowj@aol.com>
Re: regex, s and m, dice and elephants (Tad McClellan)
Re: rounding to nearest thousand <mike@a2zcables.com>
Re: rounding to nearest thousand <t.geffert@gmx.de>
Re: rounding to nearest thousand <mike@a2zcables.com>
Re: rounding to nearest thousand <dperham@dperham.eng.tvol.net>
Re: Submitting a file via a form <jeff@yoak.com>
Re: substituting a hash value with a regex? <david.kernen@bms.com>
Re: substituting a hash value with a regex? (Tad McClellan)
Re: syscall.h missing on AIX (Jens-Uwe Mager)
XML::Parser/XML::Parser::Expat swaroop@mediaone.net
Re: XML::Parser/XML::Parser::Expat <jeff@vpservices.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 6 Dec 2000 20:06:44 GMT
From: Amine Laghaout <alaghaout@trentu.ca>
Subject: How to insert Perl Code inside E-mail text?
Message-Id: <3A2E9C54.668480FB@trentu.ca>
Hi everyone,
I have a dumb question:
I have an e-mailing program which works this way:
------------------------------------------
open(MAIL, "|$MAIL_PROG");
print MAIL <<"(END MAIL)";
From: someone\@trentu.ca
To: $instruct_mail
Subject: Subject
Reply-To: someone\@trentu.ca
BLABLABLA, here goes the message...
(END MAIL)
close MAIL;
------------------------------------------
Here is what I would like to do: write a while loop inside the BLABLA
message to print out a list stored in a *.csv file. It does not
work... Is there another way to have some Perl code inside there?
Is it possible to write a message into a file and send that file via
e-mail? Hope you guys can help... I am gonna be fired I cannot do it
:)
------------------------------
Date: Wed, 06 Dec 2000 22:37:50 GMT
From: WA Support
Subject: Re: How to insert Perl Code inside E-mail text?
Message-Id: <3a2eb9e7.2956448998@news.wildapache.net>
Example using sendmail:
$someone = "Sally";
$someoneelse = "Joan";
$leadin_message = "
Dear $someone,
Whatever you want to say before information in cvs file.
";
$leadout_message = "
Whatever you want to say after information in cvs file.
";
open(INFILE, "+</path/to/.cvs/file");
open (MAIL, "|/bin/sendmail\"$someone\"\@foobear.com");
print MAIL "TO: \"$someone\"\@foobear.com\n";
print MAIL "FROM: $someoneelse\@foo.com (*** Whatever ***)\n";
print MAIL "SUBJECT: Whatever\n\n";
print MAIL "$leadin_message\n";
while (<INFILE>) {
print MAIL "$_\n";
}
print MAIL "$leadout_message\n";
close(MAIL);
close(INFILE);
On Wed, 6 Dec 2000 20:06:44 GMT, Amine Laghaout <alaghaout@trentu.ca>
wrote:
>Hi everyone,
>
>I have a dumb question:
>
>I have an e-mailing program which works this way:
>------------------------------------------
> open(MAIL, "|$MAIL_PROG");
>print MAIL <<"(END MAIL)";
>From: someone\@trentu.ca
>To: $instruct_mail
>Subject: Subject
>Reply-To: someone\@trentu.ca
>
>BLABLABLA, here goes the message...
>
>
>(END MAIL)
> close MAIL;
>------------------------------------------
>
>Here is what I would like to do: write a while loop inside the BLABLA
>message to print out a list stored in a *.csv file. It does not
>work... Is there another way to have some Perl code inside there?
>Is it possible to write a message into a file and send that file via
>e-mail? Hope you guys can help... I am gonna be fired I cannot do it
>:)
------------------------------
Date: Wed, 06 Dec 2000 22:21:44 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: How to read files from the end?
Message-Id: <90me5g$1cb$1@nnrp1.deja.com>
In article <3a2e37f0@news.cc.umr.edu>,
"LimboStar" <dontspamme@awdang.com> wrote:
> "Lucas" <wstsoi@hongkong.com> wrote...
> >
> > For some reasons, I need to read some recent logs from the log
> > files, how could I read the logs from the end of file, but not the
> > start?
>
> local *FILE;
> open( FILE, $filename );
> seek( FILE, -500, 2 ); # 500 bytes before EOF
> my @lines = <FILE>;
----------------------------
that last line would take quite a chunk of memory with a large file!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 06 Dec 2000 19:29:32 GMT
From: "Timothy J. Benson" <bujuzu@crosswinds.net>
Subject: Re: How to set the write permission of Perlscript
Message-Id: <wswX5.42436$II2.3823757@newsread2.prod.itd.earthlink.net>
Since its on IIS, I'm assuming you're using activeperl. Double-check what
you're mapping the (.pl/.cgi/.whatever) extentions to on the webserver. In
the past I've had file write problems with perl.exe and ended up switching
to perlIS.dll... (or is it the other way around?)
Either way, give it a try.
Tim Benson
<u8526505@ms27.hinet.net> wrote in message
news:90ksj8$e4a@netnews.hinet.net...
> My PerlScript works fine with my IIS 5 except that I can't write
files.I've
> tried VBScript and it was ok so it wasn't the matter of the permission of
> folders.Thanks for help.
>
> Roy
------------------------------
Date: 6 Dec 2000 20:39:58 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Lost in a sea of obfuscation...
Message-Id: <eli$0012061523@qz.little-neck.ny.us>
In comp.lang.perl.misc, Ryan Joseph <perl_man@ryanjoseph.com> wrote:
> Here is my dillema - I really want to write a JAPH, yet I have no clue how
> to go about this. Is there any stratigies, tips, techniques, or magic tricks
> I should know about before I delve into the confusing world of obfuscation,
> or should I just pound on my keyboard, save and run it and see what happens?
Well, my recent tact has been to find perl features and then say, how
can I write a JAPH with this? Thus was born a whole bunch, like:
Inline::C module:
use Inline C=>qq<#include <string.h>\nSV*japh(){char*JAPH="Just Another>
.qq< Perl Hacker\\n";return newSVpv(JAPH,strlen(JAPH)+1);}>;print japh()
X11::Protocol module:
use X11::Protocol;$X=new X11::Protocol;END{$X->FreeGC($G);undef$X}map{$$_=$X->
new_rsrc}(W,F,G);$X->event_handler('queue');$X->CreateWindow($W,$X->root,'Inp'
.'utOutput',$D=$X->root_depth,'CopyFromParent',(0,0),300,30,4,'event_mask',01,
background_pixel=>2**$D-1);$X->CreateGC($G,$W);$X->MapWindow($W);$X->PolyText8
($W,$G,25,28,[0,'Eli the Bearded:Just Another Perl Hacker']);$X->handle_input;
Filter::sh module:
perl <<'JAPH'
use Filter::sh 'perl -pey:*-r:A-~:+s/.*/print\"\$\&\"/s';
3^\] *WX]QN[ 9N[U 1JLTN[
JAPH
charnames module:
perl -Mcharnames=latin -le'print"\N{J}\N{u}\N{s}\N{t} \N{A}\N{n}\N{o}\N{t}".
"\N{t}\N{h}\N{e}\N{r} \N{P}\N{e}\N{r}\N{l} \N{H}\N{a}\N{c}\N{k}\N{e}\N{r}\n"
Sometimes it seems like Abigail uses a similar method, scanning
perldelta or the like for ideas.
Elijah
------
had a lot of trouble getting japh.X down to five lines
------------------------------
Date: Wed, 06 Dec 2000 19:23:03 GMT
From: "Timothy J. Benson" <bujuzu@crosswinds.net>
Subject: Re: perl & graphics
Message-Id: <rmwX5.42425$II2.3813719@newsread2.prod.itd.earthlink.net>
I've seen turnkey solutions for sale, but they are all essentially
manipulating the gd.pm
module. However, if you don't want to do any programming there are, like i
said, plenty of cgis out there that will do what you need.
Tim
"Lex Thoonen" <nospam_Lex@peng.nl> wrote in message
news:R3vX5.93788$Ae1.1280374@zwoll1.home.nl...
> Hi,
>
> I'm a non-programmer, but I've managed to get some scripts to work
together
> and what they do is this: from a (flatfile) database webpages are built,
and
> the database is easy to maintain online.
>
> Graphics are uploaded easily and they are given the correct names etc.
>
> My question:
>
> If somebody uploads a .jpg file, I need as well a thumbnail of it. Until
> today, I've instructed clients on how to make a thumbnail, because when
you
> do this via html, you do not really make the image smaller, only show it
> smaller. Is there a way (with perl) to really copy the image and make (the
> copy) smaller? If so, could you tell me how or where I can find details?
>
> Thanks for reading,
>
>
> Lex
> http://www.peng.nl/index-peng.html
>
>
>
------------------------------
Date: Wed, 06 Dec 2000 20:36:36 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: perl & graphics
Message-Id: <90m80k$rme$1@nnrp1.deja.com>
In article <R3vX5.93788$Ae1.1280374@zwoll1.home.nl>,
"Lex Thoonen" <nospam_Lex@peng.nl> wrote:
> If somebody uploads a .jpg file, I need as well a thumbnail of it.
-----------
The module Image::Magick does a good job of this. The Scale() function
is probably what you want. The module is a bit of a trick to install
though... There have been several detailed threads on how to do so on
comp.lang.perl.modules
There are a couple other modules out there on CPAN like GD and Imager
which may work for you too.
Dan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 06 Dec 2000 22:24:35 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: PERL based Web Application Servers
Message-Id: <90meaq$1e3$1@nnrp1.deja.com>
In article <3A2E60D0.D87466A9@yahoo.com>,
Al Dev <alavoor@yahoo.com> wrote:
> Can you recommed any PERL based Web Application Servers.
> I am planning to use PERL on linux.
-----------
why do you care what the server is written with?
D
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 6 Dec 2000 15:31:45 -0600
From: "T Hawk" <support@REMOVEdotmatrix.net>
Subject: Perl SQL Array
Message-Id: <t2tc4r3eqkqc51@corp.supernews.com>
Im just getting into using a MySQL database for my scripts. I have run into
a big problem though. I have a table with about 5 columns. I need to take
the column named "names" and put all of the contents into an array. Can
someone post an example of how this can be done?
Thanks in advance!
------------------------------
Date: Wed, 6 Dec 2000 15:34:30 -0600
From: "LimboStar" <dontspamme@awdang.com>
Subject: Re: Perl SQL Array
Message-Id: <3a2eb6cc@news.cc.umr.edu>
"T Hawk" <support@REMOVEdotmatrix.net> wrote...
>
> I'm just getting into using a MySQL database for my scripts.
> I have run into a big problem though. I have a table with
> about 5 columns. I need to take the column named "names"
> and put all of the contents into an array. Can someone post
> an example of how this can be done?
use DBI;
my $dbh = DBI->connect('...','...','...');
my $cur = $dbh->prepare('SELECT names FROM table;');
my @names = ();
$cur->execute();
while (my ($name) = $cur->fetchrow()) { push( @names, $name ); }
$cur->finish();
In general, pushing all of the data into an array is a bad idea though. The
beauty of using the DBI is that it has a low memory footprint - you can
iterate over the list and it doesn't cost much processor time or memory. I
can't really think of any applications offhand that require the list to be
read into memory all at once. Maybe if you needed to do several passes
through it it might be necessary, but even then, for large data sets, it's
wiser to structure your code to handle the iteration.
HTH,
--sjd;
------------------------------
Date: Wed, 06 Dec 2000 14:09:12 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl SQL Array
Message-Id: <3A2EB908.D446B6C5@vpservices.com>
T Hawk wrote:
>
> Im just getting into using a MySQL database for my scripts. I have run into
> a big problem though. I have a table with about 5 columns. I need to take
> the column named "names" and put all of the contents into an array. Can
> someone post an example of how this can be done?
I assume you are using DBI, if not, you should be. With DBI, it's done
like this:
my @array = @{ $dbh->selectcol_arrayref(
"SELECT $colname FROM $tablename"
) };
--
Jeff
------------------------------
Date: Wed, 06 Dec 2000 22:00:29 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: perl under win98 but no win98 directory.
Message-Id: <t2tdnt2rbo5508@corp.supernews.com>
Michael J. Habashy <mjh@servicebidders.com> wrote:
> Can anyone helpp...please...looking for a way to run perl script on a
> machine that is formated with win98 but does not have win98 on it. The DOS
> 5.0 perl that I have seems to blow up..for no reason...can anyone help..can
> I compile this script into an executable..? or something like that?
You can't use DOS on a partition that is formatted using FAT32.
There's a good chance you can't use Perl for DOS on a partition
formatted using FAT32. Many of the library functions for Perl
operate on the file system. I'm not sure if in your port they
use direct access or DOS calls, but either one will expect to
find FAT16 (or FAT12, since anything that works on FAT16 should
also work on FAT12, but this is pretty much moot).
If the Perl system is expecting to manipulate FAT16 and tries
to manipulate FAT32, then I'm sure it would blow up. This would
be caused by making the wrong calls if it calls anything to do
its file system work or by doing the wrong thing itself if it
accesses the disk directly.
There are Perl versions for Win9x platforms, and there are Perl
versions for DOS. You could probably get away with running a
DOS version on Win9x, since it will stick it in a virtual machine
of sorts. Running a DOS program on top of a Win9x file system
using a DOS command interpreter and system files is a bad idea
anyway.
You would at least have to have the Win9x versions of command.com
and io.sys to be able to run in command line mode on Win9x and be
able to use the file system. My guess is this is what you are
really doing. If the Perl interpreter is trying to access FAT16
itself instead of asking the DOS API (okay, the published DOS
interrupts that act as an API) for help, this could be your
problem still.
If Ilya is reading this, maybe we could get more light shed on
how at least the official DOs ports work.
Chris
--
Christopher E. Stith - mischief@velma.motion.net
"Carpe noctum."
------------------------------
Date: 6 Dec 2000 19:19:52 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem with warn,next,if combinations
Message-Id: <90m3go$56l$1@lublin.zrz.tu-berlin.de>
Warren L Dodge <warren.dodge@tektronix.com> wrote in comp.lang.perl.misc:
>I have the following script which does not act the way I thought it would.
>
>The second foreach loop does not print the warning message but it does do the
>next.
>
>Email is best for me as far as answers.
Nope. Ask here, read here.
[...]
> warn " $where skipping file that does not exist: $file\n",next if ( ! -f
>"$file" );
Before the warn() is executed, its operands are evaluated. But next
immediately transfers control back to the loop conditional, so warn()
never gets a chance, just *because* "next" is executed.
Why would you want to put whatever "next if ! -f $file" returns into
the warning message? Note that I have written the statement with a
little less punctuation.
Anno
------------------------------
Date: 6 Dec 2000 20:15:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Problem with warn,next,if combinations
Message-Id: <slrn92t7j4.80s.abigail@tsathoggua.rlyeh.net>
On 6 Dec 2000 19:19:52 -0000, Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote in comp.lang.perl.misc <URL: news:<90m3go$56l$1@lublin.zrz.tu-berlin.de>>:
++ Warren L Dodge <warren.dodge@tektronix.com> wrote in comp.lang.perl.misc:
++
++ >I have the following script which does not act the way I thought it would.
++ >
++ >The second foreach loop does not print the warning message but it does do the
++ >next.
++ >
++ >Email is best for me as far as answers.
++
++ Nope. Ask here, read here.
++
++ [...]
++
++ > warn " $where skipping file that does not exist: $file\n",next if ( ! -f
++ >"$file" );
++
++ Before the warn() is executed, its operands are evaluated. But next
++ immediately transfers control back to the loop conditional, so warn()
++ never gets a chance, just *because* "next" is executed.
++
++ Why would you want to put whatever "next if ! -f $file" returns into
++ the warning message? Note that I have written the statement with a
++ little less punctuation.
Eh, what's the statement "next if ! -f $file" got to do with it?
Warren's statement is to be parsed as:
warn (" $where ... exist: $file\n", next) if (! -f $file);
The return value of next is an argument to warn, not "next if -f $file",
because that's a statement, not an expression.
Abigail
--
perl -wle 'for (qw /Just another Perl Hacker/) {print; next, last and redo}'
------------------------------
Date: 6 Dec 2000 21:41:34 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem with warn,next,if combinations
Message-Id: <90mbqe$5ec$1@lublin.zrz.tu-berlin.de>
Abigail <abigail@foad.org> wrote in comp.lang.perl.misc:
>Eh, what's the statement "next if ! -f $file" got to do with it?
>Warren's statement is to be parsed as:
>
> warn (" $where ... exist: $file\n", next) if (! -f $file);
>
>The return value of next is an argument to warn, not "next if -f $file",
>because that's a statement, not an expression.
True, that's the only way the (originally unparenthesized) statement
makes sense, and B::Deparse confirms.
Anno
------------------------------
Date: Wed, 06 Dec 2000 16:00:39 -0500
From: John Crowley <crowj@aol.com>
Subject: Re: Reading Data from STDIN
Message-Id: <3A2EA8F7.48EE306@aol.com>
Bill Nelson wrote:
>
> If I do not know how big data coming in from STDIN is, how can I use the
> read() command (or other similar command) to get the data from STDIN?
>
> Note: I cannot use a while(<>) or @array = <STDIN> because I do not see
> end of file in the data.
>
> I am passing data from a web page form to a port on a server which is
> not running a web server. I have a perl script read the data from STDIN
> and this is where I am having problems. If I specify a length of that
> data I can read it just fine. Problem is that I do not know the length
> of the data so I cannot do this accurately.
>
> any help would be most appreciated!
>
> thanks,
>
> bill nelson
If you don't send the size of the data or an EOF, then how will any
receiving program no it has all it was supposed to receive?
Solution: send length or EOF.
------------------------------
Date: Wed, 06 Dec 2000 21:44:10 GMT
From: Bill Nelson <william.c.nelson@gte.net>
Subject: Re: Reading Data from STDIN
Message-Id: <3A2EB28E.8ECEBC11@gte.net>
Blame Internet browsers. I am doing a POST (or even a GET) to a particular
port on the server. There is nothing in the data that indicates eof() -
believe me, I check of eof(). The length of the data is, indeed, specified
in the header of the packet, but you never know how big the header is going
to be. Therefore I cannot key off of data in the header.
The fun part is that I try specifying a length of the read that I know will
be greater than anything the user could have inputted and the script sits
there waiting for additional data from STDIN.
Believe me, I wish this were as easy as you recommend.
bill
John Crowley wrote:
> Bill Nelson wrote:
> >
> > If I do not know how big data coming in from STDIN is, how can I use the
> > read() command (or other similar command) to get the data from STDIN?
> >
> > Note: I cannot use a while(<>) or @array = <STDIN> because I do not see
> > end of file in the data.
> >
> > I am passing data from a web page form to a port on a server which is
> > not running a web server. I have a perl script read the data from STDIN
> > and this is where I am having problems. If I specify a length of that
> > data I can read it just fine. Problem is that I do not know the length
> > of the data so I cannot do this accurately.
> >
> > any help would be most appreciated!
> >
> > thanks,
> >
> > bill nelson
>
> If you don't send the size of the data or an EOF, then how will any
> receiving program no it has all it was supposed to receive?
>
> Solution: send length or EOF.
------------------------------
Date: Wed, 06 Dec 2000 17:24:22 -0500
From: John Crowley <crowj@aol.com>
Subject: Re: Reading Data from STDIN
Message-Id: <3A2EBC96.4DD8BBDE@aol.com>
Bill Nelson wrote:
>
> Blame Internet browsers. I am doing a POST (or even a GET) to a particular
> port on the server. There is nothing in the data that indicates eof() -
> believe me, I check of eof(). The length of the data is, indeed, specified
> in the header of the packet, but you never know how big the header is going
> to be. Therefore I cannot key off of data in the header.
>
> The fun part is that I try specifying a length of the read that I know will
> be greater than anything the user could have inputted and the script sits
> there waiting for additional data from STDIN.
>
> Believe me, I wish this were as easy as you recommend.
>
> bill
>
> John Crowley wrote:
>
> > Bill Nelson wrote:
> > >
> > > If I do not know how big data coming in from STDIN is, how can I use the
> > > read() command (or other similar command) to get the data from STDIN?
> > >
> > > Note: I cannot use a while(<>) or @array = <STDIN> because I do not see
> > > end of file in the data.
> > >
> > > I am passing data from a web page form to a port on a server which is
> > > not running a web server. I have a perl script read the data from STDIN
> > > and this is where I am having problems. If I specify a length of that
> > > data I can read it just fine. Problem is that I do not know the length
> > > of the data so I cannot do this accurately.
> > >
> > > any help would be most appreciated!
> > >
> > > thanks,
> > >
> > > bill nelson
> >
> > If you don't send the size of the data or an EOF, then how will any
> > receiving program no it has all it was supposed to receive?
> >
> > Solution: send length or EOF.
Browsers should be sending data using HTTP. Are you conforming to
that protocol for data receipts? Take a look at the HTTP RFC's at
www.w3.org. I also think there are some HTTP server-oriented
modules on CPAN.
------------------------------
Date: Wed, 6 Dec 2000 15:22:20 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: regex, s and m, dice and elephants
Message-Id: <slrn92t7vs.qf6.tadmc@magna.metronet.com>
Please do not send stealth Cc'd email, it can get you killfiled.
Anthony Bouvier <anthony@notsoevil.com> wrote:
>you know, actually, after running that code (thought it does work), the result
>set is the larger than it should be. Example
"result set"?
Most people would call that thingie "a string".
>$message =~ s#//roll (\d{1,2} \d{1,2})#&RollDice($1)#ge;
We cannot troubleshoot &RollDice if we are not given the
code that implements &RollDice.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 06 Dec 2000 19:10:25 GMT
From: Mike Gardner <mike@a2zcables.com>
Subject: Re: rounding to nearest thousand
Message-Id: <3A2E9267.E25772AB@a2zcables.com>
I'm sorry, it wasn't very clear.
I have a value being generated like 1624. I want it to always round up to the
nearest hundred (ignore thousand, i'm on crack today). So it will always round
up to the nearest hundred. 1700.
If it's under 1000, it will still go up to the next 100.
456 goes to 500 as well as 424 goes to 500.
Hopefully that is more clear.
Thanks again in advance.
Mike Gardner
mike@a2zcables.com
http://www.a2zcables.com
(607) 257-8897
Thomas Geffert wrote:
> Mike Gardner <mike@a2zcables.com> writes:
>
> > Sounds simple, but for the life of me I can't figure out how to round a
> > number to the nearest thousand in my script. Isn't there a module
> > available or a simple line of code that accomplishes this?
> >
> > example, i need this: 946 rounds to 1000, 432 rounds to 500
>
> I'm not sure, what you want really to do, as with 'rounding to the nearest
> thousand', I should not expect 432 to be rounded to 500.
>
> But try this and change it to your needs:
>
> $base=1000; # or 500 for the above example
> $rounded = int($number/$base+1)*$base;
>
> If you want to round really to the nearest number and to the bigger one, use
>
> $rounded = int($number/$base+0.5)*$base;
>
> Thomas
------------------------------
Date: 06 Dec 2000 20:22:28 +0100
From: Thomas Geffert <t.geffert@gmx.de>
Subject: Re: rounding to nearest thousand
Message-Id: <m3g0k11hjf.fsf@cal056202.student.utwente.nl>
Mike Gardner <mike@a2zcables.com> writes:
> I'm sorry, it wasn't very clear.
>
> I have a value being generated like 1624. I want it to always round
> up to the nearest hundred (ignore thousand, i'm on crack today). So
> it will always round up to the nearest hundred. 1700.
>
> If it's under 1000, it will still go up to the next 100.
>
> 456 goes to 500 as well as 424 goes to 500.
>
Ok, so you can use this:
$rounded = int($number/100+1)*100;
Thomas
------------------------------
Date: Wed, 06 Dec 2000 19:24:42 GMT
From: Mike Gardner <mike@a2zcables.com>
Subject: Re: rounding to nearest thousand
Message-Id: <3A2E95C0.9677A8CA@a2zcables.com>
I thank you so much : )
Mike Gardner
mike@a2zcables.com
http://www.a2zcables.com
(607) 257-8897
Thomas Geffert wrote:
> Mike Gardner <mike@a2zcables.com> writes:
>
> > I'm sorry, it wasn't very clear.
> >
> > I have a value being generated like 1624. I want it to always round
> > up to the nearest hundred (ignore thousand, i'm on crack today). So
> > it will always round up to the nearest hundred. 1700.
> >
> > If it's under 1000, it will still go up to the next 100.
> >
> > 456 goes to 500 as well as 424 goes to 500.
> >
> Ok, so you can use this:
>
> $rounded = int($number/100+1)*100;
>
> Thomas
------------------------------
Date: 06 Dec 2000 16:38:05 -0500
From: Doug Perham <dperham@dperham.eng.tvol.net>
Subject: Re: rounding to nearest thousand
Message-Id: <81zoi9gria.fsf@wgate.com>
Mike Gardner <mike@a2zcables.com> writes:
> Sounds simple, but for the life of me I can't figure out how to round a
> number to the nearest thousand in my script. Isn't there a module
> available or a simple line of code that accomplishes this?
>
> example, i need this: 946 rounds to 1000, 432 rounds to 500
>
# -- $rounded = round(<number>, <quantum>)
# -- i.e.,
# -- print "round(946, 500) = ", round(946, 500), "\n";
# -- print "round(432, 500) = ", round(432, 500), "\n";
sub round { int($_[0]/$_[1] + 0.5)*$_[1]; }
> Thanks!
>
> Mike Gardner
> mike@a2zcables.com
> http://www.a2zcables.com
> (607) 257-8897
--
Doug Perham o{..}o
dperham@wgate.com moo! (oo)___
WorldGate Communications, Inc. (______)\
/ \ / \
------------------------------
Date: Wed, 06 Dec 2000 14:51:09 +0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: Submitting a file via a form
Message-Id: <90m5ch01j84@news1.newsguy.com>
[ posted and mailed ]
In article <90g4q7$s1i$1@ucsnew1.ncl.ac.uk>, "M.I. Planchant"
<M.I.Planchant@ncl.ac.uk> wrote:
> I have written a perl program which uses a text file such as the one
> that would be submitted as the source of input. What I need to do, is to
> run the cgi program when the submit button is clicked on and for the
> file which has been submitted to be processed and results shown. How do
> I go about doing this? Ive done the form post stuff for the text fields
> but how can I do it for the file input?
I can't understand this, but here are a couple things that may help.
You might mean that you want to work offline, that you have a test file
and you want to see how your CGI program would process the file is
posted. Presumably, you don't have a web server handy with which to try
that. For this, I suggest reading the documentation to CGI.pm . It does
support an offline mode. It won't give you post, and it might be clumsy
with a whole file, but it is a place to start.
I initially thought you wanted to actually run code that is in the file
that you are passing. Now I think that probably isn't it, but if it is
please be VERY careful about what you are doing. Generally it would be a
Bad Thing to have a CGI program that allows arbitrary code to be
executed. If this was what you meant, look thee to eval().
Hmm... I'm going to save other speculations because re-reading it, I'm
more and more convinced it was the first thing above. Best results are
to be obtained by installing a webserver locally and actually running
your program. You're using knews? Shouldn't Apache be available or
easily obtained? Maybe it isn't what you mean after all... :-)
Cheers,
Jeff
------------------------------
Date: Wed, 06 Dec 2000 15:01:28 -0500
From: David J Kernen <david.kernen@bms.com>
To: queen of the web <webqueen@my-deja.com>
Subject: Re: substituting a hash value with a regex?
Message-Id: <3A2E9B18.B914371C@usa.net>
Tad McClellan wrote:
> webqueen, queen of the web <webqueen@my-deja.com> wrote:
>
> >Hmm guess this one was a real puzzler eh?
>
> Perhaps if you used the correct operators it would
> errr, operate more like you expect?
>
> >In article <8vmi46$eij$1@nnrp1.deja.com>,
> > webqueen, queen of the web <webqueen@my-deja.com> wrote:
> >>
> >>
> >> $cat=s/dog/$h{k}/;
> ^
Binding operator aside (probably a typo when posting not when coding,
IMHO), a way to avoid the extra
variable step would be to try something like this:
$cat =~ s/dog/"$h{k}"/e;
That should work, but to tell the truth I was unable to duplicate this
problem with any of my perl versions. Which one are you using?
Dave
------------------------------
Date: Wed, 6 Dec 2000 15:29:28 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: substituting a hash value with a regex?
Message-Id: <slrn92t8d8.qf6.tadmc@magna.metronet.com>
David J Kernen <david.kernen@bms.com> wrote:
>> >> $cat=s/dog/$h{k}/;
>> ^
>
>Binding operator aside (probably a typo when posting not when coding,
>IMHO),
typo when coding? No problem. Excrement occurs.
typo when posting code? Score down future articles by poster
(making them, in effect, invisible).
(though I did not do that in this case)
Running around in circles troubleshooting code that does not
even exist is not high on my list of how I want to spend my time :-)
cut/paste or import code when posting, don't try to type it in.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Dec 2000 22:11:35 GMT
From: jum@anubis.han.de (Jens-Uwe Mager)
Subject: Re: syscall.h missing on AIX
Message-Id: <slrn92tein.o8.jum@anubis.han.de>
On Thu, 7 Dec 2000 01:02:01 +1100, Michael Roper <michael_roper@hotmail.com> wrote:
> Im trying to run a script that requires sys/syscall.ph but there is no
>sys/syscall.h header file on the system Im using (AIX 4.3.2 on RS/6000).
>What's the story?
See my answer in comp.unix.aix. BTW, the next time use proper cross
posting if you post the same question to more than one group.
--
Jens-Uwe Mager <pgp-mailto:62CFDB25>
------------------------------
Date: Wed, 06 Dec 2000 21:08:46 GMT
From: swaroop@mediaone.net
Subject: XML::Parser/XML::Parser::Expat
Message-Id: <90m9so$tid$1@nnrp1.deja.com>
These modules "die" when a parse error is encountered. Is there some way
to make them just print an informational message and go on? I'm
processing a lot of XML files at once, and I'd like to continue on to
the next file if the parsing of one fails.
Thanx,
Swaroop
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 06 Dec 2000 14:02:33 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: XML::Parser/XML::Parser::Expat
Message-Id: <3A2EB779.F79C6F2E@vpservices.com>
swaroop@mediaone.net wrote:
>
> These modules "die" when a parse error is encountered. Is there some way
> to make them just print an informational message and go on? I'm
> processing a lot of XML files at once, and I'd like to continue on to
> the next file if the parsing of one fails.
Wrap them in an eval, e.g.:
use XML::Parser;
# ...
my $p = XML::Parser->new( Style => 'Objects' );
for my $file( @files ) {
my $o;
eval { $o = $p->parsefile( $file ) };
if( $@ ) {
print "Can't parse '$file': $@\n";
}
else {
# process $o;
}
}
--
Jeff
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 5049
**************************************