[18625] in Perl-Users-Digest
Perl-Users Digest, Issue: 793 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 29 09:05:45 2001
Date: Sun, 29 Apr 2001 06: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)
Message-Id: <988549512-v10-i793@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 29 Apr 2001 Volume: 10 Number: 793
Today's topics:
Re: Activestate 5.6.1 and MRTG 2.9.12 <gellyfish@gellyfish.com>
Apologies <taka@yarn.demon.co.uk>
Re: Boole's tools (was Things I'm just not getting in P <gellyfish@gellyfish.com>
Re: Can I include local perl snipits? <gellyfish@gellyfish.com>
can I use perl for creating a gif? <mario.lat@libero.it>
Re: can I use perl for creating a gif? <comdog@panix.com>
Re: can I use perl for creating a gif? <bart.lateur@skynet.be>
Re: can I use perl for creating a gif? <gtoomey@usa.net>
Re: can I use perl for creating a gif? (Martien Verbruggen)
Re: can I use perl for creating a gif? <gtoomey@usa.net>
Re: can I use perl for creating a gif? (David Efflandt)
Re: Compile time error - need help <gellyfish@gellyfish.com>
Re: cr's in input text fields screwing up the database <xris@dont.send.spam>
Re: cr's in input text fields screwing up the database <bart.lateur@skynet.be>
Re: dynamic creation of classes? (F. Xavier Noria)
Re: First and last element in list loop <gtoomey@usa.net>
Re: First and last element in list loop (Martien Verbruggen)
golf? unknown uid/gid detection (Dave Murray-Rust)
Re: How to convert integer to string? (Perl newbie) <waltman@netaxs.com>
How to write a multi process program with perl ? (dekuo)
Re: How to write a multi process program with perl ? <gellyfish@gellyfish.com>
Re: How to write a multi process program with perl ? <djmarcus@ex-pressnet.com>
Re: Infinate loop <goldbb2@earthlink.net>
Re: matrix multiplication <wendigo@jabberwock.org>
Re: Must send lots of emails <gellyfish@gellyfish.com>
Re: perl variables problem <gellyfish@gellyfish.com>
Re: Problem - PERL mail script sends HTML formating as <gellyfish@gellyfish.com>
Re: re-sizing GIF images on the fly <gtoomey@usa.net>
Re: re-sizing GIF images on the fly <gellyfish@gellyfish.com>
Re: re-sizing GIF images on the fly (Martien Verbruggen)
script for generating a preview web page for many image josef.bauer@mchp.siemens.de_NO_SPAM_PLEASE
Re: Should Perl be first? <miltonroad@btinternet.com>
Re: total newbie <gellyfish@gellyfish.com>
Re: total newbie (Martien Verbruggen)
Re: UDP Packets with zero checksum <gellyfish@gellyfish.com>
use strict.. bugger! <"relaxedrob@optushome.com.au">
Re: use strict.. bugger! (Gwyn Judd)
XML::RSS and mod_perl <m2@csu.edu.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Apr 2001 11:57:24 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Activestate 5.6.1 and MRTG 2.9.12
Message-Id: <9cgvj4$rlp$1@neptunium.btinternet.com>
DG <dannygul@ionictech.com> wrote:
> Have just downloaded AS5.6.1 and MRTG and installed on W2k. Everything
> appeared to go ok. However, I can create the html and png files and attempt
> to load in my IE browser. The text part of the html loads ok, however, the
> png files will not display. I check the properties on the .png files and
> find that these files are really GIFs. I then save the png files as png
> files and all works ok.
>
> Has anyone experienced this problem? I am fairly new to MRTG and perl.
>
I might be entirely wrong about this but I seem to recall that the
activestate GD module uses an earlier version of the GD library that produces
GIF images.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 29 Apr 2001 14:03:21 +0100
From: Paul the Nomad <taka@yarn.demon.co.uk>
Subject: Apologies
Message-Id: <87lmojluxy.fsf@euterpe.yarn.demon.co.uk>
My most sincere apologies to all regulars, lurkers and those who
occasionally drop in for a post in a thread about file locking. Both
the tone of and the language used in that post were completely
unwarranted.
I let my frustration with one particular person or thing (nothing to
do with the person the post was a follow up to) get the better of me
when I should have ignored what I felt was a provocation.
I never imagined that anything I might say would cause such a
furore. I'm sorry for any upset that the post caused.
I wish you all the best. Any follow-ups to this I won't be able to
read because I am no longer reading this group. This is partly
because I will never be able to regain any good name that I might have
had among the regulars and partly for other reasons (I should be doing
other things than reading news.)
Perl is an incredibly useful and fascinating language and I wish you
all happy Perl hacking.
--
-----------
Paul
------------------------------
Date: 29 Apr 2001 10:33:35 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Boole's tools (was Things I'm just not getting in Perl)
Message-Id: <9cgqlv$mvf$4@plutonium.btinternet.com>
Andrew Lee <andrew_lee@earthlink.net> wrote:
<Abigail Wrote>
>> Andrew Lee (andrew_lee@earthlink.net) wrote on MMDCCXCVI September
>
> Maybe your problem stems from your misuse of Roman Numerals ... either
> that or I posted the referred to article 795 years from now.
Maybe *your* problem stems from the fact that you are unable to prevent
your news client from emitting four copies of the same article ?
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 29 Apr 2001 12:58:03 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Can I include local perl snipits?
Message-Id: <9ch34r$4ge$1@plutonium.btinternet.com>
xris <xris@dont.send.spam> wrote:
> In article <slrn9eboj7.2rs.abigail@tsathoggua.rlyeh.net>,
> abigail@foad.org (Abigail) wrote:
>
>> Objects are just references. So, you're building and destroying references.
>> Which you're likely doing in a non-OO program as well.
>> But beside that, what does that have to do with *packages*?
>
> I'll admit that my knowledge of OOP perl is pretty limited. I just
> assumed that the package was the enclosure around an object, since
> that's seemingly how they're treated.
>
No packages are just namespace control - they can be used equally in
non-OO programs - indeed they are used in *all* modules whether they have
an OO interface or not.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sun, 29 Apr 2001 05:53:15 GMT
From: "_Mario Latens" <mario.lat@libero.it>
Subject: can I use perl for creating a gif?
Message-Id: <20010429.075217.1605908235.1197@localhost.localdomain>
I'd dlike to crate a gif on the fly: can I do tha whith perl?
how?
hank you in advance, Mario.
------------------------------
Date: Sun, 29 Apr 2001 02:00:43 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: can I use perl for creating a gif?
Message-Id: <comdog-C2887A.02004329042001@news.panix.com>
In article <20010429.075217.1605908235.1197@localhost.localdomain>,
"_Mario Latens" <mario.lat@libero.it> wrote:
> I'd dlike to crate a gif on the fly: can I do tha whith perl?
> how?
see the various Image modules on CPAN
http://search.cpan.org
--
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Sun, 29 Apr 2001 06:37:07 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: can I use perl for creating a gif?
Message-Id: <kkdnets79ufcjopnc5a441f2r84h5h7mkb@4ax.com>
brian d foy wrote:
>> I'd dlike to crate a gif on the fly: can I do tha whith perl?
>> how?
>
>see the various Image modules on CPAN
>
> http://search.cpan.org
It's not so obvious, since for various modules the GIF output mode has
been replaced with PNG, because of the legal troubles around GIF.
--
Bart.
------------------------------
Date: Sun, 29 Apr 2001 18:37:53 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: can I use perl for creating a gif?
Message-Id: <hcQG6.13842$482.70291@newsfeeds.bigpond.com>
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:kkdnets79ufcjopnc5a441f2r84h5h7mkb@4ax.com...
....
> It's not so obvious, since for various modules the GIF output mode has
> been replaced with PNG, because of the legal troubles around GIF.
>
> --
> Bart.
I'm going to need to generate gifs as well.
If the CPAN modules (like GD) cannot output a gif file, what is the
alternative?
gtoomey
------------------------------
Date: Sun, 29 Apr 2001 19:07:53 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: can I use perl for creating a gif?
Message-Id: <slrn9enmf9.oj7.mgjv@martien.heliotrope.home>
On Sun, 29 Apr 2001 18:37:53 +1000,
Gregory Toomey <gtoomey@usa.net> wrote:
> "Bart Lateur" <bart.lateur@skynet.be> wrote in message
> news:kkdnets79ufcjopnc5a441f2r84h5h7mkb@4ax.com...
> ....
>> It's not so obvious, since for various modules the GIF output mode has
>> been replaced with PNG, because of the legal troubles around GIF.
>>
>> --
>> Bart.
>
> I'm going to need to generate gifs as well.
> If the CPAN modules (like GD) cannot output a gif file, what is the
> alternative?
You can go a few ways. you could still use GD to _create_ the image, and
then use Image::Magick to convert it to GIF, or shell out to an external
tool to do this work. If you use GD and Image::Magick, you don't need to
use an intermediate file.
Alternatively, you can use Image::Magick on its own, and do all the
drawing with that. It's a little less straightforward to use, and
slower, but has many, many more capabilities.
None of the above will give you compressed GIF output, unless you have a
tool that can do LZW compression for you, or you compile Image::Magick
with LZW support, in which case you're responsible yourself for getting
the correct licensing from Unisys.
My advice: Don't go there. Use PNG. GIF is obsolete, and not that great
a format anyway. You _say_ you need to create GIF, but do you really?
Martien
--
Martien Verbruggen |
Interactive Media Division | life ain't fair, but the root
Commercial Dynamics Pty. Ltd. | password helps. -- BOFH
NSW, Australia |
------------------------------
Date: Sun, 29 Apr 2001 19:21:56 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: can I use perl for creating a gif?
Message-Id: <ARQG6.13869$482.70941@newsfeeds.bigpond.com>
"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn9enmf9.oj7.mgjv@martien.heliotrope.home...
<snip>
> My advice: Don't go there. Use PNG. GIF is obsolete, and not that great
> a format anyway. You _say_ you need to create GIF, but do you really?
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | life ain't fair, but the root
> Commercial Dynamics Pty. Ltd. | password helps. -- BOFH
> NSW, Australia |
Well, I need to create an image with <256 colours, for outputting graphs.
MS PNG support is not 100% OK
http://support.microsoft.com/support/kb/articles/q255/2/39.asp
gtoomey
------------------------------
Date: Sun, 29 Apr 2001 11:53:44 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: can I use perl for creating a gif?
Message-Id: <slrn9eo068.pl5.see-sig@typhoon.xnet.com>
On Sun, 29 Apr 2001 02:00:43 -0400, brian d foy <comdog@panix.com> wrote:
> In article <20010429.075217.1605908235.1197@localhost.localdomain>,
> "_Mario Latens" <mario.lat@libero.it> wrote:
>
>> I'd dlike to crate a gif on the fly: can I do tha whith perl?
>> how?
>
> see the various Image modules on CPAN
>
> http://search.cpan.org
Use the older GD-1.19 if it is still around. But it would probably need
to be installed in its own dir pointed to with 'use lib' so it is not
confused with the current GD.
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 29 Apr 2001 10:47:48 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Compile time error - need help
Message-Id: <9cgrgk$mvf$5@plutonium.btinternet.com>
GA MILLER <gmiller@lightmail.com> wrote:
> I am attempting to use HTML::Parser. At first it whined that it "Can't
> locate <N> in @INC" and I pointed to the correct diretory with a "use lib"
> at the top of the code. The compile now says:
>
> "Can't locate loadable object for module HTML::Parser"
>
> The fact that the "use lib" caused the error to 'change' kinda indicates
> that it can now locate the correct module, but now finds something else
> objectionable (pun?). Any help would be appreciated.
>
I am assuming that you simply copied the 'Parser.pm' somewhere right ?
You can't do that with modules like HTML::Parser which has a binary
component too.
You will want to read the article in the FAQ that discusses keeping your
own private module library.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sun, 29 Apr 2001 01:55:09 -0500
From: xris <xris@dont.send.spam>
Subject: Re: cr's in input text fields screwing up the database (not text area)
Message-Id: <xris-6AEF67.01550429042001@news.evergo.net>
In article <1aLG6.1849$st.7610@newsfeed.slurp.net>,
"Jonah Klimack" <jonah@nospam.adtrackz.com> wrote:
> How could a hard return be represented as \015 by that
> webtv user if the script is running on my unix server?
the linefeeds transmitted by web browsers depends on 2 things: the
client OS and the web browser itself. Generally, linefeeds are sent as:
\r\n
the \r is just a hard carriage return (ascii #13, which is the character
you're dealing with - the octal representation confused me for a sec) -
I forget which OS the double representation comes from but it IS a
standard if I recall correctly.
I usually just do a:
s/\r\n/\n/sg;
tr/\r/\n/;
on all incoming form data to catch whatever a browser might send (you
need both, or you won't catch everything).
-Chris
------------------------------
Date: Sun, 29 Apr 2001 11:25:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: cr's in input text fields screwing up the database (not text area)
Message-Id: <leunetcklsuetb0jidlrupfsn7m52212ct@4ax.com>
Jonah Klimack wrote:
>So I had to do this to get rid of it:
>$url =~ s/\015//g;
>
>What confuses me slightly is that the
>$url =~ s/\n//g;
>didn't work, even though it works for when
>I'm processing a text area...
On most platforms, "\n" is LF (10). So, you want to get rid of the other
character: "\r".
n.b. A textarea produces both CR (13) and LF (10). You usually want to
get rid of every "\r" anyway.
--
Bart.
------------------------------
Date: Sun, 29 Apr 2001 10:24:10 GMT
From: fxn@isoco.com (F. Xavier Noria)
Subject: Re: dynamic creation of classes?
Message-Id: <3aebe766.2426578@news.iddeo.es>
On Sun, 29 Apr 2001 00:43:20 +0200, eins@durchnull.de (Rudolf Polzer) wrote:
: This one seems to be reliable. I am thinking about releasing such a
: module (may be Module::Autodetect) to the CPAN; there may be uses of
: it.
It would be nice!
The origin of my question is a program I'm writing that has to
manage some Monitors (every subclass of Monitor is specialized in
something, like disks, or databases) but that has the monitors it
actually has to manage specified in a config file where the name
of the classes (DiskMonitor, DBMonitor) are given. Then, a common
interface makes the management possible.
Perhaps this is something DBI needs to do as well, I'm going to
try to read its code.
I am not very fluent with the use of `require', `use', `BEGIN',
`eval', and their implications at different times of the cycle of
the programs further than the basics (I read the Camel book, but
need to assimilate that information), so I appreciate very much
the help of all who have contributed to this thread.
-- fxn
------------------------------
Date: Sun, 29 Apr 2001 16:17:06 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: First and last element in list loop
Message-Id: <i8OG6.13767$482.69964@newsfeeds.bigpond.com>
This issue abounds in comp.land.perl.misc and practiacllu nowhere else.
http://www.perlfaq.com/faqs/id/131
...
The above is Abigail's text. I'm going to leave it untouched, but I beg to
differ, or at least offer a contrasting viewpoint. There are some people who
feel very strongly that quoted text should appear above any reply. I, on the
other hand, could care less whether a reply comes before the relevant text
or after it. In fact, if the quoted text is long and not exactly specific to
the reply, I prefer to see it after the reply. I often follow up with the
quoted material after my reply--when I'm not addressing the quoted material
point-by-point--and although this annoys the heck out of a limited number of
people who want email and netnews and the like to be just so, it's still
perfectly readable, and it's the way that I want my postings to look. If the
meaning is clear, why should I let people tell me what order the parts of my
message should be in? Personally I think that's an overly pedantic criticism
of a message. Your view may of course differ.
-Joseph N. Hall
------------------------------
Date: Sun, 29 Apr 2001 19:09:51 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: First and last element in list loop
Message-Id: <slrn9enmiv.oj7.mgjv@martien.heliotrope.home>
On Sun, 29 Apr 2001 16:17:06 +1000,
Gregory Toomey <gtoomey@usa.net> wrote:
> This issue abounds in comp.land.perl.misc and practiacllu nowhere else.
Nonsense.
*plonk*
Martien
--
Martien Verbruggen |
Interactive Media Division | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd. | but mean your mother.
NSW, Australia |
------------------------------
Date: Sun, 29 Apr 2001 13:27:21 +0100
From: dave@mo-seph.com (Dave Murray-Rust)
Subject: golf? unknown uid/gid detection
Message-Id: <slrn9eo256.mnh.dave@flop.localnet>
A friend found his system to have many files on it with uid/gids which
were unknown - they appear in listings as a number. My challenge was
to write a one liner which could detect these files and print out the
filename as apropriate. Filenames adhere to unix naming conventions
(may include spaces and numbers), but I'm assuming there are no spaces
in the groupnames or usernames. The input is given as a single line
per file, with spaces between the fields, and the user and group as
the last two e.g.
filename with spaces and 1 digit 503 owner
Would be a file with an unknown group (3) and owned by owner which
_should_ print it's filename, and
filename with spaces and 1 digit group owner
should _not_ print it's filename.
The best I came up with was:
perl -ne '/^(.*) (\w+) (\w+)$/;print$1 if((grep /\D+/,($2,$3))!=2)'
I had
perl -ane 'print if (grep /\D+/, @F[-2..-1])!=2;'
but this doesn't strip the user and group from the line.
Also, neither of these deal with newlines in filenames.
Anyone do any better?
Dave
--
#!/usr/bin/perl
@c=map{rand}@n=(0..79);while(print@c=map{(grep/1/,@c[$_-1..$_+1])-2?1:" "}@n){}
#You need and 80char wide display for this Sierpinsky-like CA
------------------------------
Date: 29 Apr 2001 00:19:20 -0400
From: Walt Mankowski <waltman@netaxs.com>
Subject: Re: How to convert integer to string? (Perl newbie)
Message-Id: <87wv84mj7b.fsf@netaxs.com>
David Blair <dblair99@home.com> writes:
> I am trying to write a simple number guessing game in Perl. I need
> to get the random number to between 1 and 10 to use it. I type $randnum
> = int(rand * 10); but that is not satisfactory because it truncates the
> the decimal rather than rounding it. I know about sprintf() but don't
> know how to convert it back to a int to use in an if test against the
> guess. There is no sscanf function like in C, so how would one do this?
You don't need to multiply the value returned by rand; rand can scale
its result itself. From perldoc -f rand...
rand EXPR
rand Returns a random fractional number greater than or
equal to "0" and less than the value of EXPR.
(EXPR should be positive.) If EXPR is omitted,
the value "1" is used.
So
$randnum = rand 10;
will give you a floating point number such that 0 <= $randnum < 10.
Since int returns just the integer portion of a floating point number,
$randnum = int(rand 10);
will give you an integer between 0 and 9. To get an integer between 1
and 10, just add 1 to the expression:
$randnum = int(rand 10) + 1;
------------------------------
Date: 29 Apr 2001 12:21:00 +0800
From: dekuo@hello.com.tw (dekuo)
Subject: How to write a multi process program with perl ?
Message-Id: <9cg4qa$lne$1@news.ethome.net.tw>
How to use fork() system function to fork multi child process at the same time ?
For example:
Run a program to fork 5 child process at the same time and the parent must wait
until all child exit.
The child do some thing like to get remote html page at the same time.
-- CNews 0.39
------------------------------
Date: 29 Apr 2001 10:15:57 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to write a multi process program with perl ?
Message-Id: <9cgpkt$mvf$2@plutonium.btinternet.com>
dekuo <dekuo@hello.com.tw> wrote:
> How to use fork() system function to fork multi child process at the same time ?
>
> For example:
>
> Run a program to fork 5 child process at the same time and the parent must wait
> until all child exit.
>
This shows the principle :
for ( 1 .. 5 )
{
unless ( fork )
{
sleep 5;
print "child $_ exiting\n";
exit 0;
}
}
1 while( wait > 0 );
print "All children finished\n";
read the perlfunc entries for fork() and wait().
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sun, 29 Apr 2001 07:47:24 -0400
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Re: How to write a multi process program with perl ?
Message-Id: <tenvpvrn2ubn16@corp.supernews.com>
I've discovered that 'fork()' does NOT work on windows platforms the way it
does under Unix. Using Active's Perl, the 'fork()' is emulated in very much
less than satisfactory manner. I have tried to write a simple server that
forks after accepting a connection and lets the child do some simple I/O
with the socket. The I/O works when done in the parent but not in the child.
Any ideas on how to solve this problem under Windows?
-David
"Jonathan Stowe" <gellyfish@gellyfish.com> wrote in message
news:9cgpkt$mvf$2@plutonium.btinternet.com...
> dekuo <dekuo@hello.com.tw> wrote:
> > How to use fork() system function to fork multi child process at the
same time ?
> >
> > For example:
> >
> > Run a program to fork 5 child process at the same time and the parent
must wait
> > until all child exit.
> >
>
> This shows the principle :
>
>
> for ( 1 .. 5 )
> {
> unless ( fork )
> {
> sleep 5;
> print "child $_ exiting\n";
> exit 0;
> }
> }
>
> 1 while( wait > 0 );
> print "All children finished\n";
>
> read the perlfunc entries for fork() and wait().
>
> /J\
> --
> Jonathan Stowe |
> <http://www.gellyfish.com> | This space for rent
> |
------------------------------
Date: Sun, 29 Apr 2001 05:19:23 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Infinate loop
Message-Id: <3AEBA56F.8C1BCC3A@earthlink.net>
Ed wrote:
>
> Hello, I am having problems deleting the duplicates from my Ndbm file.
> Is it becuse I can't do it this way (accessing same hash nested and
> deleting entry)? This code just gives an infinite loop! Please help!
> Ed
>
> my $key;
> my $value;
> my %dbm_hash;
> tie(%dbm_hash, 'NDBM_File',
> '/ncl/www/people/e.c.fowler/cgi-bin/Prot2App',O_CREAT|O_RDWR, 0600) or
> die "unableto open file: $!";
> #Step through entry by entry
> while (($key, $value) = each %dbm_hash)
> {
> my $key2;
> my $value2;
> #Step through again (i.e. comparing entries)
> while (($key2, $value2) = each %dbm_hash)
> {
> #Check each entry against every other entry
> if($value eq $value2)
> {
> delete $dbm_hash{$key2};
> }
> }
>
> }
> untie (%dbm_hash);
As others have said, the cause of the problem is the fact that you try
to nest loops which use each on the same hash. A better way to do what
you want would be something like the following:
my (%dbm_hash, %seen);
tie( %dbm_hash, 'NDBM_File',
'/ncl/www/people/e.c.fowler/cgi-bin/Prot2App',
O_CREAT|O_RDWR, 0600 ) or die "unable to open file: $!";
while( my ($key, $value) = each %dbm_hash ) {
if( exists $seen{$value} ) {
push @$seen{$value}, $key;
} else {
$seen{$value} = [];
}
}
while( my ($value, $keys) = each %seen ) {
delete @dbm_hash{ @$keys };
}
Or perhaps:
my (%dbm_hash, %seen, @duplicates);
tie( %dbm_hash, 'NDBM_File',
'/ncl/www/people/e.c.fowler/cgi-bin/Prot2App',
O_CREAT|O_RDWR, 0600 ) or die "unable to open file: $!";
while( my ($key, $value) = each %dbm_hash ) {
push @duplicates{$key}, $key if ++$seen{$value};
}
delete @dbm_hash{ @duplicates };
Oh, and in both cases, you ought to have
#!/usr/local/bin/env perl -w
use strict;
Way up at the top.
--
Shift to the left, shift to the right, mask in, mask out, BYTE, BYTE,
BYTE !!!
------------------------------
Date: Sun, 29 Apr 2001 06:38:58 GMT
From: Mark Rogaski <wendigo@jabberwock.org>
Subject: Re: matrix multiplication
Message-Id: <6GOG6.99608$C55.8813692@news1.rdc1.nj.home.com>
Chris W <chrisw+usenet@dynamite.com.au> wrote:
> news:slrn9ci3i6.7ms.tjla@thislove.dyndns.org...
>> You should read up on mathematical notation. 'iff' means "if and only if."
> Yes, and your point is? My comment stands unaltered.
> 'A matrix can only represent a rotation if and only if the determinate is
> one' does not mean the same as 'all matrices with a determinate of one are
> represent a rotation' which is what Anno Siegel is interpreting it to mean.
According to simple propositional logic, "A iff B" is equivalent to
"(if A, then B) and (if B, then A)".
Mark
--
[] | "Girls in occupied countries always
[] Mark Rogaski | get into trouble with soldiers," she
[] wendigo@pobox.com | said, when I asked her what the Virgin
[] | birth was. -- Florence King, CoaFSL
------------------------------
Date: 29 Apr 2001 10:54:10 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Must send lots of emails
Message-Id: <9cgrsi$mvf$6@plutonium.btinternet.com>
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
> Victor Prasad wrote in comp.lang.perl.misc:
> } Hello,
> }
> } I have a user list of a about 20000. Hopefully on a spreadsheet.
>
> Let's hope this spreadsheet is not in a proprietary format ;-)
>
There's always Spreadsheet::ParseExcel :)
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 29 Apr 2001 11:19:12 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perl variables problem
Message-Id: <9cgtbg$mvf$7@plutonium.btinternet.com>
Sylvain Thevoz <sylvain.thevoz@mcnet.ch> wrote:
> I have a file which contents:
> $a Mr. Smith, how do you do?
>
> I have a perl file which contents:
> $a = "good morning";
> open(FILE, "file.lst");
> while (<FILE>)
> {
> $out .= $_;
> }
> print $out;
>
> My problem:
> when I execute the perl file, it prints "$a Mr. Smith, how do you do?"
>
> But I want to print "good morning Mr. Smith, how do you do?"
>
See the item :
How can I expand variables in text strings?
in perlfaq4
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 29 Apr 2001 12:17:05 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Problem - PERL mail script sends HTML formating as part of plain text message
Message-Id: <9ch0o1$rlp$3@neptunium.btinternet.com>
rthkid <yourguru@whkjcssss.com> wrote:
> I'm trying to have a PERL script email a message with HTML formating.
> The problem is that the HTML is sent as part of the plain text message.
> What command will force it to be sent as intended ?
>
Please see perlfaq1 :
What's the difference between "perl" and "Perl"?
I think you probably want to look at the module MIME::Lite.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sun, 29 Apr 2001 18:24:46 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: re-sizing GIF images on the fly
Message-Id: <_%PG6.13839$482.70214@newsfeeds.bigpond.com>
"Andrew Boswell" <graham@dragroup.com> wrote in message
news:4jnMGwACuB66EAkB@dragroup.com...
> I want to write a Perl script that examines a GIF file to determine the
> image size (width and height in pixels), then creates a thumbnail of it
> on the fly.
http://www.bloodyeck.com/wwwis/ provides a program to dynamically generate
height= and width= tags.
The image parser should be easy to modify for your purposes .
gtoomey
------------------------------
Date: 29 Apr 2001 10:00:20 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: re-sizing GIF images on the fly
Message-Id: <9cgonk$mvf$1@plutonium.btinternet.com>
Graham Stow <graham@letsgouk.com> wrote:
> I think this means that ImageMagick must be installed on the ISPs
> server. This is unnecessary as the Image::Size module can determine the
> original size, and a simple script can then be written to do the
> resizing. Why use a torque wrench when a spanner will do!
Then why do you need to use Image::Size ? If you know enough about the
format of your image files to be able to do the resizing why would you
need to use a module ? Ah you mean *dumbnails* not thumbnails dont you ?
Specify the smaller size of the image in HTML. Complete waste of time in
my opinion. But hey its your website.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sun, 29 Apr 2001 22:50:03 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: re-sizing GIF images on the fly
Message-Id: <slrn9eo3fr.os0.mgjv@martien.heliotrope.home>
On Sat, 28 Apr 2001 13:51:16 +0100,
Graham Stow <graham@letsgouk.com> wrote:
> I think this means that ImageMagick must be installed on the ISPs
> server. This is unnecessary as the Image::Size module can determine the
> original size, and a simple script can then be written to do the
> resizing. Why use a torque wrench when a spanner will do!
I am confused. The GIF format is not a trivial one to work with,
certainly not so trivial that you can claim that 'a simple script' can
be written to resize it, once you know the new size. However, what is
simple, is to parse the first few bytes of a GIF file to determine what
its intended size is.
So, either you know a lot about the image format (which is implied,
since you can write a simple script to resize the image), or you know
nothing, (which is implied because you don't seem to know how to get the
size of the image from the file).
Which is it?
Martien
--
Martien Verbruggen |
Interactive Media Division | In the fight between you and the
Commercial Dynamics Pty. Ltd. | world, back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: 29 Apr 2001 15:53:15 +0200
From: josef.bauer@mchp.siemens.de_NO_SPAM_PLEASE
Subject: script for generating a preview web page for many images
Message-Id: <m3r8ybizhw.fsf@white.mchp.siemens.de>
Hi,
does anybody know of a script that generates a clickable preview HTML
page for (many) images (in a directory)? In the preview page clickable
thumpnails of all images should be given.
The funcionality should be similar to that of Guash (Gimp) or Visual
Schnauzer (xv)?
regards,
Josef
------------------------------
Date: Sun, 29 Apr 2001 10:02:03 +0100
From: Milton Road <miltonroad@btinternet.com>
Subject: Re: Should Perl be first?
Message-Id: <1MQG6.12695$PP3.844238@nnrp3.clara.net>
Perl wasn't my first language. I started out using C and later on, C++.
As such I really appreciate the stuff that Perl gives you for free. I
rarely write C and C++ code these days, although I'm really grateful to
have an idea about what happens at the lower levels.
It sounds like you're having a straight contest between Visual Basic and
Perl right now. Between those two languages, I would definitely recommend
Perl for a number of reasons. Firstly, Perl will run on several platforms,
whereas VB is a Windows-only gig. Secondly, Perl is pretty neat for
developing the Web applications that you want to do - and you can use it
with numerous Web servers. Perl is open-source, meaning that you're not
left at the whims of a single corporate entity who might do a complete
redesign of the language in later revisions. I've not read an amazing
amount about Perl 6 - but the articles I have read suggest that
backwards-compatibility is a high priority.
Money-wise, I'm not sure of the situation where you are. If you're
thinking of undertaking bespoke work for a multitude of clients ( who in
all likeliness, will be sporting different hardware and software
configurations ) then Perl would be better, because it runs on more
platforms. There are plenty of Perl contracts here in the UK - it's fairly
easy to get to most of them - although your mileage may vary - depending on
where you are.
Perl isn't all a bed of roses. There is a lot of reading to do, and the
TMTOWTDI philosophy means that picking up someone elses code can be quite
hellish. Personally, I find myself having to exercise quite a bit of
self-discipline within the language when writing stuff, because it is so
easy to write quick and dirty stuff if you want.
The newsgroup community can be quite elitist at times too, although if you
ask your questions correctly, you'll probably get some good help. Expect a
couple of flambes whilst you get up to speed. Contrast that with the help
that you'll get on the Python newsgroups, and you'll see the difference.
To summarise, if it's a straight fight between Perl and VB, pick Perl. If
you want to get closer to your computer and internals, spend some time with
C too.
Milton.
BUCK NAKED1 wrote:
> I'm wanting to learn a programming language to use mainly for web
> applications, but that could also be used for business applications
> off-line, and hopefully make me some money. I am much older than most of
> you, and probably not as swift (as perhaps evidenced by some of my
> questions in this forum).
>
> I started learning Perl a few months ago, but still have much to learn.
> Friends tell me that VB is THE language to learn. I know a little
> VBScript, but no VB... and of course VBScript is not a programming
> language. I'm confused. Should Perl be the first programming language
> that I should learn? or would you recommend another programming
> language? C++? Java? what?
>
> Your input would be much appreciated.
>
> --Dennis
>
------------------------------
Date: 29 Apr 2001 12:04:22 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: total newbie
Message-Id: <9ch006$rlp$2@neptunium.btinternet.com>
Chris Gunn <cgunn@bizynet.com> wrote:
>
> Why they seem to be unwilling to write that to hard
> drive as an .exe is beyond me.
>
Why would I want to write the file with any particular extension at all ?
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sun, 29 Apr 2001 22:55:01 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: total newbie
Message-Id: <slrn9eo3p5.os0.mgjv@martien.heliotrope.home>
On Wed, 25 Apr 2001 22:40:42 -0500,
Chris Gunn <cgunn@bizynet.com> wrote:
> On Wed, 25 Apr 2001 16:45:39 GMT, gil@nospam-keskydee.com (Gil G.) wrote:
>
>>Hum... If you mean that an interpreter compiles on the fly, sure...
>>As to perly.y, enlight me please..
>
> Howdy Gil,
>
> Everytime your script is executed, Perl verifies its okay and then compiles
> an executable in memory. Why they seem to be unwilling to write that to hard
> drive as an .exe is beyond me. Mostly I think they want your source code to
> be available to borrow whenever anyone wants to.
You don't seem understand what the result of Perl's compilation is. It
has nothing to do with files that on certain platforms often have the
extension "exe". It's a format internally used by Perl. Not bytecode.
$ man perlcompile
$ man perlfaq3
[snip]
How can I compile my Perl program into byte code or C?
Did you think that the end result of all compilations has to be machine
specific bytecode? It may surprise you to know that that is not true in
most cases.
Martien
--
Martien Verbruggen |
Interactive Media Division | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd. | bundled with your Microsoft product.
NSW, Australia |
------------------------------
Date: 29 Apr 2001 10:20:52 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: UDP Packets with zero checksum
Message-Id: <9cgpu4$mvf$3@plutonium.btinternet.com>
In comp.lang.perl.misc Max Heimer <mheimer@gmx.at> wrote:
> hi!
>
> is there anybody who can give me a hint how to
> create udp-packets, and send it to a host,
> where the _checksum field_ is set to zero.
> if i use socket, i've no control on the
> checksum field.
>
You should be able to use Net::RawIP to do this - you will also need to
have libpcap installed.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sun, 29 Apr 2001 09:46:51 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: use strict.. bugger!
Message-Id: <fqRG6.51082$Xx3.290036@news1.eburwd1.vic.optushome.com.au>
Howdy all!
Why can I do this?
use strict;
if ($a || bugger off)
{
print "true || bugger off = true\n";
}
OUTPUT:
true || bugger off = true
But not this?
use strict;
if ($a || buggeroff)
{
print "true || buggeroff = true\n";
}
OUTPUT:
Bareword "buggeroff" not allowed while "strict subs" in use at or_test.pl
line 30.
Execution of or_test.pl aborted due to compilation errors.
I am using ActivePerl for Windows..
C:\WINDOWS>perl -v
This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2000, Larry Wall
Rob..
:)
------------------------------
Date: Sun, 29 Apr 2001 10:55:22 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: use strict.. bugger!
Message-Id: <slrn9eo0lb.38t.tjla@thislove.dyndns.org>
"mein Luftkissenfahrzeug ist voll von den Aalen"
said Rob () in
<fqRG6.51082$Xx3.290036@news1.eburwd1.vic.optushome.com.au>:
>Howdy all!
>
>Why can I do this?
>
>use strict;
>if ($a || bugger off)
>{
> print "true || bugger off = true\n";
>}
>
>OUTPUT:
>true || bugger off = true
Only if $a has a true value. Try putting $a = 0 above the if statement.
$a is exempt from use strict 'vars' by the way (see perldoc -f sort) so
you might want a different variable name for general use.
Try doing this as well:
use strict;
use O(Deparse);
$a = 1;
if ($a || bugger off)
{
print "some stuff\n";
}
The Deparse module will tell you what Perl *thinks* you want your code
to do. In this case the "bugger off" bit looks like you are attempting
to call the method named 'bugger' in the 'off' package. This is
evaluated at run-time, but not if $a has a true value.
>But not this?
>use strict;
>if ($a || buggeroff)
>{
> print "true || buggeroff = true\n";
>}
In this case, the "buggeroff" is treated like a bareword identifier.
Read all about it:
perldoc strict
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
We have the power to make this the best generation of mankind
in the history of the world - or to make it the last.
-- John F. Kennedy
------------------------------
Date: Sun, 29 Apr 2001 17:41:09 +1000
From: "Matt Morton-Allen" <m2@csu.edu.au>
Subject: XML::RSS and mod_perl
Message-Id: <%xPG6.16$t61.1376@news0.optus.net.au>
Hi All,
I am trying to use XML::RSS under mod_perl but keep getting a segfault. The
error occurs only on the call to the parse method. Anyone experienced this?
Matt.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 793
**************************************