[8865] in Perl-Users-Digest
Perl-Users Digest, Issue: 2482 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 3 11:06:10 1998
Date: Sun, 3 May 98 08:00:41 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 3 May 1998 Volume: 8 Number: 2482
Today's topics:
Re: 1701 days hath September (was: Re: rename funciton) (John Stanley)
Re: 1701 days hath September (was: Re: rename funciton) (Nathan V. Patwardhan)
Re: 1701 days hath September (was: Re: rename funciton) <nospam@no.where>
Re: 1701 days hath September (was: Re: rename funciton) <flavell@mail.cern.ch>
Re: 1701 days hath September (was: Re: rename funciton) (Stefaan A Eeckels)
Re: Array of Arrays, sorting and using (bernd wolfsegger)
Backend (B) compiler in Perl5004.64. Need Help! <fenyvesi@cadvision.com>
Re: Converting COBOL Comp-3 field <bcoleman@mindspring.com>
Re: editor? (Alex Dong Li)
Re: editor? (Gabor)
Exporting vs. "direct" access (John Siracusa)
Re: Exporting vs. "direct" access <jdf@pobox.com>
Re: HELP win32 perl (Shawn )
HEX to BCD <btate@primary.net>
Re: HEX to BCD (Stefaan A Eeckels)
Re: How to read command line literally? <bcoleman@mindspring.com>
Re: Huge array/Win32::NetAdmin::GetUsers (Excession)
Interrupts ... or whatever they are called (Pablo Hortal)
Re: looking for a little bit of help here. Thanks. (Shawn )
Re: looking for a little bit of help here. (Shawn )
Re: Newbie config CGI question (Jonathan Stowe)
Re: Newbie config CGI question <webmaster@fccjmail.fccj.org>
Pb with an array in a PERL Object (bis) <steve. lhomme@nordnet.fr>
Re: Pb with an array in a PERL Object (bis) <dcameron@bcs.org.uk>
PB with an array in a PERL object <steve. lhomme@nordnet.fr>
Re: regex help - Follow-up <webmaster@fccjmail.fccj.org>
Re: regex help <webmaster@fccjmail.fccj.org>
Serial port ... again (Pablo Hortal)
Re: Test httpd server status (Robert Watkins)
Re: Using the -- notation? <ariels@mangal.cs.huji.ac.il>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 May 1998 07:22:51 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6ih60b$55l$1@news.NERO.NET>
In article <354BFFC5.E2D597AA@coos.dartmouth.edu>,
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
>
>And there are people who can't afford the time to read and post to USENET, and
>people who can't afford a computer to post to USENET, and people who...
And if you read what you have said, you will notice that you mentioned
costs of using news that apply to using news.
If you read what I have said, you will notice that it refers to costs
associated with EMAIL that result from using news. In case you didn't
realize it, email is not news.
>Yes, it is a choice. TANSTAAFL. There are always costs. It's your decision
>whether you are willing to pay those costs.
It is clear you have accepted the cost of using news. I expect that you
will also accept the cost of collect phone calls from anyone who wants
to call you about an article you posted. What? That isn't the same
medium? Phone calls aren't USENET? You didn't expect that you should
have to pay that cost?
How odd. You expect people to put up with extra costs from spam email,
just on the off chance that you might want to send them email.
>No one would be prevented from using the moderated newsgroup.
Except those for whom the cost of getting spammed is more than they can
afford.
>Anyone who
>doesn't has made a choice not to, for whatever reason.
Just like I said, those who can't fathom that it might cost people real
money to receive spam tend to word this as "choice".
------------------------------
Date: 3 May 1998 13:20:51 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6ihqvj$9ra@fridge.shore.net>
Lloyd Zusman (ljz@asfast.com) wrote:
: But now that we've been enlightened, I'm disappointed to find that
: it's just more gratuitous anti-"newbie" snobbery.
Wheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee!
Here we go again.
--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov
------------------------------
Date: 03 May 1998 09:58:18 -0400
From: Reply to unauthorized spam <nospam@no.where>
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <ltiunncv7p.fsf@no.where>
stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
> Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
> >
> > [ ... ]
> >
> >No one would be prevented from using the moderated newsgroup.
>
> Except those for whom the cost of getting spammed is more than they can
> afford.
You seem to forget that everyone in the world with usenet access would
be able *read* the spam-free c.l.p.moderated newsgroup. The only
restrictions on that group would concern *posting*. This is how all
moderated usenet newsgroups work. Therefore, every usenet user in the
world would benefit from the lower costs of reading a spam-free,
Perl-based newsgroup.
Secondly, even if you post to a moderated newsgroup, your email
address would be present on the post just like it would be present in
a non-moderated newsgroup. So, the chances of someone pulling your
address off of a post of yours in a moderated newsgroup and then
spamming you with email are the same as if your post were in a
non-moderated group.
And finally, everyone is accruing the costs you mention right now when
they read c.l.p.misc, even though c.l.p.moderated doesn't exist yet.
For all these reasons, I don't consider your "costs" argument to be
valid.
> [ ... ]
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: Sun, 3 May 1998 15:14:13 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <Pine.A41.3.95a.980503150708.35574G-100000@rsplus13.cern.ch>
On 3 May 1998, John Stanley wrote:
> If you read what I have said, you will notice that it refers to costs
> associated with EMAIL that result from using news. In case you didn't
> realize it, email is not news.
One doesn't have to even write software to deal with this problem.
There's a whole range of solutions. If you want to, you could create an
email address exclusively for your usenet activities, which (except at
the specific times or for the specific purposes that you need to respond
to it, e.g to authorize a posting) dumps everything in the bit bucket,
preferably at the server without even downloading it to your own
machine.
PROCMAIL is one approach, albeit somewhat fiddly to set up.
But I don't see why we're discussing it here. There are plenty of ways
that email addresses get loose on the Internet and added to spam-mailing
lists; you're only considering one of those ways. Feel free to set
followups to whatever ng you think is appropriate; I'm sure this one
isn't.
------------------------------
Date: 3 May 1998 14:07:40 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A Eeckels)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6ihtnc$hlg$2@justus.ecc.lu>
In article <3549e30b.20252989@news.btinternet.com>,
Gellyfish@btinternet.com (Jonathan Stowe) writes:
> On 2 May 1998 23:28:14 GMT, John Stanley wrote :
>
> Look on the bright side guys you could be Tony Blair (or a morris
> dancer).
What's wrong being a morris dancer?
--
Stefaan
--
PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
"Don't worry about people stealing your ideas. If your ideas
are any good, you'll have to ram them down people's throats."
-- Howard Aiken
------------------------------
Date: Sun, 03 May 1998 12:48:57 +0200
From: eggsite@berlin.snafu.de (bernd wolfsegger)
Subject: Re: Array of Arrays, sorting and using
Message-Id: <eggsite-ya023380000305981248570001@news.snafu.de>
In article <comdog-ya02408000R0205981725380001@news.panix.com>,
comdog@computerdog.com (brian d foy) wrote:
> In article <eggsite-ya023380000205982302240001@news.snafu.de>,
eggsite@berlin.snafu.de posted:
>
> >can anybody tell me how I can sort an Array of Arrays (No Hashes),
> >depending on the Arraysfields of the Array.
> >And then put the sorted thing in another Array to use it?
>
> the perldsc and perllol manpages have lots of examples.
>
> good luck :)
>
thats right, but its the same as in the camelbook. And I can't find any
example of sorting an array of arrays, just array of hashes etc...
but perhaps there other manpages otherwhere? or all the manpages on all
mirrors are the same?
Bernd
------------------------------
Date: Sat, 2 May 1998 14:12:44 -0600
From: "Joe" <fenyvesi@cadvision.com>
Subject: Backend (B) compiler in Perl5004.64. Need Help!
Message-Id: <354c27b5.0@news.cadvision.com>
I recently downloaded and compiled the latest beta version of Perl, 5004.64,
which includes the B backend module. I have found using this with the CC
option
fairly easy and straightforward and I have had little trouble with compiling
vanilla
perl scripts into applications using Visual C++ 5.0. However, I can't figure
out
how to include extensions that require the loading of DLLs (It was Tk that I
was
mainly interested in, but I found that no dynamic library will work.) Does
anyone
know how I can use the backend compiler to generate executables that use
dynamic (or statically) loaded libraries? Does anyone know where I can get
some documentation for the compiler?
Thanks very much,
Louis
BTW,
Sorry about the cross-post to both groups. I couldn't figure out which group
I should send the to, given the subject matter.
------------------------------
Date: Sun, 03 May 98 10:16:35 +0400
From: "Ben Coleman" <bcoleman@mindspring.com>
Subject: Re: Converting COBOL Comp-3 field
Message-Id: <nwcaegsemrwmaem.pminews@user-37kbo9f.dialup.mindspring.com>
On Sat, 2 May 1998 21:03:22 -0500, Bob Tate wrote:
>the comp-3 field is S9(7) COMP-3.
>
>what this means, assuming that you are not completely familiar with COBOL,
>is that a COMP-3 field is encoded to save space in the file.
Close enough so far.
>"S" means secured
No, S indicates a signed number
>"9" means that it is numeric only and "(7)" means that it is
>7-numbers long.
Close enough.
> COMP-3 means that it is the length of the field "7" plus
>"1" divided by "2". So, instead of taking up "8" bytes in the file it will
>only occupy 4.
Well, strictly speaking, a COMP modifier indicates a storage
mechanism other than character data. Last time I played with COBOL,
the exact storage mechanism for a particular COMP modifier is
implementation dependent, though a lot of implementations will
naturally copy the semantics of the most popular implementations, for
marketability's sake.
>Now, remember that my PRN = 97818. The file displays that the now 4 byte
>field is in Hex (00 70 61 C6).
Now that looks odd. The position of the sign character would make me
think this was a packed decimal with 'leading sign'(i.e. the sign
nybble in the most significant digit position), stored in
little-endian form. I'd therefore interpret it as a value of
6617000.
>What the info needs to look like, after converting the HEX to COMP-3 is (00
>97 81 8C).
I don't think it's valid to speak of 'converting' from Hex to COMP-3.
You may display the binary contents of a COMP-3 field in hex(it's
the most natural way of doing it, if it is packed decimal), but there
should be no 'conversion' necessary get to the contents you expect to
see, provided that you do properly understand what storage format
COMP-3 represents.
You may have either(or both) of these two problems:
1. COMP-3 may not be what you think it is. COMP-3 does mean the
'packed decimal with sign trailing, stored in big-endian format'
you've described, on IBM mainframes(I've dealt with that recently).
It may not mean the same thing on whatever platform you're
using(Intel, perhaps, given the apparent little-endian-ness of the
data you've shown?). You'll probably need to consult the docs for
the COBOL compiler in use.
2. The field you're looking at may not actually contain the value
you're expecting(or you may be looking for it in the wrong place in
the record). I can think of no easy way of getting 00 70 61 C6 as a
packed decimal(or any other) representation of 97818.
I suspect that you may have some more research ahead of you in
storage representations and record layouts before you can tackle
accessing the data from Perl.
If you _are_ dealing with packed decimal, you should be able to use
unpack with the H specifier. E.g., if you're dealing with
leading-sign, little-endian data(which is what your data looks like),
you'd do something like
$field = reverse $field; # put in big-endian order
$unpacked = unpack "H8",$field; # unpack to characters
$sign = substr($unpacked, 0, 1); # extract sign
$value =0+ substr($unpacked, 1, 7); # extract value
$value *= -1 if $value eq "D"; # apply sign to value
For trailing-sign, big-endian, it's similar
$unpacked = unpack "H8", $field; # unpack to characters
$sign = substr($unpacked, 7, 1); # extract sign
$value = 0+substr($unpacked, 0, 7); # extract value
$value *= -1 if $value eq "D"; # apply sign to value
Ben
--
Ben Coleman NJ8J | The attempt to legislatively
Internet: bcoleman@mindspring.com | micromanage equality results, at
http://bcoleman.home.mindspring.com/ | best, in equal misery for all.
------------------------------
Date: Sun, 03 May 1998 13:32:04 GMT
From: lidong@globalserve.net (Alex Dong Li)
Subject: Re: editor?
Message-Id: <6ihv38$c48$1@titan.globalserve.net>
># Does anybody know of a nice perl editor fin win95?
Kedit for windows is probably best editor on Win95 for all programming
languages: http://www.kedit.com/
It highlight all key words in perl, and comments in a different color.
You need to get a profile for Perl from the company. Also there is a minor
mistake in that profile: elsif, not elseif.
Regards,
Alex
------------------------------
Date: 3 May 1998 13:47:53 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: editor?
Message-Id: <slrn6kotj7.pnm.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Alex Dong Li <lidong@globalserve.net> wrote :
#
# ># Does anybody know of a nice perl editor fin win95?
#
# Kedit for windows is probably best editor on Win95 for all programming
# languages: http://www.kedit.com/
# It highlight all key words in perl, and comments in a different color.
So does vim 5.1. And it's available for all known platforms pretty
much.
------------------------------
Date: 3 May 1998 01:22:36 GMT
From: macintsh@cs.bu.edu (John Siracusa)
Subject: Exporting vs. "direct" access
Message-Id: <6iggss$k9f$1@news1.bu.edu>
Say I've got a .pm with a bunch of constants in it, to be
used internally by a set of modules. Users will never need
to access any of these constants. I've got some efficiency
questions:
1. What advantages or disadvantages does "use constant"
have over making normal variables that are set to
references to scalars?
2. What's faster: using Exporter, or accessing the variables
via $MyConstants::whatever?
Currently, I'm using plain jane variables set to references to
scalars, and I'm accessing them via $MyConstants::whatever in my
other modules.
-----------------+----------------------------------------
John Siracusa | If you only have a hammer, you tend to
macintsh@bu.edu | see every problem as a nail. -- Maslow
------------------------------
Date: 03 May 1998 10:35:38 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: macintsh@cs.bu.edu (John Siracusa)
Subject: Re: Exporting vs. "direct" access
Message-Id: <emyb9xkl.fsf@mailhost.panix.com>
macintsh@cs.bu.edu (John Siracusa) writes:
> 1. What advantages or disadvantages does "use constant"
> have over making normal variables that are set to
> references to scalars?
The aesthetic advantage of a simple scalar constant is prettier
interpolation, i.e.,
*FOO = \1776;
print "The constant \$FOO is currently $FOO.\n";
versus
use constant FOO => 1776;
print "The constant FOO is currently ", FOO, ".\n";
print "The constant FOO is still @{[ FOO ]}\n";
But I'd still go with the inlined functions (use constant). I'm sure
the gurus will correct me if I'm wrong, but I think that inlined
functions are actually replaced in the compile tree by constants,
whereas the typeglob trick, above, still results in a run-time
interpolation. If this is true, then use constant is actually
faster. I invite you to benchmark it.
Oh, ummm, constant lists are not inlined.
> 2. What's faster: using Exporter, or accessing the variables
> via $MyConstants::whatever?
Importing the namespace of a module incurs a hit at compile-time, when
the package->import() method is called, etc. But after that, the
exported names are aliased into your own namespace, so there's no
detectable difference in the time it takes to fetch the value. It's a
matter of style. It should really come down to what you want your
program to look like.
require Flintstone;
if ($fred < Flintstone::MAX_FRED) {
versus
use Flintstone qw( MAX_FRED );
if ($fred < MAX_FRED) {
I think that legibility and maintainability are way more important
than cpu time when it comes to Perl scripting. Go ahead and make
modules, if it turns you on.
Your reading list: perlsub, perlmod.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
Who inserted 'Flintstone' into his ispell dictionary, then was
gratified when it turned out that the second 'Flintstone' was
misspelled.
------------------------------
Date: Sun, 03 May 1998 10:21:31 GMT
From: sweiner@usa.net (Shawn )
Subject: Re: HELP win32 perl
Message-Id: <35584527.12007866@news.wwa.com>
On Sun, 03 May 1998 06:38:20 GMT, alan@sonic.net (Taran) was forced by
space aliens to write:
>What am I doing wrong. perl's lib's can't really be this bad... are
>they????
no, but the activestate's version of Perl does NOT support sockets so
Ping does not work.
don't know why the other doesn't work
If you are going to want to use sockets you might want to check into
the latest GS version of perl available through the CPAN
(Comprehensive Perl Archive Network) at http://www.perl.com/CPAN/
according to the readme docs he built it using a form of compiler that
enables the sockets use (I hope I'm not mangling this).
>
>HELP...
>
>Alan...
>
>Please email me if you can at alan@sonic.net
>
>Thank you very much
Shawn
shawn@wwa.com
shawns@wwa.com
sweiner@usa.net
slweiner@juno.com
sweiner@yahoo.com
IrunWulf@aol.com
ICQ#1925117 (visit www.mirabilis.com for more info)
------------------------------
Date: Sat, 2 May 1998 23:32:55 -0500
From: "Bob Tate" <btate@primary.net>
Subject: HEX to BCD
Message-Id: <354bf3a2.0@news.primary.net>
This is a multi-part message in MIME format.
------=_NextPart_000_0168_01BD7622.A2014600
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Anyone know the math to convert a HEX number to a BCD number?
------=_NextPart_000_0168_01BD7622.A2014600
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>Anyone know the math to convert a =
HEX number to=20
a BCD number?</FONT></DIV></BODY></HTML>
------=_NextPart_000_0168_01BD7622.A2014600--
------------------------------
Date: 3 May 1998 14:28:25 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A Eeckels)
Subject: Re: HEX to BCD
Message-Id: <6ihuu9$ho7$1@justus.ecc.lu>
In article <354bf3a2.0@news.primary.net>,
"Bob Tate" <btate@primary.net> writes:
>
> Anyone know the math to convert a HEX number to a BCD number?
Having programmed a Z-80 in assembler has some advantages :-)
To convert a decimal number into bcd, convert each decimal
digit into its 4-bit binary equivalent. After conversion,
we'll have a 'binary-like' number whose length equals four
times the number of decimal digits, ie 2 bcd digits in
each byte.
Example:
3 1 9 7
0011 0001 1001 0111
This means that you never use the 0x0A-0x0F range each
nybble can contain.
Now converting hex - you'd basically have to convert your
binary representation to decimal, and then convert the
decimal into bcd.
Example:
0xC7D -> 3197 -> 0011 0001 1001 0111 (0x3197)
Don't forget that the machine representation will depend
on the endianness of the processor.
Hope this helps
--
Stefaan
--
PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
"Don't worry about people stealing your ideas. If your ideas
are any good, you'll have to ram them down people's throats."
-- Howard Aiken
------------------------------
Date: Sun, 03 May 98 10:39:58 +0400
From: "Ben Coleman" <bcoleman@mindspring.com>
Subject: Re: How to read command line literally?
Message-Id: <bdkgquwytpkzopo.pminews@user-37kbo9f.dialup.mindspring.com>
On 29 Apr 1998 19:05:28 GMT, Ilya Zakharevich wrote:
>cmd has the same redirection features as tcsh, maybe even better.
When did they add backtick processing(or the equivalent) to cmd?
I've had a few times that would've been handy.
Ben
--
Ben Coleman NJ8J | The attempt to legislatively
Internet: bcoleman@mindspring.com | micromanage equality results, at
http://bcoleman.home.mindspring.com/ | best, in equal misery for all.
------------------------------
Date: Sun, 03 May 1998 12:26:55 GMT
From: daclay@NOSPAMzip.com.au (Excession)
Subject: Re: Huge array/Win32::NetAdmin::GetUsers
Message-Id: <354c61ca.6272555@news.zip.com.au>
On Sat, 02 May 1998 14:15:52 GMT, broomberg@nospam-ccgroupnet.com (Barry
Roomberg) wrote:
>>On Thu, 30 Apr 1998 13:41:27 -0400, "John Felso" <jfelso@att.com> wrote:
>>Does anyone have experience handling really really large arrays? I need to
>If you check out the 2nd line on the following display, you will
>see that the mem_t.pl perl script allocated 1991M (almost 2GB) on
>a system that has 1GB real and 2GB swap. The actual data quantity
[large script deleted]
try:
$x=1;
for (1..6)
{
$x = $x x 50;
}
print length($x);
(50**6 is 15Gbytes or so)
Dac
---
David Andrew Clayton # Please remove NO_SPAM when
dac@NOSPAM.pcug.org.au # sending email replies.
I post therefore I am. #
------------------------------
Date: 3 May 1998 14:43:53 GMT
From: mcai3ph2@ist4.co.umist.ac.uk (Pablo Hortal)
Subject: Interrupts ... or whatever they are called
Message-Id: <6ihvr9$4in$2@yama.mcc.ac.uk>
Hi,
I need to do the following:
The user of my system stores a date and a time (Windows 95). At that date &
time, I need one of my scripts to be called (i.e. like an interrupt).
How can I do this?
Thanks,
Espinete.
------------------------------
Date: Sun, 03 May 1998 08:59:39 GMT
From: sweiner@usa.net (Shawn )
Subject: Re: looking for a little bit of help here. Thanks.
Message-Id: <355431f1.7089371@news.wwa.com>
On 2 May 1998 19:14:23 GMT, "Allan M. Due" <alpaca@iname.com> was
forced by space aliens to write:
>while ($in=<IN>)
>
> $in =~ s|\\y\/|\\\.\.\/|g;
>print $in;
>}
This one (above DID not work)
>
>and for more readability use quotema:
>
>while ($in=<IN>)
>
>$in =~ s|\Q\y/|\../\E|g;
>print $in;
>}
This one did. Don't know why.
BTW thanks.
and I've altered it a little bit now to provide it as a patch in case
anyone else runs into this problem with pod2html.
#!perl -w
########################################################
##Program Convert.pl by Shawn Weiner
##email: sweiner@usa.net
##
##Program is designed to fix a bug that I had happen to me
##when the pod2html messed up in converting pod files to html
##it put a "\y/" instead of "\../" when trying to use the file:
##tag to navigate relative paths.
use CARP;
#below is the dir to be processed. Change as needed for the base dir
my $dir='c:\perl\html\lib';
#below is the arbitrary dirhandle. I made it a number so that it is
easy to
#manipulate with ++ and -- to aid in the recursing
$dirhandle="0";
#jeez isn't this a short main?
procdir($dir,$dirhandle);
sub convert {
#get the file to be converted
my $file=shift(@_);
#get the dir so as to properly display dir\file processed
my $dir=shift(@_);
#this is the temp file. Can be anything
my $temp="temp.html";
open (IN, "< $file") || die "INfile $file didn't open $!";
open (OUT, "> $temp") || die "OUTfile $temp didn't open $!";
while (<IN>) {
if (index ($_,"\y/") ne "-1") {
s|\Q\y/|\../\E|g;
}
print OUT $_;
}
close IN;
close OUT;
print "$dir\\$file processed.\n";#this is here to show you
it's working.
unlink ($file);#if I didn't unlink the file it wouldn't
overwrite.
rename($temp,$file) || die "Couldn't rename $temp to $file.
$!";
}
#I decided to put the processing of the dirs in a sub
#so that I could recurse down paths
sub procdir {
#get the dir to process
my $dir=shift(@_);
#increment the dirhandle to reflect a dif dir
$dirhandle++;
opendir ($dirhandle, $dir) || die "Couldn't open DIR$dirhandle
$dir $!";
while (defined($file=readdir($dirhandle))) {
if (index($file,".htm") ne "-1") {
chdir ($dir) || die "couldn't change into dir.
perhaps unusual dir name? $!";
&convert($file,$dir);
} elsif ((index($file,"\.") eq "-1")) {
#call the sub recursively
&procdir("$dir\\$file");
#decrement the dir handle after the recursive
call.
$dirhandle--;
}
}
}
Shawn
shawn@wwa.com
shawns@wwa.com
sweiner@usa.net
slweiner@juno.com
sweiner@yahoo.com
IrunWulf@aol.com
ICQ#1925117 (visit www.mirabilis.com for more info)
------------------------------
Date: Sun, 03 May 1998 10:13:54 GMT
From: sweiner@usa.net (Shawn )
Subject: Re: looking for a little bit of help here.
Message-Id: <35564233.11252095@news.wwa.com>
On Sun, 03 May 1998 00:03:45 GMT, Tom Phoenix <rootbeer@teleport.com>
was forced by space aliens to write:
>On Sat, 2 May 1998, Shawn wrote:
>
>> Subject: looking for a little bit of help here.
>
>Please check out this helpful information on choosing good subject
>lines. It will be a big help to you in making it more likely that your
>requests will be answered.
>
> http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
>
>> I recently DLd the GS version of Perl for win32 (at CPAN) and have run
>> into an interesting problem.
>>
>> When it converted the .pod files into html it messed it up by putting
>> a "y" in the relative URLs instead of ".."
>
>That's a bug, no doubt. It's worth tracking down, or at least reporting.
>
Well, after looking it over and trying desperatly to get it to work (I
did but then found other "unanticipated" features in pod2html that
made it utterly impossible to use (it REALLY messed up in creating the
relative URLs). that I've gotten to the point of throwing up my hands
in disgust and moving on. I did get it to work, eventually, but then
encountered other problems in that the bug I noticed was not the only
one.
Just asking here, but who would I go to to try to report this bug??
I've tried to make heads-or-tails of pod2html but have run my head
into the wall enough. I still can't figure out HOW it constructs it's
relative URLs. I am way to impatient to sit here banging my head
against that wall any more. Thanks for the advice and here is how the
script looked when I was done with it:
#!perl -w
########################################################
##Program Convert.pl by Shawn Weiner
##email: sweiner@usa.net
##
##Program is designed to fix a bug that I had happen to me
##when the pod2html messed up in converting pod files to html
##it put a "\y/" instead of "\../" when trying to use the file:
##tag to navigate relative paths.
use CARP;
#below is the dir to be processed. Change as needed for the base dir
my $dir='c:\perl\html\lib';
#below is the arbitrary dirhandle. I made it a number so that it is
easy to
#manipulate with ++ and -- to aid in the recursing
$dirhandle="0";
#jeez isn't this a short main?
procdir($dir,$dirhandle);
sub convert {
#get the file to be converted
my $file=shift(@_);
#get the dir so as to properly display dir\file processed
my $dir=shift(@_);
#this is the temp file. Can be anything
my $temp="temp.html";
open (IN, "< $file") || die "INfile $file didn't open $!";
open (OUT, "> $temp") || die "OUTfile $temp didn't open $!";
while (<IN>) {
if (index ($_,"\y/") ne "-1") {
s|\Q\y/|\../\E|g;
}
print OUT $_;
}
close IN;
close OUT;
print "$dir\\$file processed.\n";#this is here to show you
it's working.
unlink ($file);#if I didn't unlink the file it wouldn't
overwrite.
rename($temp,$file) || die "Couldn't rename $temp to $file.
$!";
}
#I decided to put the processing of the dirs in a sub
#so that I could recurse down paths
sub procdir {
#get the dir to process
my $dir=shift(@_);
#increment the dirhandle to reflect a dif dir
$dirhandle++;
opendir ($dirhandle, $dir) || die "Couldn't open DIR$dirhandle
$dir $!";
while (defined($file=readdir($dirhandle))) {
if (index($file,".htm") ne "-1") {
chdir ($dir) || die "couldn't change into dir.
perhaps unusual dir name? $!";
&convert($file,$dir);
} elsif ((index($file,"\.") eq "-1")) {
#call the sub recursively
&procdir("$dir\\$file");
#decrement the dir handle after the recursive
call.
$dirhandle--;
}
}
}
Shawn
shawn@wwa.com
shawns@wwa.com
sweiner@usa.net
slweiner@juno.com
sweiner@yahoo.com
IrunWulf@aol.com
ICQ#1925117 (visit www.mirabilis.com for more info)
------------------------------
Date: Sat, 02 May 1998 01:31:37 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Newbie config CGI question
Message-Id: <354a7524.1022923@news.btinternet.com>
On Sun, 03 May 1998 04:57:53 +0000, qazmlp wrote :
<snip>
>
>#!/usr/bin/perl
>#
>#
>use CGI;
>
>$q = new CGI;
>
>$q->header;
>#print "Content-type: text/html\n\n";
>print "This is a test";
>
>I receive the error:
>
>"Internal Server Error
>
>The server encountered an internal error or misconfiguration and was
>unable to complete your request.
>
<snip>
Eh,oh.
I think a re-examination of the CGI documentation called for as your
example show a misunderstanding as to how CGI.pm works.
The header method does not actually output the HTTP headers but simply
returns a value that would be suitable for printing as one.
The majority of the CGI methods work in this way.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sun, 03 May 1998 12:36:43 GMT
From: Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org>
Subject: Re: Newbie config CGI question
Message-Id: <354C6320.F985F368@fccjmail.fccj.org>
qazmlp wrote:
> #!/usr/bin/perl
> #
> #
> use CGI;
>
> $q = new CGI;
>
> $q->header;
The above should be
print $q->header;
> #print "Content-type: text/html\n\n";
> print "This is a test";
>
> I receive the error:
>
> "Internal Server Error
> This script, however, :
>
> #!/usr/bin/perl
> #
> #
> use CGI;
>
> $q = new CGI;
>
> #$q->header;
> print "Content-type: text/html\n\n";
If you print $q->header; you won't need to
print "Content-type: text/html\n\n";
HTH,
-Sneex- :-)
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster
------------------------------
Date: Sun, 3 May 1998 10:26:57 +0200
From: "Steve Lhomme" <steve. lhomme@nordnet.fr>
Subject: Pb with an array in a PERL Object (bis)
Message-Id: <6ihba1$7bq$2@news.nordnet.fr>
Where am I wrong ?
I'm building a class with an array data.
When I build multiple instances of this object class, and push data in the
array, the multiple objects seem to use the same array...
Please reply to my e-mail : steve .lhomme@audiophile.com (without the space
between steve and .lhomme)
Thx
---------------------------------------------------------------------
Here's the code :
#--- The code that uses OCDB ---
require OCDB;
$objet1 = OCDBD->new();
$objet2 = OCDBD->new();
$data='Bus66.6=ON&Multi+3.5=ON';
$objet1->CGI2DB($data);
$data='Bus60=ON&Multi+2=ON';
$objet2->CGI2DB($data);
if (!(@erreurs = $objet1->donnee_bonne()))
{$objet1->afficheHTML();
$objet2->afficheHTML();}
#--- The code in OCDB.pm ---
# Constructor
sub new {
my $self = {};
my $proto = shift;
my $class = ref($proto) || $proto;
$self->{all_freq} = ();
$self->{all_mult} = ();
bless ($self,$class);
return $self;
}
# Data analysis
sub CGI2DB {
my $self = shift;
#--- Format the input from a CGI ---
@pairs = split(/&/, $_[$#_]);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Convert the HTML encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
# Convert HTML stuff as necessary.
$value =~ s/<([^>]|\n)*>//g;
$FORM{$name} = $value;
}
#--- Extraction of the data for both array ---
@{$self->{all_freq}}=();
@{$self->{all_mult}}=();
foreach $nom (%FORM) {
my $freq = ();
my $mult = ();
($foo,$freq) = split(/Bus[\+]*/,$nom);
($foo,$mult) = split(/Multi[\+]*/,$nom);
if ($mult)
{push @{$self->{all_mult}}, $mult;}
if ($freq)
{push @{$self->{all_freq}}, $freq;}
}
}
# Printing Method for the class
sub afficheHTML {
my $self = shift;
foreach $freq (@{$self->{all_freq}}){
foreach $mult (@{$self->{all_mult}}){
printf "%s * %s = %s<br>\n",$freq,$mult,$freq*$mult;
}
}
print "multiplicateurs : @{$self->{all_mult}}\n";
print "frequences : @{$self->{all_freq}}\n";
}
---------------------------------------------------------------------
Here is what I get when I run perl on the first script:
66.6 * 3.5 = 233.1<br>
multiplicateurs : 3.5
frequences : 66.6
60 * 2 = 120<br>
60 * 3.5 = 210<br>
66.6 * 2 = 133.2<br>
66.6 * 3.5 = 233.1<br>
multiplicateurs : 2 3.5
frequences : 60 66.6
------------------------------
Date: 3 May 1998 11:07:41 GMT
From: "Duncan Cameron" <dcameron@bcs.org.uk>
Subject: Re: Pb with an array in a PERL Object (bis)
Message-Id: <01bd7683$57b95900$3a3663c3@dns.btinternet.com>
No, the objects are not using the same array. Your code is putting the
same values into different arrays.
The problem is caused by the %FORM hash accumulating values across
successive calls to CGI2DB. From your example I can't tell whether it's
meant to, or whether there is an earlier problem.
HTH
Steve Lhomme <steve. lhomme@nordnet.fr> wrote in article
<6ihba1$7bq$2@news.nordnet.fr>...
> Where am I wrong ?
> I'm building a class with an array data.
> When I build multiple instances of this object class, and push data in
the
> array, the multiple objects seem to use the same array...
>
> Please reply to my e-mail : steve .lhomme@audiophile.com (without the
space
> between steve and .lhomme)
>
> Thx
<code snipped>
>
> $FORM{$name} = $value;
The second call to CGI2DB has different values for $name to those fo the
first call.
------------------------------
Date: Sun, 3 May 1998 10:25:47 +0200
From: "Steve Lhomme" <steve. lhomme@nordnet.fr>
Subject: PB with an array in a PERL object
Message-Id: <6ihb9v$7bq$1@news.nordnet.fr>
Where am I wrong ?
I'm building a class with an array data.
When I build multiple instances of this object class, and push data in the
array, the multiple objects seem to use the same array...
---------------------------------------------------------------------
Here's the code :
#--- The code that uses OCDB ---
require OCDB;
$objet1 = OCDBD->new();
$objet2 = OCDBD->new();
$data='Bus66.6=ON&Multi+3.5=ON';
$objet1->CGI2DB($data);
$data='Bus60=ON&Multi+2=ON';
$objet2->CGI2DB($data);
if (!(@erreurs = $objet1->donnee_bonne()))
{$objet1->afficheHTML();
$objet2->afficheHTML();}
#--- The code in OCDB.pm ---
# Constructor
sub new {
my $self = {};
my $proto = shift;
my $class = ref($proto) || $proto;
$self->{all_freq} = ();
$self->{all_mult} = ();
bless ($self,$class);
return $self;
}
# Data analysis
sub CGI2DB {
my $self = shift;
#--- Format the input from a CGI ---
@pairs = split(/&/, $_[$#_]);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Convert the HTML encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
# Convert HTML stuff as necessary.
$value =~ s/<([^>]|\n)*>//g;
$FORM{$name} = $value;
}
#--- Extraction of the data for both array ---
@{$self->{all_freq}}=();
@{$self->{all_mult}}=();
foreach $nom (%FORM) {
my $freq = ();
my $mult = ();
($foo,$freq) = split(/Bus[\+]*/,$nom);
($foo,$mult) = split(/Multi[\+]*/,$nom);
if ($mult)
{push @{$self->{all_mult}}, $mult;}
if ($freq)
{push @{$self->{all_freq}}, $freq;}
}
}
# Printing Method for the class
sub afficheHTML {
my $self = shift;
foreach $freq (@{$self->{all_freq}}){
foreach $mult (@{$self->{all_mult}}){
printf "%s * %s = %s<br>\n",$freq,$mult,$freq*$mult;
}
}
print "multiplicateurs : @{$self->{all_mult}}\n";
print "frequences : @{$self->{all_freq}}\n";
}
---------------------------------------------------------------------
Here is what I get when I run perl on the first script:
66.6 * 3.5 = 233.1<br>
multiplicateurs : 3.5
frequences : 66.6
60 * 2 = 120<br>
60 * 3.5 = 210<br>
66.6 * 2 = 133.2<br>
66.6 * 3.5 = 233.1<br>
multiplicateurs : 2 3.5
frequences : 60 66.6
------------------------------
Date: Sun, 03 May 1998 14:30:03 GMT
From: Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org>
Subject: Re: regex help - Follow-up
Message-Id: <354C7DB1.17289CFB@fccjmail.fccj.org>
Bill 'Sneex' Jones wrote:
>
> Ronald J Kimball wrote:
>
> > /(^|[^.])(identifier)/
>
> I found this this morning and played around with different strings.
> Except for the start of a string, all matches return an extra
> character. Is this caused by the [^.] ?
It is. But when I do
my $strTest = 'This is a line. It is line 11.';
print $strTest =~ /(^|[^.][^.])(\.)/, " : First Match\n";
$strTest = $';
print $strTest =~ /(^|[^.][^.])(\.)/, " : Second Match\n";
Is there a way to matched 'embedded' ##. strings?
Regardless of where they appear in the string/glob?
Thx, :-)
-Sneex-
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster
------------------------------
Date: Sun, 03 May 1998 13:01:10 GMT
From: Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org>
Subject: Re: regex help
Message-Id: <354C68DB.4AEF634B@fccjmail.fccj.org>
Ronald J Kimball wrote:
> /(^|[^.])(identifier)/
I found this this morning and played around with different strings.
Except for the start of a string, all matches return an extra
character. Is this caused by the [^.] ?
-Sneex- :-)
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster
------------------------------
Date: 3 May 1998 14:40:14 GMT
From: mcai3ph2@ist4.co.umist.ac.uk (Pablo Hortal)
Subject: Serial port ... again
Message-Id: <6ihvke$4in$1@yama.mcc.ac.uk>
Hi,
There have been many messages about how to write to / read from a serial port
... but no one has actually provided any code that works ... or at least I
haven't found it.
I'm after some code to read data comming from the serial port (Windows 95
system), I already know how to write to it.
Some help on this will be appreciated.
Thanks,
Espinete.
------------------------------
Date: Sun, 03 May 1998 12:39:51 GMT
From: r-watkinsNOSPAM@worldnet.att.net (Robert Watkins)
Subject: Re: Test httpd server status
Message-Id: <6ihomf$9qt@bgtnsc03.worldnet.att.net>
In article <354A3F3D.ED3CA454@cks.ssd.k12.wa.us>, Jerome O'Neil <joneil@cks.ssd.k12.wa.us> wrote:
>
>Anything 'webbish' should use LWP.
>
>#!/bin/perl -w
>use strict;
>use LWP; # ******BIG HINT*******
>my(@servers) = qw{server1 server2 server3};
>my($ua) = new LWP::UserAgent;
>foreach(@servers)
>{
> my($url) = new URI::URL "http://$_";
> my($request) = new HTTP::Request HEAD => $url;
> my($response) = $ua->request($request);
> if($response->is_error)
> {
> # you know what to do
> }
>}
>
>Jerome O'Neil
>
Brilliant! Thank you.
This was absolutely the clue I needed to get going. I now have a script that
can run on my desktop as if it were a cron job, write a log of the status
of each of the six servers (not cumulative), and, should anything go wrong,
will pop up a Tk Perl window and display that log file to let me know what's
up.
While I have been teaching myself Perl for the last six months or so, and can
write pretty good flat code, I'm having trouble making that leap into objects
and modules (I do not have any programming background, you see). As such,
the code you included was indispensible in starting me off. To write the Tk
bit (about which I knew nothing 24 hours ago) I went carefully over the
brilliant documentation (I'm using the CPAN standard port for NT) to piece
together a workable bit of code.
Thank you again.
-- Robert Watkins
------------------------------
Date: 03 May 1998 10:40:41 +0300
From: Ariel Scolnicov <ariels@mangal.cs.huji.ac.il>
Subject: Re: Using the -- notation?
Message-Id: <7zzpgzg5ty.fsf@mangal.cs.huji.ac.il>
Tom Phoenix <rootbeer@teleport.com> writes:
> On 2 May 1998, Jonas Bofjall wrote:
>
> > Why doesn't this:
> > open(blaj, ">$ARGV[$#ARGV--]");
> > work like this:
> > open(blaj, ">$ARGV[$#ARGV]");
> > $#ARGV--;
> >
> > It seems to work with variables other than ARGV.
>
> Really? If so, that's a (minor) bug in perl. But I couldn't get it to do
> anything useful in a quick test. (Maybe you're using an old version?)
>
> Of course, even when your script is "just an example" (and perhaps
> especially in that case!) you should _always_ check the return value after
> opening a file. And it's generally recommended that filehandles should be
> named in all caps.
I can't figure out if this boiler-plated message is meant to point out
the answer or not, but anyway here's a demonstration (from the Perl
debugger):
DB<1> @x = qw/2 3 5 7 11/ # an array to play with
DB<2> p $x[$#x] # print the last element of @x
11
DB<3> @y = @x # copy @x (for a post-mortem)
DB<4> p $x[$#x--] # print and eliminate last element of @x
# (doesn't work?!?)
DB<5> p $#y-- # decrement number of elements of @y
4
DB<6> x @y # $y[4] has vanished!
0 2
1 3
2 5
3 7
DB<7> p $y[4] # and so we can't print it
DB<8>
What you're trying to do would have undefined results in any
normally-defined language (Perl has a single interpreter, so you can
get away with considering that interpreter as defining the language).
$#x-- has 2 side-effects: it decrements $#x, and as a side-effect of
that it truncates @x. You were hoping that $x[$#x--] would be
implemented as "get return value $x[$#x], decrement $#x, truncate
@x". Instead, you get "decrement $#x, truncate @x, get return value
$x[old value of $#x]". Which is correct? I couldn't possibly say.
Perl doesn't have a standard (in the sense of, say, the C standard).
So statements like "$i = $i++;" and your statement might be said to be
defined, in the sense of Perl having only one interpreter (today; does
anyone know if the compiler will preserve the behaviour of this sort
of construct?).
I still wouldn't use such constructs at all, even if they work today.
Until you get a firm guarantee (in a manual, say) of the behaviour, it
could change tomorrow with nary a ChangeLog.
> [...]
> Hope this helps!
Me too.
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2482
**************************************