[19288] in Perl-Users-Digest
Perl-Users Digest, Issue: 1483 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 10 06:05:38 2001
Date: Fri, 10 Aug 2001 03:05:11 -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: <997437911-v10-i1483@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 10 Aug 2001 Volume: 10 Number: 1483
Today's topics:
Re: Advise on using perl to sort and give totals (Anno Siegel)
bitvector functionality question <ddb@R3401.rlem.titech.ac.jp>
Re: bitvector functionality question (wade)
Re: Can I make methods private/public? <joe+usenet@sunstarsys.com>
Re: Can't Negate Regex /^8([0876])\1\d+$/ <krahnj@acm.org>
Email +Perl <ryan@bong.net>
Re: error with signal handling (Villy Kruse)
Re: error with signal handling (Martien Verbruggen)
Re: FAQ: How can I expand variables in text strings? (David Combs)
FAQ: How do I flush/unbuffer an output filehandle? Why <faq@denver.pm.org>
Re: help with hash <ts@tms.cc>
Re: help with hash (E.Chang)
Re: I need help with one last thing. (wade)
Re: ImageMagick, Tk, and PNG ---- HELP <sky@mail.lviv.ua>
Is an element in a table ? plop740@mail.ru
Re: Is an element in a table ? <philippe.perrin@sxb.bsf.alcatel.fr>
Re: Is it a number? <philippe.perrin@sxb.bsf.alcatel.fr>
Re: Is this a Perl bug? (Martien Verbruggen)
Re: Is this a Perl bug? <samneric@tigerriverOMIT-THIS.com>
Re: Matching Strings in an array <ahamm@sanderson.net.au>
Newsletter Script <ommadawn@club-internet.fr>
Poor man's HTML hidden field message digest?? <miscellaneousemail@yahoo.com>
Re: Poor man's HTML hidden field message digest?? (Eric Bohlman)
Re: q: converting strings (Anno Siegel)
Reading a NT directory from Unix (Anders Hertz)
Re: reading Powerpoint with Win32::OLE? <shaofeng.li@esf.ericsson.se>
Re: Reporting Questionable Programming Activity (David Combs)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Aug 2001 07:14:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Advise on using perl to sort and give totals
Message-Id: <9l01l4$3ur$1@mamenchi.zrz.TU-Berlin.DE>
According to Ren Maddox <ren@tivoli.com>:
> On 9 Aug 2001, anno4000@lublin.zrz.tu-berlin.de wrote:
>
> > According to sammy <sammy@bigpond.net.au>:
>
> [snip]
>
> >> #!/usr/local/bin/perl -wl
> >> $_{(split)[0]}++ while (<>);
> >> print "$_\t$_{$_}" for sort { $_{$b} <=> $_{$a} } keys %_;
>
> [snip]
>
> > It also contains a subtle blunder: The parens around <> in the
> > second line make it slurp the whole file.
>
> What makes you say that? Those parens don't change the context.
> Parens seldom (never?) change the context of what the contain.
You re quite right, sorry. The parens are just superfluous, they
don't hurt.
Anno
------------------------------
Date: Fri, 10 Aug 2001 13:50:01 +0900
From: Douglas du Boulay <ddb@R3401.rlem.titech.ac.jp>
Subject: bitvector functionality question
Message-Id: <3B7367F9.F843AB27@R3401.rlem.titech.ac.jp>
I am new to using perl string bitvectors i.e. vec() operations and I was
wondering
is there any way to add bitvectors i.e. an addition "+" function , or
is there a
a way to apply shift right and shift left operations on these
bitvectors?
The perl man pages don't seem to cover such things that I can see.
Thanks in advance.
Doug
------------------------------
Date: 10 Aug 2001 02:42:16 -0700
From: jjchen@alumni.ice.ntnu.edu.tw (wade)
Subject: Re: bitvector functionality question
Message-Id: <4259465b.0108100142.6bf62b99@posting.google.com>
Douglas du Boulay <ddb@R3401.rlem.titech.ac.jp> wrote in message news:<3B7367F9.F843AB27@R3401.rlem.titech.ac.jp>...
> I am new to using perl string bitvectors i.e. vec() operations and I was
> wondering
> is there any way to add bitvectors i.e. an addition "+" function , or
> is there a
> a way to apply shift right and shift left operations on these
> bitvectors?
>
> The perl man pages don't seem to cover such things that I can see.
>
> Thanks in advance.
> Doug
Using perl to do BIT operations is seems not a good idea.
If you want, try using pack/unpack to tranfer "number" to digit.
There are |, & operators for BIT operations.
------------------------------
Date: 10 Aug 2001 00:22:46 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Can I make methods private/public?
Message-Id: <m3wv4cbl2h.fsf@mumonkan.sunstarsys.com>
Benjamin Goldberg <goldbb2@earthlink.net> writes:
> You can also use local.
How?
> package SomePackage;
>
> local *private = sub {
> ....
> }
> sub public {
> private(@some_args);
> }
> __END__
That probably won't work as written, since ...
>
> At the end of the file, the local *private goes out of scope, so it
> dissapears from the namespace then; Things outside of the package can't
> see it.
which means code like this
use SomePackage;
SomePackage::public(0..9);
will wind up producing a fatal error:
% perl -wle 'BEGIN{
package Foo;
local *goner = sub{ scalar @_ };
sub args { goner(@_) } # line 4
}
print Foo::args(1..10), "OK";
'
Undefined subroutine &Foo::goner called at -e line 4.
If you want to privatize some subs in a module, one approach might be
to remove entries from the symbol table by using a BEGIN block:
% cat Foo.pm
package Foo;
sub private { scalar @_ }
sub args { private(@_) }
BEGIN {
my @clobber = qw/ private /; # list of subs to privatize
delete @Foo::{@clobber};
}
1;
__END__
% perl -mFoo -wle 'print Foo::args(1..10)'
10
% perl -mFoo -wle 'print Foo::private(1..10)'
Undefined subroutine &Foo::private called at -e line 1.
%
--
Joe Schaefer "A little inaccuracy sometimes saves a ton of explanation."
-- H. H. Munro (Saki)
------------------------------
Date: Fri, 10 Aug 2001 04:07:38 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Can't Negate Regex /^8([0876])\1\d+$/
Message-Id: <3B735E6D.4C08E1B7@acm.org>
Victor Araujo wrote:
>
> I am trying to negate the following regex which I am using
> to filter toll free numbers. The regex seems to work fine as
> is but when I try to negated it won't work.
>
> $regex =~ /^8([0876])\1\d+$/;
>
> even though I have tried many different combinations like
>
> /^[^8([0876])\1]\d+$/
> /^[^8([0876])]\1\d+$/
>
> I can't get it to work properly. Any help is welcome.
$regex =~ /^(?!8([0876])\1)\d+$/
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 10 Aug 2001 07:15:48 GMT
From: "Ryan Gralinski" <ryan@bong.net>
Subject: Email +Perl
Message-Id: <ESLc7.2370$5d2.8598@news1.wwck1.ri.home.com>
I'm writing a webmail program, and i got to the point where to display the
messages from a POP3 server..
Is there a special module to help display the message
, for instance this is a sample message from the pop3 server., i need to
know if theres a module allready written to display the text/html portion.
This is a multi-part message in MIME format.
------=_NextPart_000_000A_01C101AF.944A81E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
WHATS UP
IM JUST EMAILIN U TO SAY SUP
CAN U EMAIL ME BACK WIT YOUR INFO=20
PEACE
------=_NextPart_000_000A_01C101AF.944A81E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
WHATS UP
IM JUST EMAILIN U TO SAY =
SUP
CAN U EMAIL ME BACK WIT YOUR INFO =
PEACE
------=_NextPart_000_000A_01C101AF.944A81E0--
------------------------------
Date: 10 Aug 2001 07:01:52 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: error with signal handling
Message-Id: <slrn9n71n0.hd7.vek@pharmnl.ohout.pharmapartners.nl>
On 9 Aug 2001 11:17:32 -0700,
yawnmoth <terra1024@yahoo.com> wrote:
>
>I added sleep(1); to it, but that makes it kinda slow. Adding
>sleep(.2) or sleep(.9) doesn't seem to have any effect - it goes just
>as fast as it did before (I'm guessing it thinks that .2 is equiv to
>0). Is there anyway I can make it a tad faster, but not to fast, or
>would this be machine dependant, upon the number of proccessors and
>types?
If I'm not mistaken sleep(.9) is the same as sleep (int (.9))
which is the same as sleep(0).
See perldoc -f sleep for suggested alternatives, but an interface to
the POSIX function nanosleep might not be such a bad idea on systems
that supports it.
Villy
------------------------------
Date: Fri, 10 Aug 2001 18:42:35 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: error with signal handling
Message-Id: <slrn9n77jr.cq.mgjv@martien.heliotrope.home>
On 10 Aug 2001 07:01:52 GMT,
Villy Kruse <vek@pharmnl.ohout.pharmapartners.nl> wrote:
> On 9 Aug 2001 11:17:32 -0700,
> yawnmoth <terra1024@yahoo.com> wrote:
>
> See perldoc -f sleep for suggested alternatives, but an interface to
> the POSIX function nanosleep might not be such a bad idea on systems
> that supports it.
Want to patch the POSIX module and send the patch to p5p? :)
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: 10 Aug 2001 08:44:12 GMT
From: dkcombs@panix.com (David Combs)
Subject: Re: FAQ: How can I expand variables in text strings?
Message-Id: <9l06ss$lh8$1@news.panix.com>
<SNIP>
In article <u9lml272rz.fsf@wcl-l.bham.ac.uk>, <nobull@mail.com> wrote:
>
>The FAQ really should mention:
>
> If you want not only to expand simple variables but want the full
> power of Perl's double-qouted interpolation then:
>
> # Assume $text does not contain "\n__EOD__\n"
> chop( $text = eval "<<__EOD__\n$text\n__EOD__" );
> die if $@;
>
> This allows $text to contain arbintrary Perl code (for example
<SNIP>
Uh, when, if ever, are these super suggestions
and modifications actually INCORPORATED into the
faqs, so that people can *benefit* from them,
and learn the stuff a little better.
And if they do in fact get incorporated,
where can we find the (beta of) the updated
version.
Or diff.
Or annotated diff (even better).
THANKS!
David
------------------------------
Date: Fri, 10 Aug 2001 06:17:02 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I flush/unbuffer an output filehandle? Why must I do this?
Message-Id: <y%Kc7.59$B2j.185174016@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How do I flush/unbuffer an output filehandle? Why must I do this?
The C standard I/O library (stdio) normally buffers characters sent to
devices. This is done for efficiency reasons so that there isn't a
system call for each byte. Any time you use print() or write() in Perl,
you go though this buffering. syswrite() circumvents stdio and
buffering.
In most stdio implementations, the type of output buffering and the size
of the buffer varies according to the type of device. Disk files are
block buffered, often with a buffer size of more than 2k. Pipes and
sockets are often buffered with a buffer size between 1/2 and 2k. Serial
devices (e.g. modems, terminals) are normally line-buffered, and stdio
sends the entire line when it gets the newline.
Perl does not support truly unbuffered output (except insofar as you can
"syswrite(OUT, $char, 1)"). What it does instead support is "command
buffering", in which a physical write is performed after every output
command. This isn't as hard on your system as unbuffering, but does get
the output where you want it when you want it.
If you expect characters to get to your device when you print them
there, you'll want to autoflush its handle. Use select() and the "$|"
variable to control autoflushing (see perlvar/$ and the select entry in
the perlfunc manpage):
$old_fh = select(OUTPUT_HANDLE);
$| = 1;
select($old_fh);
Or using the traditional idiom:
select((select(OUTPUT_HANDLE), $| = 1)[0]);
Or if don't mind slowly loading several thousand lines of module code
just because you're afraid of the "$|" variable:
use FileHandle;
open(DEV, "+</dev/tty"); # ceci n'est pas une pipe
DEV->autoflush(1);
or the newer IO::* modules:
use IO::Handle;
open(DEV, ">/dev/printer"); # but is this?
DEV->autoflush(1);
or even this:
use IO::Socket; # this one is kinda a pipe?
$sock = IO::Socket::INET->new(PeerAddr => 'www.perl.com',
PeerPort => 'http(80)',
Proto => 'tcp');
die "$!" unless $sock;
$sock->autoflush();
print $sock "GET / HTTP/1.0" . "\015\012" x 2;
$document = join('', <$sock>);
print "DOC IS: $document\n";
Note the bizarrely hardcoded carriage return and newline in their octal
equivalents. This is the ONLY way (currently) to assure a proper flush
on all platforms, including Macintosh. That's the way things work in
network programming: you really should specify the exact bit pattern on
the network line terminator. In practice, ""\n\n"" often works, but this
is not portable.
See the perlfaq9 manpage for other examples of fetching URLs over the
web.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
05.01
--
This space intentionally left blank
------------------------------
Date: Fri, 10 Aug 2001 00:31:07 -0400
From: Tom <ts@tms.cc>
Subject: Re: help with hash
Message-Id: <3B73638B.2659C3BE@tms.cc>
Sorry for my ignorance, I'm new to Perl.
What does '$file{$filename}++;' mean?
Thanks,
"E.Chang" wrote:
> "Ryan Gralinski" <ryan@bong.net> wrote in
> <iooc7.1547$5d2.4587@news1.wwck1.ri.home.com>:
>
> > can someone help me out,
> > i have a list of files downloaded off my web site
> >
> > i read in the file, and store it like this..
> > while($filename=<thelist>)
> > {
> > chomp $filename;
> > $file{$filename}++;
> > }
> > close thelist;
> >
> >
> >
> > now how can i find out what the largest one is, as in which file was
> > downloaded most, the biggest of all the $file s
>
> Just go through the hash keeping track of the largest number you have
> found. When you find a larger one, replace it.
>
> my $lgst_so_far, $lgst_file;
> foreach (keys %file) {
> if ($file{$_} > $lgst_so_far){
> $lgst_so_far = $file{$_};
> $lgst_file = $_;
> }
> }
>
> print "Most downloads $lgst_so_far for file $lgst_file";
>
> --
> EBC
------------------------------
Date: Fri, 10 Aug 2001 04:48:49 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: help with hash
Message-Id: <Xns90F98D84592Bechangnetstormnet@207.106.93.86>
Tom <ts@tms.cc> wrote in <3B73638B.2659C3BE@tms.cc>:
>
>Sorry for my ignorance, I'm new to Perl.
Please don't top-post. Insert your replies and questions at the
appropriate place in the quoted text so the next reader can more
readily understand your refences. I moved your question so it follows
the code to which you were referring.
>
>"E.Chang" wrote:
>
>> "Ryan Gralinski" <ryan@bong.net> wrote in
>> <iooc7.1547$5d2.4587@news1.wwck1.ri.home.com>:
>>
>>> can someone help me out,
>>> i have a list of files downloaded off my web site
>>>
>>> i read in the file, and store it like this..
>>> while($filename=<thelist>) {
>>> chomp $filename;
>>> $file{$filename}++; }
>
>What does '$file{$filename}++;' mean?
>
The script is using a hash which the programmer chose to name %file - I
personally would have chosen a less generic-seeming variable name. The
keys are the file names read from the filehandle theList and the values
are used to count the number of times each file name is found.
$file{$filename} is the hash value for the key $filename and ++
increments the value.
hashes are a key data structure in Perl - read up on them in the
documentation (perldata manpage or at
http://www.perldoc.com/perl5.6/pod/perldata.html)
>>> close thelist;
>>>
>>> now how can i find out what the largest one is, as in which file
>>> was downloaded most, the biggest of all the $file s
>>
>> Just go through the hash keeping track of the largest number you
>> have found. When you find a larger one, replace it.
>>
>> my $lgst_so_far, $lgst_file;
>> foreach (keys %file) {
>> if ($file{$_} > $lgst_so_far){
>> $lgst_so_far = $file{$_};
>> $lgst_file = $_;
>> }
>> }
>>
>> print "Most downloads $lgst_so_far for file $lgst_file";
--
EBC
------------------------------
Date: 10 Aug 2001 02:35:36 -0700
From: jjchen@alumni.ice.ntnu.edu.tw (wade)
Subject: Re: I need help with one last thing.
Message-Id: <4259465b.0108100135.7569dbb8@posting.google.com>
"Stephen Edelblut" <viper16336@mindspring.com> wrote in message news:<9kvl2n$1ga$1@slb4.atl.mindspring.net>...
> My form works, all I need it to do is after it loads the cgi file it:
> open FILE,">>../www/file.txt";
> print FILE "$name: $message\n";
> close FILE;
>
> print $q->header("text/html"),
> $q->start_html("results"),
> $q->p("Done."),
> $q->end_html;
>
> displays "done". How do I get it to redirect the window to my 'file.txt'? It
> wont work if I use regular html. Thanks
Not sure what you want. Why don't you try output 'file.txt' to your $q?
or, you can print a header such as :
# after 3 sec, "Done." will disappear then change to file.txt
<meta HTTP-EQUIV="REFRESH" CONTENT="3;URL=file.txt">
------------------------------
Date: Fri, 10 Aug 2001 11:52:29 +0300
From: Roman Khutkyy <sky@mail.lviv.ua>
Subject: Re: ImageMagick, Tk, and PNG ---- HELP
Message-Id: <3B73A0CD.C139B9F5@mail.lviv.ua>
I solved my problem alone. It wasn't in Tk.
I just tried two kinds of filename.
The problem was that in first case i pointed the filename to
save as finemane.png, in second i used the full path:
D:\probe\filename.png.
When used filename without path Image::Magic treats the output
file synonymously as PNG file, but when used full path it's
nessesery to point :
$image->write(magick=>PNG, filename=>$file_with_path);
________________________________________________________
Thanks to all. Sorry for disturbance...
------------------------------
Date: Thu, 09 Aug 2001 23:04:34 +0000
From: plop740@mail.ru
Subject: Is an element in a table ?
Message-Id: <pj56ntgu7kn27gvorbgudpuk6u8l31m8vq@4ax.com>
Hi,
I have 2 lists of data: list A and list B
What's the quickest way to see if, and how many elements of A are in B
?
Thanks for your help !
Igor
------------------------------
Date: Fri, 10 Aug 2001 09:33:03 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Re: Is an element in a table ?
Message-Id: <3B738E2F.B95E1F9B@sxb.bsf.alcatel.fr>
Here is my solution... there must be better :
$n = 0;
foreach (@listA) { # if @listA is smaller
$n += grep(/^$_$/, @listB);
}
plop740@mail.ru wrote:
>
> Hi,
>
> I have 2 lists of data: list A and list B
>
> What's the quickest way to see if, and how many elements of A are in B
> ?
>
> Thanks for your help !
>
> Igor
--
PhP
------------------------------
Date: Fri, 10 Aug 2001 08:34:01 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Re: Is it a number?
Message-Id: <3B738059.D55ED257@sxb.bsf.alcatel.fr>
Bart Lateur wrote:
> >for float : $x =~ /^(\d+)(\.?)(\d*)$/;
>
> Why the parens?
easier to read + easier to retrieve the integer part ($1) and the
floating part ($3)
> Plus: you may just allow a "-" sign. Provisions for an exponent
> (/[eE][+-]?\d+/) could be added too. And finally, you might allow a
> sting like ".1" as well.
true.
let's add "-" and the .1 : /^(-?)(\d*)(\.?)(\d*)\d?$/;
(allows number of type
1.
.1
1.1
1
)
--
PhP
------------------------------
Date: Fri, 10 Aug 2001 18:44:20 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Is this a Perl bug?
Message-Id: <slrn9n77n4.cq.mgjv@martien.heliotrope.home>
Subject: Re: Is this a Perl bug?
I think you have a bug in your newsreader:
On Fri, 10 Aug 2001 07:14:40 GMT,
flamencoman@earthlink.net <flamencoman@earthlink.net> wrote:
>
> ----=_3b7389fd72248580250c5a4.MFSBCHJLHS
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
you posted unreadable crap to clp.misc. Please don't do this again. if
you want to post a program, post its source code as part of the message
body. Do not post multipart MIME attachments.
Martien
--
Martien Verbruggen |
Interactive Media Division | I used to have a Heisenbergmobile.
Commercial Dynamics Pty. Ltd. | Every time I looked at the
NSW, Australia | speedometer, I got lost.
------------------------------
Date: Fri, 10 Aug 2001 04:44:13 -0400
From: Samneric <samneric@tigerriverOMIT-THIS.com>
Subject: Re: Is this a Perl bug?
Message-Id: <3B739EDD.D4631F8A@tigerriverOMIT-THIS.com>
flamencoman@earthlink.net wrote:
> I don't get it. Why does Perl balk when it sees this long string. I've
> included both the perl script and the html file as attachments. I have
> run this on Windows98, Windows2000, and UNIX with the same result.
It's not a perl bug. You told perl to skip this VERY long line (no lf's,
cr's).
The line in question begins: CLASS="Code"><!-- $MVD$:spaceretainer()
-->
You told perl to skip it when you wrote this line of code:
if($curr =~ /<!-- \$MVD\$/i){next;}
You evidently intended that line of code to only be applied between the
<HEAD>..</HEAD> tags, but like all "buggy" programming languages perl
does what you told it to do - not what you intended it to do :)
BTW, there is no <\HEAD> tag in HTML.
------------------------------
Date: Fri, 10 Aug 2001 17:47:25 +1000
From: "Andrew Hamm" <ahamm@sanderson.net.au>
Subject: Re: Matching Strings in an array
Message-Id: <3b7391f8$1@news.iprimus.com.au>
Yves Orton wrote in message
<74f348f7.0108080459.30d90616@posting.google.com>...
>
>Yes I remember seeing one of friends fathers doing APL on a line
>terminal. He had a great printout on the wall:Torture the Data long
>enough it will confess to anything. (He's a prof of statistics)
>
heheh - can you post his name so I can attribute him in my next signature?
Quoting a professor sounds like a good idea ;-)
>> $self->{param} = shift if @_;
>> return $self->{param};
>>
>And while I agree with your point, I have to admit that the other is
>sooo much easier to type.
>
hmmm - that one up there is short too
>Oops, maybe I should rewrite some of my modules. ;-) No really, i
>think the key is that the key is commenting. One or two clear
>comments strategically placed can make the most magical of notation
>clean and clear.
>
One ideal to aspire to is that at least 30% of the lines are comments.
Hah!-)
>On the other
>hand I recently got into a bit of a debate with a colleague about
>enormous nested and layered ifs. Like so
>
>if ($file_open) {
> #code;
> if ($file_type_correct) {
> #code
> if ($data_type_correct) {
> #code
> if ($dbi_updated) {
> #Do something
> return $something;
> }
> }
> }
>}
>return undef;
>
>I changed it something like this
>
>return undef unless $file_open;
>#code;
>return undef unless $file_type_correct;
>#code;
>return undef unless $data_type_correct;
>#code;
>return undef unless $dbi_updated;
>return $something;
>
Yup - the big ifs is ugly, and surely can't be called better than the return
chains. Although I know the C.S. purists will insist it is. I like the
do-stuff or return/next/last ;
more stuff
style too.
What ever makes sense.
Cheers. We're probably getting too philosophical to continue much longer in
this arena.
--
Space Corps Directive #003
By joining Star Corps. each individual tacitly consents to give up his
inalienable rights to life, liberty, and adequate toilet facilities.
-- Red Dwarf
------------------------------
Date: Fri, 10 Aug 2001 11:55:10 +0100
From: "Sgluarb" <ommadawn@club-internet.fr>
Subject: Newsletter Script
Message-Id: <9l0b2l$im3$1@reader1.imaginet.fr>
Hi,
Somebody have a newsletter script to send mail ( with text and HTML) ?
PS1: Our NewsLetter email list is about 10 000 persons
PS2: ActivePerl 5.6
------------------------------
Date: Fri, 10 Aug 2001 08:56:02 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Poor man's HTML hidden field message digest??
Message-Id: <MPG.15dd4f5254b5770f989724@news.edmonton.telusplanet.net>
Hi everyone,
I am trying to come up with a simple way to check whether a hidden field
in my HTML form has been tampered with. The hidden field is not so
critical that I need to use something like a full blown RSA message
digest generating algorithm.
Below is some code I have been playing with. It is not exactly what I
intend to use but it conveys the essence of it.
I am wondering first off why my if comparison (in my Perl script) doesn't
work? The number 24.9473684210533 appears on the screen yet when I run a
comparision for this number I get a false value. Am I getting rounding
errors?
Is a double precision number guaranteed by Perl to be consistently the
same value accross platforms?
Lastly what about the simple idea in my code? Any comments on the
relative security or insecurity of such an approach? The "key" strings
(not neccessarily the ASCII values in the code below) would be kept in a
Perl script on the server and would not be readable from the web. The
"key" strings would also change from time to time.
I cannot think of a way that someone could change either hidden HTML
field without affecting the value of the equation that I would check for.
HTML snippet:
<input type="hidden" name="type_of_submission" value="initial">
<!-- hidden_ID is used to make sure that the type_of_submission is not
tampered with -->
<input type="hidden" name="hidden_ID" value="A3rT7">
Perl script (just testing the securing of strings as in my HTML snippet):
#!/usr/bin/perl -w
use CGI::Carp qw(carpout fatalsToBrowser);
use diagnostics;
use strict;
# ASCII values for string "initial" used.
my $ASCII_type_of_submission = 105 - 110 + 105 + 116 - 105 + 97 + 108;
# ASCII values for string "A3rT7" used.
my $ASCII_hidden_ID = 65 * 51 / 114 - 84 + 55;
my $key_value = $ASCII_type_of_submission * $ASCII_hidden_ID;
print $key_value."\n";
if ($key_value == 24.9473684210533) {
print "Hidden field OK!";
}
else {
print "Hidden field was tampered with!";
}
Comments on any of this would be appreciated. Thanks.
--
Carlos
www.internetsuccess.ca
------------------------------
Date: 10 Aug 2001 09:31:40 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Poor man's HTML hidden field message digest??
Message-Id: <9l09ls$qqv$9@bob.news.rcn.net>
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
> I am wondering first off why my if comparison (in my Perl script) doesn't
> work? The number 24.9473684210533 appears on the screen yet when I run a
> comparision for this number I get a false value. Am I getting rounding
> errors?
Yep. One of the first practical lessons programmers learn about floating
point arithmetic is that you never compare two floating-point numbers for
exact equality unless you're sure that they hold whole numbers. Try this
for kicks:
my $i=0;
while ($i!=1) {
print "$i\n";
$i+=.1;
}
------------------------------
Date: 10 Aug 2001 08:39:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: q: converting strings
Message-Id: <9l06kp$88t$1@mamenchi.zrz.TU-Berlin.DE>
According to Alan Barclay <gorilla@elaine.furryape.com>:
> There were two seperate sets of gymphs used at this time, called
^^^^^^
"glyphs"?
Anno
------------------------------
Date: Fri, 10 Aug 2001 09:55:44 GMT
From: ahz.ReMoVe@aub.auc.dk (Anders Hertz)
Subject: Reading a NT directory from Unix
Message-Id: <3b73ae6f.186047241@sunsite.dk>
Hiya
What modules should I look further upon if I have to do the following:
Checking if a file exists on a machine running Windows NT Workstation.
The file is in a shared directory (maybe also reading it could be
necessary).
The NT directory is shared.
Using TCP/IP
I am administrator both on Unix and the NT
Not using client/server programming
The program is run from Unix
Written in Perl (of course .-))
Samba is installed on the Unix box, but not all clients has access to
it.
Anders (Denmark)
------------------------------
Date: Fri, 10 Aug 2001 09:29:24 +0200
From: "Shaofeng Li" <shaofeng.li@esf.ericsson.se>
Subject: Re: reading Powerpoint with Win32::OLE?
Message-Id: <9l01df$3hn$1@newstoo.ericsson.se>
I think the PowerPoint Frame window has to be activated before opening the
document.
Try this:
my $App = Win32::OLE->new('PowerPoint.Application', 'Quit');
$App->{Visible} = 1;
$App->Activate();
my $Pres = $App->Presentations->Open($file);
--
Shaofeng.
------------------------------
Date: 10 Aug 2001 08:49:41 GMT
From: dkcombs@panix.com (David Combs)
Subject: Re: Reporting Questionable Programming Activity
Message-Id: <9l0774$lh8$2@news.panix.com>
In article <hkxa7.207864$2O6.13515289@news2.aus1.giganews.com>,
Jay Flaherty <fty@mediapulse.com> wrote:
>"Smiley" <gurm@intrasof.com> wrote in message
>news:3b672381.218715906@news1.on.sympatico.ca...
>> The company I'm working for purchased a Perl CGI Script that turns out
>> to be seriously faulty - so much so that my boss asked me to
>> investigate whether there's any international agency or organization
>> set up that we can report this kind of thing to.
>>
>> Does anybody know? Thanks :)
>>
>
>Like an *International* lemon law? :-)
>
>
I thought a "lemon law" made it *illegal* to complain
in an extremely-public way, eg by driving around in
a (buggy) car with a big lemon painted on each door.
It was a *long* time ago that I read that -- and
I might have gotten it wrong, eg by 180 degrees.
David
------------------------------
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 1483
***************************************