[13221] in Perl-Users-Digest
Perl-Users Digest, Issue: 631 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 24 16:07:20 1999
Date: Tue, 24 Aug 1999 13:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 24 Aug 1999 Volume: 9 Number: 631
Today's topics:
Adding a User <dontemailme@garbage.com>
Re: Books , Reccomend? <makkulka@cisco.com>
Re: Can you print " ? (Graham)
Re: Catching writes to files in Modules <cassell@mail.cor.epa.gov>
Re: CGI newsgroups? <cassell@mail.cor.epa.gov>
Dealing with commas variables <sjfox@email.sjsu.edu>
Re: Dealing with commas variables (Greg Bacon)
Re: Dealing with commas variables <sariq@texas.net>
Re: email address verification <cassell@mail.cor.epa.gov>
Re: Email Bounce config - MIME::Enitity <cassell@mail.cor.epa.gov>
Re: Hex from a file <cassell@mail.cor.epa.gov>
How add a new key to a hash <akelingos@petrosys-usa.com>
Re: how to capture STDOUT from external command? <cassell@mail.cor.epa.gov>
Re: Image reading and browsing <cassell@mail.cor.epa.gov>
Installing Perl and Perl/Tk on HP-UX 11 <benjamin.cassan@wanadoo.fr>
Re: lists and commas (Tony Kennick)
output format <deano@server.1011tenn.net>
Re: Perl Module Installation <cassell@mail.cor.epa.gov>
Re: Perl Sockets on Linux <callen@boxcar.driver8.org>
Re: POP is pooped! <cassell@mail.cor.epa.gov>
Problem opening a flat-file for read <news@news.news>
Re: Problem opening a flat-file for read <lottopescado@yahoo.com>
Re: Problem opening a flat-file for read <samay1NOnzSPAM@hotmail.com>
Reading / writing Java serialised objects from PERL? (Matthew Bloch)
Returning an absolute value from a variable ("willow")
Re: Returning an absolute value from a variable <Allan@due.net>
Re: Returning an absolute value from a variable <sariq@texas.net>
Re: Returning an absolute value from a variable ("willow")
Re: sorting files randomly out of a list <cassell@mail.cor.epa.gov>
tar? gzip? <admin3@teleport.com>
uploading files using multipart/form-data with NT (Helen Sian Ashton)
Re: User's Operative Sistem???? <cassell@mail.cor.epa.gov>
Win32::ODBC and Sql <lottopescado@yahoo.com>
Re: Win32::OLE to read Word file <cassell@mail.cor.epa.gov>
Re: Win32::OLE to read Word file <peterw@innate.co.uk>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Aug 1999 12:49:04 -0500
From: Sarah <dontemailme@garbage.com>
Subject: Adding a User
Message-Id: <37C2DB10.29FC@garbage.com>
Does anyone know of a script that would allow me to add a user to a Unix
System via a form on a web page. It would be nice to have something to
use, even just as a start to making something of my own.
Thanks,
Sarah
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 24 Aug 1999 11:22:26 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Books , Reccomend?
Message-Id: <37C2E2E2.E22D2CF0@cisco.com>
[ Tim wrote:
> Can someone recommend a book tha twould be a good step up?
Get hold of the books (1) and (2)
1. CGI Programming with Perl, Second Edition
By Gundavaram, Shishir
Make sure you get the latest edition published 09/1999
2. Official Guide to Programming with CGI.pm : The Standard for Building
Web Scripts
By Stein, Lincoln
A must if you want to use CGI.pm to develop your CGI apps
3. Read the documentation that comes with CGI.pm. All of it.
4. Read the CGI faq. Then read it again and again.
http://www.htmlhelp.org/faq/cgifaq.html
5 Read the MetaFAQ
.http://www.smithrenaud.com/public/CGI_MetaFAQ.html
===
------------------------------
Date: Tue, 24 Aug 1999 17:51:42 GMT
From: graham@hglmotors.co.uk (Graham)
Subject: Re: Can you print " ?
Message-Id: <37c2db47.1319861@news.btinternet.com>
On Mon, 23 Aug 1999 23:10:10 GMT, graham@hglmotors.co.uk (Graham)
wrote:
>I am writing/modifying a perl script to send web access
Thanks to both David's, got it sorted now.
Regards,
Graham
http://www.hglmotors.co.uk
------------------------------
Date: Tue, 24 Aug 1999 11:21:51 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Catching writes to files in Modules
Message-Id: <37C2E2BF.305C5758@mail.cor.epa.gov>
Simon Wistow wrote:
>
> Is there a way to get a file retrieved by Net::FTP to be read in a variable
> rather than outputted to a file. I could try and hack the module so that it
> accepted a filehandle instead of a filename and do it that way but is that isn't
> exactly what you call portable.
You're not being lazy enough. Read the docs for Net::FTP. I
quote:
get ( REMOTE_FILE [, LOCAL_FILE [, WHERE]] )
Get REMOTE_FILE from the server and store locally. LOCAL_FILE
may be a filename or a filehandle.
^^^^^^^^^^^^^^^
It is already hacked in there for you.
> I mean, is there a general way of doing this? There have been a few times when i
> wished I could do this (the MIME modules for one).
>
> Is there some clever trick you could od with named pipes? Although I'd prefer
> not to do this.
<AOL'er>
Me too!
</AOL'er>
It's all done for you. Enjoy.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 11:33:08 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: CGI newsgroups?
Message-Id: <37C2E564.D0246F83@mail.cor.epa.gov>
Andrei Karpatchev wrote:
>
> Can somebody say which newsgroups are there for the questions on CGI?
Oddly enough, this gets answered here about 20 times a week.
Or more. You might want to check out:
comp.infosystems.www.authoring.cgi
comp.infosystems.www.authoring.html
and any newsgroup related to your preferred webserver and
browser, in order to learn about quirk of your software.
Since you posted from WinNT, you may be using ActiveState Perl.
If so, go to their website and look for their Perl-and-CGI
mailing list:
http://www.activestate.com/support/mailing_lists.htm
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 11:19:25 -0700
From: "Stephanie Fox" <sjfox@email.sjsu.edu>
Subject: Dealing with commas variables
Message-Id: <7punnd$hk9$1@hades.csu.net>
I have a web form that is sending a field that may have commas in it. But
when I process that, like the following, it does not work right.
$Employer = $fields{Employer};
$mainstring = $mainstring.$Employer;
I eventually write all of this to a file, and then mail out the file.
But if there is a comma in the $Employer field, it messes up. How do I get
around this?
Thanks,
Stephanie
------------------------------
Date: 24 Aug 1999 18:54:54 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Dealing with commas variables
Message-Id: <7puppu$3ds$1@info2.uah.edu>
In article <7punnd$hk9$1@hades.csu.net>,
"Stephanie Fox" <sjfox@email.sjsu.edu> writes:
: I have a web form that is sending a field that may have commas in it. But
: when I process that, like the following, it does not work right.
In general, you shouldn't describe problems with phrases like "doesn't
work". Instead, say what you expected it to do and what it did do (and
the difference if necessary).
: $Employer = $fields{Employer};
:
: $mainstring = $mainstring.$Employer;
Experienced Perl programmers would write
$mainstring .= $Employer;
instead.
: I eventually write all of this to a file, and then mail out the file.
How are you mailing the file? That could make a difference.
: But if there is a comma in the $Employer field, it messes up. How do I
: get around this?
Would stripping commas from $Employer help?
$Employer =~ s/,+//g;
Hope this helps,
Greg
--
Ah, women. They make the highs higher and the lows more frequent.
-- Nietzsche
------------------------------
Date: Tue, 24 Aug 1999 13:49:42 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Dealing with commas variables
Message-Id: <37C2E946.D8035B4B@texas.net>
Stephanie Fox wrote:
>
> I have a web form that is sending a field that may have commas in it. But
> when I process that, like the following, it does not work right.
>
> $Employer = $fields{Employer};
>
> $mainstring = $mainstring.$Employer;
Why not just:
$mainstring .= $fields{Employer};
> But if there is a comma in the $Employer field, it messes up.
The commas have no effect in the assignment.
-----
acme$ cat test.pl
#!/usr/bin/perl -w
use strict;
my %fields;
$fields{Employer}='something,else';
my $mainstring='blah';
$mainstring.=$fields{Employer};
print "$mainstring\n";
acme$ ./test.pl
blahsomething,else
acme$
-----
There must be a problem elsewhere.
- Tom
------------------------------
Date: Tue, 24 Aug 1999 10:57:42 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: email address verification
Message-Id: <37C2DD16.A47B17A5@mail.cor.epa.gov>
Jon Hollcraft wrote:
[a bunch of code]
Jon, this does *not* verify e-mail addresses. It does make a
couple checks. It does not catch a lot of improper addresses.
It does reject some legal addresses.
I suppose you didn't read my earlier post in this thread.
Check out better solutions mentioned therein.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 11:00:21 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Email Bounce config - MIME::Enitity
Message-Id: <37C2DDB5.EB40E8FB@mail.cor.epa.gov>
E. Preble wrote:
>
> I'm using MIME::ENTITY to send emails via a form. I'd like
> to know if the emails bounce or not, but am unsure of the
> field that needs to be added (I assume to the header of the
> email). The "from" field doesn't get messages if they
> bounce. Which one would?
Even though your code is in Perl, this is not actually a
Perl question. You are liable to get more reliable
answers to this if you ask in a newsgroup specifically
about mail and/or your MTA.
This doesn't deal with people who have set up their systems
to transparently throw away incoming mail to the specified
address. Is that a problem for your program design?
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 11:35:52 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Hex from a file
Message-Id: <37C2E608.CF056FDA@mail.cor.epa.gov>
Jörg Oliver Pinn wrote:
>
> Hi,
>
> how can I read hex-values from a file?
Since you posted from a WinNT box, you will probably want to
read about binmode() so that the OS treats your file as binary.
Type at a command prompt:
perldoc -f binmode
Or else read the HTML docs on your Start Menu, starting
with the 'perlfunc' page.
If you want to translate the hex-values, you will want to
read about unpack() also.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 19:50:48 GMT
From: "Alec Kelingos" <akelingos@petrosys-usa.com>
Subject: How add a new key to a hash
Message-Id: <01beee6a$9de61c00$0664a8c0@psusa6.petrosys-usa.com>
I HAVE BEATEN THE FAQs AND MY TWO BOOKS to death but could find nothing -
How does one add a key to a hash? I'm trying to build a hash dynamically:
foreach $col ( keys $columns ) {
< add $col as a new columns to a new hash >
}
I tried:
foreach $col ( keys $columns ) {
%data = ( $col => [ $fields[$columns{$col}[1]] ]); }
}
But ofcourse that just keeps overwriting %data and in the end I was left
with a hash with a single column i.e. the last $col.
Alec
------------------------------
Date: Tue, 24 Aug 1999 11:02:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: how to capture STDOUT from external command?
Message-Id: <37C2DE18.271D20B0@mail.cor.epa.gov>
Adrian Hands wrote:
>
> angpung@my-deja.com wrote:
> >
> > I call external shell command by using pipe like:
> >
> > open (SQL,"| sqlplus ");
> > print SQL "select * from xxx;\n";
[snip]
> You REALLY should use DBI, not sql*plus.
> It's way more powerful, safer, cleaner, etc...
>
> use strict;
> use DBI;
>
> my $dbh = DBI::connect("dbi:Oracle:$dbname", "scott", "tiger");
> my $csr = $dbh->prepare("select * from xxx");
> $csr->execute();
> while(my($col1, $col2) = $csr->fetchrow()) {
> print "$col1 $col2\n";
> }
> $csr->finish();
> $dbh->disconnect();
And it has error-checking.. if you decide to use it.
The first time your connect() fails, you'll be glad you did.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 11:13:54 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Image reading and browsing
Message-Id: <37C2E0E2.8F8D6A5B@mail.cor.epa.gov>
Jonathan Stowe wrote:
>
> h.benne@library.uu.nl wrote:
> > In article <slrn7s2lko.k6b.abigail@alexandra.delanet.com>, abigail@delanet.com wrote:
> >
> >>And a C program doing the same won't do because of?
> >
> > That will probably do also, but I'm not able to write or read the C program
> > language. Apart from that I do not posses a C-compiler so Perl is the language
> > for me I guess..
> >
>
> Well that might be the case if you were thinking of writing this program
> yourself but you explicitly said you were looking for an already made
> program so what difference does the language make ?
>
> Anyhow if you are going to write a program yourself you will
> probably want to use opendir and readdir to get the files in the directory
> and one of the modules GD or Image::Magick to create the thumbnails - you
> will then use a bunch of print statements to generate the4 HTML.
A couple suggestions to add to Jonathan's helpful post:
[1] Benjamin Franz posted a program to do similar work in
this newsgroup about five months ago. You might check his
website:
http://www.nihongo.org/snowhare/
[2] O'Reilly has a book titled "Programming Web Graphics with
Perl and GNU Software" by Shawn P. Wallace which might help.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 19:08:02 +0200
From: Benjamin Cassan-de Gorostarzu <benjamin.cassan@wanadoo.fr>
Subject: Installing Perl and Perl/Tk on HP-UX 11
Message-Id: <37C2D171.274273AA@wanadoo.fr>
Hi,
I have some questions for Perl and Perl/Tk :
** Perl :
I want to compile Perl 5.005_03 on HP-UX 11. I already did it with 10.20
and the complete cc C ANSI compiler, with the default choices for
"Configure".
With HP-UX 11 I only have aCC and Perl doesn't compile with it. aCC
seems to be too strict even for the little test source files of
"Configure".
So on HP-UX 11 :
- Did somebody compile Perl with aCC ? With specific parameters or
options ?
- Did somebody compile Perl with gcc ? With specific parameters or
options ? With which version of gcc ?
- Did somebody compile Perl with the complete cc ? With specific
parameters or options ?
According to newsgroups, it seems to be ok with cc, but if you can
confirm it...
Did somebody known if copying a binary of Perl from 10.20 to 11 is
working well ?
** Same problem with Perl/Tk 800.014.
It requires a complete C ANSI compiler, and I only have aCC. I did not
try it because generating the
Makefile requires Perl :-)
So still for HP-UX 11 :
- Did somebody compile Perl/Tk with aCC ? With specific parameters or
options ?
- Did somebody compile Perl/Tk with gcc ? With specific parameters or
options ? With which version of gcc ?
- Did somebody compile Perl/Tk with the complete cc ? With specific
parameters or options ?
Using a binary from 10.20 gave me a nice core dump.
If you can answer to one of these questions, thank you for your help.
Regards,
Benjamin Cassan
--
Benjamin Cassan-de Gorostarzu
benjamin.cassan@wanadoo.fr
------------------------------
Date: Tue, 24 Aug 1999 19:46:45 GMT
From: tony@showroom.org.uk (Tony Kennick)
Subject: Re: lists and commas
Message-Id: <37c2f52a.7507616@missy.shef.ac.uk>
oshram@bells.net (Jeff) imparted the following:
:->the numbers look like this
:->$4.00
:->$5.15
:->$1,250.17
:->...
:->
:->the commas present a problem with my lame code above
:->
:->I know this is probably simple but the answer isn't obvious to me
:->
:->can anyone help?
If the data is just numbers in those formats you might want the
translation operator it looks like tr/// or y/// and is discussed in
the perlop section of the manual.
Try man perlop or perldoc perlop from the command line or if you have
"ActivePerl" perlop can be found in the HTML pages that came with the
install.
--
From Tony Kennick aka Gonzo The Great
http://missy.shef.ac.uk/users/old-firm/
Gonzo: Slang for "the last man standing
at a drinking marathon"
------------------------------
Date: Tue, 24 Aug 1999 14:54:52 -0500
From: Dean Wilson <deano@server.1011tenn.net>
Subject: output format
Message-Id: <Pine.LNX.4.10.9908241446250.18363-100000@server.1011tenn.net>
Hi! I have a question that I don't even know where to start looking for
answers for. I'd like to write a program that outputs information to
STDOUT, but instead of scrolling the text upward, I'd like it to replace
current text. (I'm not even sure if there is a common name for text that
is outputted in this fashion...)
i.e.:
If the original screen looks like this:
Title 1 Title 2
________ _________
Some info some more info
And the program adds a line that says "new info new info"
it would look like:
Title 1 Title 2
________ _________
new info new info
Instead of
Title 1 Title 2
________ _________
Some info some more info
new info new info
I'd like to do this in a normal terminal -- no XWindows. Does anyone know
a) what this informational display type is called, so I can look up info on it
b) of any modules that may help output info in this way
c) how to format text this way with/without any available modules
???
Thanks for your help,
Dean Wilson
------------------------------
Date: Tue, 24 Aug 1999 11:04:43 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl Module Installation
Message-Id: <37C2DEBB.B72F23D0@mail.cor.epa.gov>
polarbear wrote:
>
> Hi,
>
> I am trying to install the perl module, POP3Client, and when I did a
> 'make install', it gives me the following error message,
>
> Perl lib version (5.00502) doesn't match executable version (5.00503)
[snip]
It looks like your lib version is 5.005_02 while your
Perl is 5.005_03. Make sure everything is up to date,
like your Perl version is.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 24 Aug 1999 18:57:22 GMT
From: Christopher Allen <callen@boxcar.driver8.org>
Subject: Re: Perl Sockets on Linux
Message-Id: <7pupui$13p0$1@news1.spacestar.net>
Scott.R.Wachtler <Scott.Wachtler@cdc.com> spake:
> box also. Unfortunately when a client tries to connect to my linux box
> it receives a Connection Refused. The "offending" line is
> connect($S, $remote_sok) || die $!;
> But when a client tries to connect to the Unix server it runs fine.
I noticed this also within c written-socket-programs.
Start here:
Check this out:
--------------------
[root@vermont develop]# perldoc -q socket
=head2 Why doesn't my sockets program work under System V (Solaris)? What does the error message "Protocol not supported" mean?
Some Sys-V based systems, notably Solaris 2.X, redefined some of the
standard socket constants. Since these were constant across all
architectures, they were often hardwired into perl code. The proper
way to deal with this is to "use Socket" to get the correct values.
^^^^^^^^^^
( did you use this?)
Note that even though SunOS and Solaris are binary compatible, these
values are different. Go figure.
--------------
Without your code being shown it's hard to help: repost with the code.
-out
------------------------------
Date: Tue, 24 Aug 1999 11:16:28 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: POP is pooped!
Message-Id: <37C2E17C.9F6BCDC3@mail.cor.epa.gov>
Alan J. Flavell wrote:
>
> On 24 Aug 1999, Sam Holden wrote:
>
> > > flock(KEYS, 2);
> >
> > You should really use the human readbale constants LOCK_SH, etc...
>
> Yes, I was trying to make that point to a student recently, and then
> noticed to my surprise that Merlyn's Web techniques articles are all
> using numbers:
>
> http://www.stonehenge.com/cgi/wtsearch?search=flock
>
> Comments?
You're surprised? Surprised that the man who invented the
Schwartzian Transform would use the numbers instead of the
readable constants? Surprised that the man who showed me
how to type $|++; would have any obfuscations in his code?
:-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 20:21:45 +0100
From: news <news@news.news>
Subject: Problem opening a flat-file for read
Message-Id: <37C2F0C9.A06A6583@news.news>
Can anyone tell me what is wrong with this piece of code? I am trying to
open a flat-file that contains data like:
Joe:20:foobar
Jack:20:foobar
and then match up some fields. Any help would be much appreciated.
(ps thanks to whoever orignally posted this code)
saiid@excite.com
open(READ, "$database") || die $!;
while(<READ>)
{
($fieldname,$fieldage,$fieldcountry)=split(/:/);
$numofpeople++ if $fieldage ==20 and $fieldcountry="foobar";
}
------------------------------
Date: Tue, 24 Aug 1999 12:34:15 -0700
From: Andrew Crawford <lottopescado@yahoo.com>
Subject: Re: Problem opening a flat-file for read
Message-Id: <37C2F3B7.7363406D@yahoo.com>
try open(READ, "<$database") || die $!;
-- note that '<'
news wrote:
> Can anyone tell me what is wrong with this piece of code? I am trying to
>
> open a flat-file that contains data like:
>
> Joe:20:foobar
> Jack:20:foobar
>
> and then match up some fields. Any help would be much appreciated.
>
> (ps thanks to whoever orignally posted this code)
>
> saiid@excite.com
>
> open(READ, "$database") || die $!;
> while(<READ>)
> {
> ($fieldname,$fieldage,$fieldcountry)=split(/:/);
> $numofpeople++ if $fieldage ==20 and $fieldcountry="foobar";
> }
------------------------------
Date: Tue, 24 Aug 1999 12:45:55 -0700
From: Samay <samay1NOnzSPAM@hotmail.com>
Subject: Re: Problem opening a flat-file for read
Message-Id: <021ae482.581221cb@usw-ex0102-010.remarq.com>
try
while(<READ>){
whatever..
}
You are just opening the file,
and not reading it at all..
(Naming the FileHandle READ will not do the magic. -:)
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Tue, 24 Aug 1999 20:03:14 GMT
From: mattbee@eh.org (Matthew Bloch)
Subject: Reading / writing Java serialised objects from PERL?
Message-Id: <slrn7s5t65.iqq.mattbee@soup-kitchen.demon.co.uk>
Subject says it all; I've got some aggregate data types which need to be
chucked between a Java program and some PERL scripts behind a web server.
It'd be really nice if I could use Java's serialisation features to read
and write these, and have PERL co-operate? If it hasn't already been
done, does it sound like a large job, or are Java serialised objects a
relatively simple format?
--
Matthew ( http://www.soup-kitchen.demon.co.uk/ )
------------------------------
Date: Tue, 24 Aug 1999 09:20:17 -0800
From: chettah@msn.com ("willow")
Subject: Returning an absolute value from a variable
Message-Id: <atAw3.4523$C%.3148207@WReNphoon3>
What command can I use to return the absolute value of a variable that could
be either positive or negative?
In this subroutine, my $diff is the variable and when I print it in the
"elsif" statement, I'd like the absolute value.
sub evalsum {
my $diff = ($sumrec - $sumsent);
print "$diff\n";
if ($sumrec == $sumsent) {
print "Validation is successful \n";
}
elsif ($sumsent > $sumrec) {
print "Outgoing amounts are greater than incoming amounts by
$diff\n";
}
else {
print "Incoming amounts are greater than outgoing amounts by
$diff\n";
}
}
Any help is appreciated to this beginner. Thanks!
Tara
-**** Posted from RemarQ, http://www.remarq.com/?a ****-
Search and Read Usenet Discussions in your Browser - FREE -
------------------------------
Date: Tue, 24 Aug 1999 13:47:44 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Returning an absolute value from a variable
Message-Id: <7pullv$thb$1@nntp8.atl.mindspring.net>
"willow" wrote in message ...
:What command can I use to return the absolute value of a variable that
could
:be either positive or negative?
[snip]
:Any help is appreciated to this beginner. Thanks!
Um, my best advice for a beginner would be to check the helpful
documentation that is provided with Perl.
perldoc -f abs
perlfunc abs
All shall be revealed.
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
Although the Perl Slogan is There's More Than One Way to Do It, I
hesitate to make 10 ways to do something. :-)
- Larry Wall in <9695@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Tue, 24 Aug 1999 12:44:31 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Returning an absolute value from a variable
Message-Id: <37C2D9FF.6F0A3AA2@texas.net>
willow wrote:
>
> What command can I use to return the absolute value of a variable that could
> be either positive or negative?
perldoc -f abs
And you should really read the perlfunc manpage. It's a lot faster than
waiting for a Usenet reply, and it shows that you're at least *trying*
to solve the problem on your own.
- Tom
------------------------------
Date: Tue, 24 Aug 1999 10:18:50 -0800
From: chettah@msn.com ("willow")
Subject: Re: Returning an absolute value from a variable
Message-Id: <ThBw3.5574$001.2810935@WReNphoon3>
I apologize for asking these questions here, but I don't have perldoc. I
guess we don't have all of Perl but when I typed that in, it wasn't found.
I have been reading "Programming Perl" and the "Perl Cookbook" trying to
resolve this on my own.
-**** Posted from RemarQ, http://www.remarq.com/?a ****-
Search and Read Usenet Discussions in your Browser - FREE -
------------------------------
Date: Tue, 24 Aug 1999 11:28:43 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: sorting files randomly out of a list
Message-Id: <37C2E45B.B8F3F540@mail.cor.epa.gov>
Gareth Rees wrote:
>
> Gareth Rees wrote:
> > Aside: is there a way to avoid the sort when computing the combination?
> > In other words, is there an O(n) algorithm for generating a combination
> > of k elements from 0..n-1?
[snip of my post of Larry Rosler's code]
Oh, all right. Try this:
#!/usr/bin/perl -w
# Note: there is no srand() function here.
# So if you're not using 5.004 or better, fix that!
use strict;
my @array = ( 1 .. 10000 );
my $max = @array<10 ? @array : 10;
my @selected = ();
my $count = @array;
for (@array) {
next if rand > $max/$count--;
push @selected, $_;
last unless --$max;
}
print "@selected\n";
__END__
Note the dirty trick in the last line to get spaces
between the selections. I should have written this
better. But it should be O(n). It uses a cute trick
from statistical computing to walk the array and
ensure equal likelihood as you go.
And Uri will probably complain about the initialization
of @selected, but I like it for clarity.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 12:31:02 -0700
From: Teleport Admin--Jereme <admin3@teleport.com>
Subject: tar? gzip?
Message-Id: <Pine.GSO.4.10.9908241229320.16864-100000@eng1.teleport.com>
I would have like to have scoured the initial 22k messages for this
answer, but.. Well.. You know.. Anyways, I know Programming Perl mentions
something about a standard lib that can tar files. I can't remember where
I saw it.. Can anyone clue me in? Also, is there one that gzips files as
well?
Thanks,
Jereme Claussen | T E L E P O R T I N T E R N E T |
System Administrator I | #1 in the Northwest! |
admin3@teleport.com | http://www.teleport.com/ |
503.223.0076x259 | 503.223.4245/888.223.4245 |
------------------------------
Date: Tue, 24 Aug 1999 11:51:55 GMT
From: ceehsa1 (Helen Sian Ashton)
Subject: uploading files using multipart/form-data with NT
Message-Id: <FGywyL.CK2@cee.hw.ac.uk>
Hi, I am trying to allow uses to uplaod to my NT apache Server. The uploaded
files will mostly be zip files. The problem I am encountering is that the data
from the zip files doesn't seem to upload properly. I think it is to do with
them being binary. I have set the binmode of the file to be written to, but
I'm unsure of how to set the form data to be binary also. Anyone got any
ideas?
Cheers,
Helen
------------------------------
Date: Tue, 24 Aug 1999 11:07:44 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: User's Operative Sistem????
Message-Id: <37C2DF70.23B57AEA@mail.cor.epa.gov>
Jon Peterson wrote:
>
> Rodrigo Cortes <roco3d@softhome.net> wrote:
> > How i know the user's Operative Sistem with a perl script???
>
> There are several ways. To find basic information, use the variable $^O (that's
> a capital o, not a zero).
>
> Or, get the same info another way if you use the English module:
> use English;
> print "Running under $OSNAME\n";
Good so far...
> But, if you are on some kind of unix, the command uname will give you more
> information:
>
> my $os = `uname -a`;
But make sure that you only run this on systems which *have*
uname, or else that you can handle the failure gracefully.
There are a number of unix-ish values for $^O as well.
If you get $^O='MSWin32' you may want to differentiate between
NT and 95/98 . ActiveState has an IsWinNT() variable you
can test in this case.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 12:22:25 -0700
From: Andrew Crawford <lottopescado@yahoo.com>
Subject: Win32::ODBC and Sql
Message-Id: <37C2F0F1.2E624187@yahoo.com>
First-time caller, long-time listener.
I'm using Win32:ODBC to interface with an Access database. The following
code:
my $stmt = "insert into TableName (field1, field2, field3) values
($var1, $var2, $var3)";
$db->Sql($stmt);
would ordinarily do a fine job of what we'd expect it to do. However,
say the value of $var1 is a text string. Since strings need to be in
single quotes when used in Sql insert statements, I've placed single
quotes at the start and end of $var1's value by the time the above code
is executed. My quandary is that $var1 has other single quotes in it, so
a word like "don't" is causing an error because that apostrophe is being
read as an end-of-string quote by the sql statement. Any suggestions?
Many thanks.
------------------------------
Date: Tue, 24 Aug 1999 11:10:18 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Win32::OLE to read Word file
Message-Id: <37C2E00A.A46ED69@mail.cor.epa.gov>
Andrew Fry wrote:
>
> Anyone have an example of a Win32:OLE program
> that reads a Word file line-by-line ?
> I've seen an example that prints a Word file, but
> this isnt what I want to do, and it isnt obvious
> how I might modify it to do what I want.
MS Word doesn't do 'lines'. It is really a paragraph-
oriented system. The words on a line are totally dependent
on font, margins, kerning, and a handful of other fun DTP
functions. You'll probably want to capture the file
and do your own line breakout. Text::Wrap might be of
some help here.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 24 Aug 1999 20:55:33 +0100
From: "Peter Wilkinson" <peterw@innate.co.uk>
Subject: Re: Win32::OLE to read Word file
Message-Id: <935524783.7404.0.nnrp-06.9e983bf8@news.demon.co.uk>
I would be interested in the example you mention that
prints a word file. What exactly do you mean by 'print'?
It could mean send to the printer, or show on the screen.
Anyhow, a reference to it would be useful.
Peter
David Cassell <cassell@mail.cor.epa.gov> wrote in message
news:37C2E00A.A46ED69@mail.cor.epa.gov...
> Andrew Fry wrote:
> >
> > Anyone have an example of a Win32:OLE program
> > that reads a Word file line-by-line ?
> > I've seen an example that prints a Word file, but
> > this isnt what I want to do, and it isnt obvious
> > how I might modify it to do what I want.
>
> MS Word doesn't do 'lines'. It is really a paragraph-
> oriented system. The words on a line are totally dependent
> on font, margins, kerning, and a handful of other fun DTP
> functions. You'll probably want to capture the file
> and do your own line breakout. Text::Wrap might be of
> some help here.
>
> HTH,
> David
> --
> David Cassell, OAO cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 631
*************************************