[8863] in Perl-Users-Digest
Perl-Users Digest, Issue: 2480 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 2 22:05:54 1998
Date: Sat, 2 May 98 19:00:26 -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 Sat, 2 May 1998 Volume: 8 Number: 2480
Today's topics:
Re: 1701 days hath September (was: Re: rename funciton) (John Stanley)
Re: 1701 days hath September (was: Re: rename funciton) (John Stanley)
Re: 1701 days hath September (was: Re: rename funciton) (Jonathan Stowe)
== vs. eq <perl@corcoll.demon.co.uk>
Re: Apache Logfile Parser? <tchrist@mox.perl.com>
Can Perl execute a shell command? <rodw@maine.rr.com>
Re: Can Perl execute a shell command? <rootbeer@teleport.com>
Converting COBOL Comp-3 field <btate@primary.net>
Re: Converting COBOL Comp-3 field <rootbeer@teleport.com>
Re: Converting COBOL Comp-3 field (Charles DeRykus)
Re: Converting COBOL Comp-3 field (Jonathan Stowe)
Re: Encryption of perl scripts <milos@vellocet.insync.net>
Re: Encryption of perl scripts <rootbeer@teleport.com>
Re: extracting a sub-string <tchrist@mox.perl.com>
Re: extracting a sub-string <rootbeer@teleport.com>
Re: HELP Me PLEASE! (Stuart McDow)
Re: How meta search works? (brian d foy)
Re: looking for a little bit of help here. <rootbeer@teleport.com>
Re: looking for a little bit of help here. <rootbeer@teleport.com>
Re: Passing type AV * ? (Charles DeRykus)
Perl and Emacs question - perl debugging mode & cperl- <chuckk@monmouth.com>
problems with commands (newbie) (Saurabh S. Tendulkar)
Re: problems with commands (newbie) <rootbeer@teleport.com>
Re: problems with commands (newbie) (Jonathan Stowe)
Re: Randomly sorting an array <rootbeer@teleport.com>
Re: regex help (Jonathan Stowe)
Style question: trouble with $_ ... <horowitz@ulb.ac.be>
Re: Substiting the backslash character (Craig Berry)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 May 1998 23:14:49 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6ig9d9$i88$1@news.NERO.NET>
In article <6if795$ia5$1@ns1.arlut.utexas.edu>,
Stuart McDow <smcdow@arlut.utexas.edu> wrote:
>stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
>> Stuart McDow <smcdow@arlut.utexas.edu> wrote:
>> >I'm not intending to be
>> >incendiary here; I'm just trying to point out that it's a matter of
>> >individual priorities.
>>
>> No, it is a matter of understanding how USENET groups work. All this
>> touchy-feely stuff about people living in gated communitities and stuff
>> is very nice, but it doesn't change how a moderated newsgroup works.
>
>I disagree. IMO, the real point is that no one is ever forced to
>participate in moderated newsgroups. If someone doesn't like moderated
>newsgruops, then they don't have to subscribe. Finis. Done. It is
>about individual priorities.
Please read what I wrote. It does not matter if nobody is forced to
participate. It doesn't matter if you like or do not like moderated
groups. Moderated groups are the way they are whether you like it or
not or whether you participate or not. They are NOT "a group moderating
itself", they are "moderation by a few".
Please notice that that statement contains _zero_ value judgements
about moderation. When I start talking about moderation being bad or
good, feel free to argue with me about whether moderation is good or
bad.
------------------------------
Date: 2 May 1998 23:28:14 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6iga6e$iiu$1@news.NERO.NET>
In article <354B2F03.8DE651EE@coos.dartmouth.edu>,
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
>John Stanley wrote:
>>
>> In article <lt4sz9qqyp.fsf@asfast.com>, Lloyd Zusman <ljz@asfast.com> wrote:
>> >However, since c.l.p.misc will still exist, I don't see how these
>> >potentially non-utopian aspects of the proposed c.l.p.moderated would
>> >have any major effects on anyone who doesn't chose to participate in
>> >that new group ... assuming that this non-utopianness will come to
>> >pass at all.
>>
>> Saying that those who are not able to participate will suffer no major
>> effects is a very damning admission about the value of the proposed
>> group. I suspect that, were you one of the excluded, your tune would be
>> different.
>
>Yes, but that's not what he said, is it? What he said was that anyone who
>*chooses not to participate* will suffer no major effects.
Yes, the words written are as you say. However, in this context, the
issue is requiring spammable addresses, and some people cannot afford
the cost of email spam just so they can post to USENET. This means it
is not really a choice, even though people keep wanting to couch it in
those terms.
>There are already many people who *choose not to participate* in
>comp.lang.perl.misc. Is that a very damning admission about the value of this
>group?
If the choice really is a choice, no, it isn't. Since people can use
munged addresses in this group, there is no issue of choice relevant to
munged addresses.
>John, I know it's much harder to do, but could you try to prove your point
>without twisting other people's words around?
You've got it backwards. People keep twisting the issue into "choice"
when it is not. That is part of the argument, and expecting me to accept
it is a "choice" when it is not is ridiculous. That means that I will
continue to discuss it in terms of ability even when those who discuss
it with me use the word "choice". They enter this discussion knowing
that that is a part of the argument -- or they should know it by now.
------------------------------
Date: Fri, 01 May 1998 15:35:10 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <3549e30b.20252989@news.btinternet.com>
On 2 May 1998 23:28:14 GMT, John Stanley wrote :
<snip>
>
>Yes, the words written are as you say. However, in this context, the
>issue is requiring spammable addresses, and some people cannot afford
>the cost of email spam just so they can post to USENET. This means it
>is not really a choice, even though people keep wanting to couch it in
>those terms.
>
>>There are already many people who *choose not to participate* in
>>comp.lang.perl.misc. Is that a very damning admission about the value of this
>>group?
>
>If the choice really is a choice, no, it isn't. Since people can use
>munged addresses in this group, there is no issue of choice relevant to
>munged addresses.
>
<snip>
This spamming thing is a red-herring, it has almost become a nervous
tic on this newgroup. I am one of those to whom there could be a
potential cost from spam but as a proportion of the total cost of use
of Usenet specifically and the internet in general it is
infinitessimal.
I dont and infact wouldnt munge my E-Mail address.
I pay my PSTN connection by the minute to British Telecom (albeit at
the poxily named Lo-Call rate) and I pay them a moderate sum of money
every year for the account (oh and i do, whatever they may have said
to the monopolies and mergers commission) these costs are then
combined with the underlying costs of hardware and software and the
administration and maintenance thereof and I have to say that say at a
crude calculation that the cost of spam is less than 1% of the total
(to us personally that is).
I would further suggest that the majority of spam e-mails that are
addressed to my account are probably not as a result of posting to
this group anyhow. (shit I made one joke post to rec.boats not long
ago and I *know* I have two junk-mails as a result of that).
Look on the bright side guys you could be Tony Blair (or a morris
dancer).
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sun, 3 May 1998 00:43:01 +0100
From: perl <perl@corcoll.demon.co.uk>
Subject: == vs. eq
Message-Id: <C455575623CED111941500409520680E01A80E@BETTY>
OK OK that enough.
I have been reading this newsgroups for a free weeks now and I am a
newbie to perl however not all newbies are completely brain dead.
I want to learnt perl so this is what I did
1. Purchased Learning Perl (I think you had something to do with that
book didn't you Tom :))
2. Purchased Programming Perl (Cheers Larry Tom and Randal)
3. Purchased Learning Perl on Win32 systems (thanks again tom and Randal
and Erik cos in the Real world NT is doing OK for itself and a few
companies use it.)
4. purchased Mastering Regular Expressions (explained at last thanks
Jeffery)
5. print and read all FAQ I could find
6. now writing Scripts for NT and Linux very happily
I use Exchange server at home for easy. I also use Sendmail but not at
home
Now if I get really stuck I would check all this doc's before I send to
the Newsgroup and as this is my first posting I think I am doing ok
Please don't consider all newbies idiots and Please just because I use
Outlook doesn't mean I am incapable of doing the same on a sendmail
system
once again Tom, Larry, Randal, Erik, Jeffery, O'Reilly Thanks for the
books a
Tony hitchinson
tony@corcoll.demon.co.uk
> -----Original Message-----
> From: Tom Christiansen [SMTP:tchrist@mox.perl.com]
> Posted At: Saturday, April 25, 1998 11:11 PM
> Posted To: misc
> Conversation: == vs. eq
> Subject: Re: == vs. eq
>
>
> In comp.lang.perl.misc, "Kelby Valenti" <kelby@mplx.com> writes:
> :What exactly is the difference between == and eq in an if statement.
> Also
> :is there a function that can tell me whether a string is numbers or
> chars.
>
> The way of the post-docu-literate future. Lovely. Should have
> seen it coming:
>
> X-Newsreader: Microsoft Outlook Express 4.71.1712.3
> X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
>
> --tom
> --
> Tom Christiansen tchrist@jhereg.perl.com
>
> /* now make a new head in the exact same spot */
> --Larry Wall in cons.c from the perl source code
------------------------------
Date: 2 May 1998 23:03:22 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Apache Logfile Parser?
Message-Id: <6ig8nq$3c8$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, jay <mocat@best.com> writes:
:I'm helping a friend of mine with a few scripts for his new server...
:what he needs is an Apache logfile parser
:(/var/log/www/hostname/access.log)...
:Was wondering if there is a module to make this easier on myself, or do I
:have to do it manually?
Was wondering why you didn't look at CPAN.
http://www.perl.com/CPAN/modules/by-module/Apache/Apache-LogFile-0.11.tar.gz
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
I just hate to be pushed around by some fucking machine. - Ken Thompson, on the i960
------------------------------
Date: Sat, 2 May 1998 20:54:41 -0400
From: "Rod Wintle" <rodw@maine.rr.com>
Subject: Can Perl execute a shell command?
Message-Id: <6igdsq$r42$1@proxye2.maine.rr.com>
Hi,
Is it possible for me to use perl to collect variables and then have the
perl script call a shell command?
Say I want to collect the name of a machine and then have the script ping
the machine...
How can that be done?
Thanks in advance..
Rod Wintle
------------------------------
Date: Sun, 03 May 1998 01:36:31 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Rod Wintle <rodw@maine.rr.com>
Subject: Re: Can Perl execute a shell command?
Message-Id: <Pine.GSO.3.96.980502181853.8809P-100000@user2.teleport.com>
On Sat, 2 May 1998, Rod Wintle wrote:
> Is it possible for me to use perl to collect variables and then have the
> perl script call a shell command?
Yes, although Perl can do anything that the shell can do.
> Say I want to collect the name of a machine and then have the script
> ping the machine...
>
> How can that be done?
First you get the name of a machine. I'd request it from the user. Then,
you can ping the remote machine. I'd use a routine from a module.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 2 May 1998 19:23:35 -0500
From: "Bob Tate" <btate@primary.net>
Subject: Converting COBOL Comp-3 field
Message-Id: <354bb933.0@news.primary.net>
Hello,
I need some help with converting a COMP-3 field to normal decimal. I am
using PERL 5 and understand the COMP-3 format, also called "packed decimal"
or "Binary Coded Decimal (BCD)". I know what the correct answer should be
once the field is decoded. Even with all this info I am still missing the
critical element that will allow me to decode the Comp-3 field. Any help
would be great.
Bob Tate
btate@primary.net
------------------------------
Date: Sun, 03 May 1998 01:13:55 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Bob Tate <btate@primary.net>
Subject: Re: Converting COBOL Comp-3 field
Message-Id: <Pine.GSO.3.96.980502180852.8809O-100000@user2.teleport.com>
On Sat, 2 May 1998, Bob Tate wrote:
> I need some help with converting a COMP-3 field to normal decimal. I am
> using PERL 5 and understand the COMP-3 format, also called "packed
> decimal" or "Binary Coded Decimal (BCD)". I know what the correct
> answer should be once the field is decoded. Even with all this info I
> am still missing the critical element that will allow me to decode the
> Comp-3 field.
And that critical element is what? Could you post a small piece of code
which shows what you're trying that isn't working? It would also help to
see some sample data, and how it should be converted.
I don't know what COBOL COMP-3 fields are, but you may be able to use
unpack to get the data out. Then again, maybe not. :-) Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 3 May 1998 00:58:33 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Converting COBOL Comp-3 field
Message-Id: <EsCw1L.Exy@news.boeing.com>
In article <354bb933.0@news.primary.net>, Bob Tate <btate@primary.net> wrote:
>
> I need some help with converting a COMP-3 field to normal decimal. I am
> using PERL 5 and understand the COMP-3 format, also called "packed decimal"
> or "Binary Coded Decimal (BCD)". I know what the correct answer should be
> once the field is decoded. Even with all this info I am still missing the
> critical element that will allow me to decode the Comp-3 field. Any help
> would be great.
>
>
Here's something I saw which may give you a start:
sub ltobcd { # long to BCD
my $long = shift;
pack("H*", sprintf("%.7d%s", abs($long), ($long<0 ? 'd' : 'c')));
}
sub bcdtol { # BCD to long
my $bcd = shift;
$_ = unpack("H*", $bcd);
chop eq 'c' ? 0+$_ : -$_;
}
HTH,
--
Charles DeRykus
------------------------------
Date: Fri, 01 May 1998 15:46:52 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Converting COBOL Comp-3 field
Message-Id: <3549ec62.22644039@news.btinternet.com>
On Sat, 2 May 1998 19:23:35 -0500, Bob Tate wrote :
>Hello,
>
>I need some help with converting a COMP-3 field to normal decimal. I am
>using PERL 5 and understand the COMP-3 format, also called "packed decimal"
>or "Binary Coded Decimal (BCD)". I know what the correct answer should be
>once the field is decoded. Even with all this info I am still missing the
>critical element that will allow me to decode the Comp-3 field. Any help
>would be great.
>
Can you wait until tuesday? I left my COBOL programmers at work and I
threw the book out years ago.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 3 May 1998 00:16:53 GMT
From: Miles Lott <milos@vellocet.insync.net>
Subject: Re: Encryption of perl scripts
Message-Id: <6igd1l$9e6$1@synthemesc.insync.net>
Perhaps the new perl compiler will set this up for you?
brian d foy <comdog@computerdog.com> wrote:
> [all the stuff Tom said, and ...]
> In article <354B4B52.5E547E9E@koan.de>, hophuels@koan.de posted:
>>I have to write a perl/CGI script. It will be distributed on several
>>computers. How can I achive that nobody changes the script.
> well, you can't stop them from changing it, but you can keep the MD5
> digest handy so you know when they do. if you want to make that part
> of the license agreement somehow, that's up to you.
>>Is there a posibity that the Script is encrypted and decrypted
>>at execution time.
> curious idea, but it wouldn't stop the determined. what about storing
> gzipped scripts that are uncopressed then fed to the perl interpreter.
> seems like a simple, fake wrapper "perl" could do that for you. probably
> doesn't solve your problem and is easy to crack, but sounds like a cool
> hack :)
> good luck :)
> --
> brian d foy <comdog@computerdog.com>
> CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
> Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
> Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: Sun, 03 May 1998 01:08:13 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Miles Lott <milos@vellocet.insync.net>
Subject: Re: Encryption of perl scripts
Message-Id: <Pine.GSO.3.96.980502174517.8809N-100000@user2.teleport.com>
On 3 May 1998, Miles Lott wrote:
> Subject: Re: Encryption of perl scripts
>
> Perhaps the new perl compiler will set this up for you?
And perhaps the new perl decompiler will undo it. :-)
Don't let anyone tell you that compiling Perl will let you hide your
secret algorithm or copy-protect your program or keep people from altering
the behavior of your scripts. It won't. It also won't improve your gas
mileage or whiten your teeth or protect against rust or give you
long-lasting hold or be 99 44/100 % pure or taste great or be less filling
or cost ten cents per minute or be strong enough for a man and pH balanced
for a woman or even be finger-licking good. But compiling your Perl
program may indeed Just Do It. :-)
To find out more about what compiling might accomplish for you, though,
the FAQ has some good information.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 2 May 1998 23:01:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: extracting a sub-string
Message-Id: <6ig8jl$3c8$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, hawk@algonet.se writes:
:What's so terribly wrong with something like:
:
:#!/usr/bin/perl -w
:use strict;
:open( HTML, "index.html" ) || die( "No can do:\n$!" );
:while ( <HTML> ) {
: foreach ( /<.*?>/g ) {
: print "$_\n";
: }
:}
My advice is that you abandon the regex approach.
<A
NAME="fred"
HREF="#thither
>
<IMG SRC = "foo.gif" ALT = "A > B">
<!-- <A comment> -->
<SCRIPT>if (a<b && a>c)</SCRIPT>
<# Just data #>
<![INCLUDE CDATA [ >>>>>>>>>>>> ]]>
<!-- This section commented out. <B>You can't see me!</B> -->
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"It's easier to make up sayings people like to hear than sayings they
like to heed."
--Larry Wall
------------------------------
Date: Sun, 03 May 1998 00:07:54 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Hakan Hjelmstrom <hawk@algonet.se>
Subject: Re: extracting a sub-string
Message-Id: <Pine.GSO.3.96.980502170602.8809J-100000@user2.teleport.com>
On Sat, 2 May 1998, Hakan Hjelmstrom wrote:
> What's so terribly wrong with something like:
> while ( <HTML> ) {
> foreach ( /<.*?>/g ) {
<img src= 'arrow.gif' alt= "-->" >
The moral of the story is, if you need to parse HTML, it's best use an
HTML parser. Fortunately, if you use a module, that's easy to do. Hope
this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 3 May 1998 01:29:00 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: HELP Me PLEASE!
Message-Id: <6igh8s$f75$1@ns1.arlut.utexas.edu>
"Alex" <alex-oleinik@usa.net> writes:
>
> I use Windows
That's your problem right there.
And what is this doing in c.l.perl.misc?
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"It is obvious that about 750,000 people ago, Austin was a wonderful City."
------------------------------
Date: Sat, 02 May 1998 20:14:49 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: How meta search works?
Message-Id: <comdog-ya02408000R0205982014490001@news.panix.com>
Keywords: from just another new york perl hacker
In article <3549c76c.13451352@news.btinternet.com>, Gellyfish@btinternet.com (Jonathan Stowe) posted:
>On Sat, 02 May 1998 16:40:43 -0600, tietzmann@yahoo.com wrote :
>>I'm looking for some information regarding how a meta search works. Meta
>>search engines such as Metacrawler ( http://www.metacrawler.com ), can use
>>How they do it? Where can I find a CGI to do it?
>I dont know how *they* do it. But I would use LWP::UserAgent to pose
>the requests to said servers; HTML::parser to extract the relevant
besides those, there are also the WWW::Search modules that provide
interfaces to the various major search thingys.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: Sun, 03 May 1998 00:03:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Shawn <sweiner@usa.net>
Subject: Re: looking for a little bit of help here.
Message-Id: <Pine.GSO.3.96.980502163149.8809I-100000@user2.teleport.com>
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.
> #perl -w
>
> use carp;
Even if your system lets you get away with writing it like this, you
should properly capitalize module and pragma names. (Perl should probably
be made to warn you about this, if it doesn't already.)
> #This program is to try to convert messed up html files from pod2html
> #hopefully it will work
> # This is a sample url from one of the files
> # file:C:\Perl\html\lib\y/lib/site/Alias.html
>
> sub convert {
> $file=$_;
It's generally better to pass parameters in the normal way. perlsub
explains how to do that.
> $temp="temp.html";
> open (IN, "< $file");
> open (OUT, "> $temp");
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.
> while ($in=<IN>) {
> $_=$in;
I'm not sure why you're using $in here; the more-typical way is to use $_
as the line being read, since Perl provides many useful shortcuts for that
case.
while (<IN>) { # Puts line into $_ automatically
> if (/\\lib\\y\//) {
> $in =~ s/\\y\//\\..//g;
> }
I think you meant to use the same pattern in both places. If that's the
case, you don't really need the if test, since the substitution can't
happen unless the pattern matches. But if you're going to need slashes
within a pattern, it's often easier to use a different delimiter. Also, do
you really need the .. , or would it be better to shorten the path? (I may
have misunderstood, of course, so this may not be quite right.)
s#\\lib\\y/#/#g; # maybe?
> print OUT $in;
> }
> die "CHECK TEMP.HTML";
> #this is here for testing purposes else rename($temp,$file);
> }
Of course, that should die when the sub is about to return. But I think
you need to close both files before you could do the rename, if I
understand the DOS/Windows filesystem. (Maybe I don't understand it,
though. :-)
> my $dir='c:\perl\html\lib';
>
> opendir (DIR,$dir);
Probably a good idea to check the return from opendir, also.
> while ($_=readdir(DIR)) {
> if (/\.htm/||/\.html/) {
I think that should be this:
if (/\.html?$/) {
> &convert;
> }
> }
If you're still having troubles, it may be useful to step through your
code with the Perl debugger. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 03 May 1998 00:10:33 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: "Allan M. Due" <alpaca@iname.com>
Subject: Re: looking for a little bit of help here.
Message-Id: <Pine.GSO.3.96.980502170849.8809K-100000@user2.teleport.com>
On 2 May 1998, Allan M. Due wrote:
> > $in =~ s/\\y\//\\..//g;
> Both of those periods need to be escaped.
Not so. The right side of a s/// is a double-quotish string, so a dot is
just a dot. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 3 May 1998 00:23:37 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Passing type AV * ?
Message-Id: <EsCuFD.Czv@news.boeing.com>
In article <3548AE9F.41C67EA6@cs.yale.edu>,
Kaleem Siddiqi <siddiqi-kaleem@cs.yale.edu> wrote:
>I'd like to pass a pointer to the first element
>in a Perl array to a C subroutine, so that it
>can be modified. Can anyone help me with the perl syntax?
>
>My XS subroutine is:
>
>void
>SetArrayValue(array, width, height, val)
> AV *array
> int width
> int height
> SV *val
> CODE:
> {
> int xx,yy;
> for(yy = 0; yy < height; yy++){
> for(xx = 0; xx < width; xx++){
> av_store(array,xx+yy*height,val);
> }
> }
> }
> OUTPUT:
> array
>
>Consider a perl array, called @array,
>that contains 100x100 floating point numbers.
>
>The perl code:
>
>$var = 51.5;
>SetArrayValue(\@imagearray,100,100,$var);
>
>complains that the first argument is not of type AVPtr
>(although passing a pointer to a scalar works).
I believe the complaint means the array ref Perl
puts on the stack doesn't look like an AV * to
the XSUB at all - just a mere scalar. You'll have
to pry the array nature out of the scalar.
Clear as mud ?
Try something like this:
SetArrayValue(arrayRef, width, height, val)
SV *arrayRef
int width
int height
SV *val
CODE:
{
AV *array;
int xx,yy;
array = (AV *) SvRV(arrayRef)
for (...) {
for(...) {
av_store(array, xx + yy * width, SvREFCNT_inc(val));
}
}
}
HTH,
--
Charles DeRykus
------------------------------
Date: Sat, 02 May 1998 20:24:00 +0000
From: chuck kovacs <chuckk@monmouth.com>
Subject: Perl and Emacs question - perl debugging mode & cperl-mode vs perl-mode??
Message-Id: <354B80E0.28AF02C2@monmouth.com>
Hello,
I've just installed emacs and opened a perl file, I opened a new
'buffer' and ran M-x perldb. I was able to step through the code in the
perl debugger and watched the pointer advance in the code window (very
cool).
1. Is there any way I can set watches and have them appear in another
emacs 'buffer'?
2. The xemacs menus that show up while I'm perl debug mode don't seem to
do anything,
and I have to type s - to step through the code. Do I have something set
up improperly?
3) Also I am using the perl mode that came with emacs 20.2.1, what does
the cperl-mode.el
I've read about improve on the default perl mode?
Thanks,
Chuck
chuckk@monmouth.com
------------------------------
Date: 2 May 1998 23:07:11 GMT
From: tendus@rpi.edu (Saurabh S. Tendulkar)
Subject: problems with commands (newbie)
Message-Id: <6ig8uv$5u3@newsfeeds.rpi.edu>
I am using this following stuff in my code. However the "cd" command
fails to execute though I feel it should go to my home directory. It says
cannot exec to the directory specified. I also tried `cd $ENV{'HOME'}` but
that doesnt work either. Anything I am missing ?
`cd`;
@pluslist = `du`;
@pluslast = split(/ /, pop(@pluslist));
$plus = $pluslast[0];
TIA,
Saurabh.
------------------------------
Date: Sun, 03 May 1998 00:15:51 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: "Saurabh S. Tendulkar" <tendus@rpi.edu>
Subject: Re: problems with commands (newbie)
Message-Id: <Pine.GSO.3.96.980502171417.8809L-100000@user2.teleport.com>
On 2 May 1998, Saurabh S. Tendulkar wrote:
> Subject: problems with commands (newbie)
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
> `cd`;
See the FAQ, and the chdir function in perlfunc. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 01 May 1998 15:35:05 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: problems with commands (newbie)
Message-Id: <3549d5c9.17127647@news.btinternet.com>
On 2 May 1998 23:07:11 GMT, Saurabh S. Tendulkar wrote :
>
>I am using this following stuff in my code. However the "cd" command
>fails to execute though I feel it should go to my home directory. It says
>cannot exec to the directory specified. I also tried `cd $ENV{'HOME'}` but
>that doesnt work either. Anything I am missing ?
>
>`cd`;
>@pluslist = `du`;
>@pluslast = split(/ /, pop(@pluslist));
>$plus = $pluslast[0];
>
A moments reflection as to what the backticks are doing here (although
the result would be same if system or fork/exec were used) might
illuminate. The backticks cause a shell to be spawned with which to
run the external command. In the case of cd that external command
makes changes to the environment (in the general sense) of that shell,
shell exits and control resumes with the perl program that continues
to execute in its original environment.
You really should be using the builtin chdir.
If you are fiddling with a du kind of thing (uh-huh) you might search
on DejaNews for a posting to this group by Tom Christiansen with the
subject line:
SOURCE: recursive du summary
Which you might find illuminating if you're thinking of doing anythink
elaborate.
Why,oh why do they have Top of the Pops at 12:45 on a sunday morning ?
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 02 May 1998 23:29:13 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark-Jason Dominus <mjd@op.net>
Subject: Re: Randomly sorting an array
Message-Id: <Pine.GSO.3.96.980502152406.8809H-100000@user2.teleport.com>
On 2 May 1998, Mark-Jason Dominus wrote:
> In article <Pine.GSO.3.96.980501144215.2859R-100000@user2.teleport.com>,
> Tom Phoenix <rootbeer@teleport.com> wrote:
> > sub shuffle {
> > # returns a random shuffle of a given list
> > my @list = @_; # private copy
> > for my $i (1..$#list) { # Yes, start at 1!
> > my $j = rand($i+1); # pick one at or before $i
> > @list[$i,$j] = @list[$j,$i]; # swap
> > }
> > @list;
> > }
>
> We found that this runs somewhat faster if you insert
>
> next if $i == $j;
Odd; that condition should (almost) never be true. Did you add an int() as
well? (That should slow things down, I'd expect.) Or did you use this test
instead?
next if $j >= $i;
> in the obvious place. Perl seems to take a (comparatively) long time
> when it tries to do
>
> @x[$i,$i] = @x[$i,$i]
Yes, Perl might be somewhat slow to do that.
I chose to exclude that next (without benchmarking it) on the theory that,
for small lists, the time for shuffling is going to be small in any case,
and for large lists, the condition would be true so infrequently that it
would be a waste of time to check it.
Of course, there's no substitute for actually seeing what runs faster. My
test program follows my .sig. Here's what I found: If the list has fewer
than about 10 items, it's better to include the test, even though the
improvement is minimal. (On the order of dozens of microseconds per
shuffle.) If the list has more than about 100 items, it's better to omit
the test, since the improvement can be significant. (On the order of
milliseconds per shuffle.)
Based upon my testing, I'd say that, unless you know you'll be shuffling
many very short lists, you should omit the test. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
#!/usr/bin/perl -w
use Benchmark;
use strict;
# Adjust this according to the speed of the test machine...
# ...and your patience! :-)
use constant MAGNITUDE => 4;
sub shuffle {
# returns a random shuffle of a given list
my @list = @_; # private copy
for my $i (1..$#list) { # Yes, start at 1!
my $j = rand($i+1); # pick one at or before $i
@list[$i,$j] = @list[$j,$i]; # swap
}
@list;
}
sub shuffle_next {
# returns a random shuffle of a given list
my @list = @_; # private copy
for my $i (1..$#list) { # Yes, start at 1!
my $j = rand($i+1); # pick one at or before $i
next if $j >= $i;
@list[$i,$j] = @list[$j,$i]; # swap
}
@list;
}
for my $size (1..MAGNITUDE) {
my $bound = 2 * 10**$size;
my $reps = 5 * 10**(MAGNITUDE-$size+1);
my $trials = {
"$bound sans next" => sub { my @copy = shuffle 1..$bound },
"$bound with next" => sub { my @copy = shuffle_next 1..$bound },
};
timethese $reps, $trials;
print "\n";
}
__END__
------------------------------
Date: Fri, 01 May 1998 15:35:08 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: regex help
Message-Id: <3549de2c.19006247@news.btinternet.com>
On Sat, 02 May 1998 16:59:01 -0600, mehta@mama.indstate.edu wrote :
<snip>
>
>The regex is like:
>$prefix = "InterfaceName\.";
>s/([^\.]*)(identifier)/$1$prefix$2/g;
>
>if I could convey my problem could you help to perfect the regex. Basically
>its to be
>
<snip>
For myself, I would like to see some of the stuff that you are dealing
with this. I've seen java code before but still not quite sure what
you want to achieve.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 02 May 1998 20:11:23 -0600
From: Joel Horowitz <horowitz@ulb.ac.be>
Subject: Style question: trouble with $_ ...
Message-Id: <6igg7r$poj$1@nnrp1.dejanews.com>
Hye,
I tended to think that writing things like that:
...
$_=<FILE>; <---- ASSIGNING TO $_ !!!
chomp;
s/a/A/;
... whatever functions that use $_ as an implicit parameter...
print;
was very nice, however, I realised that assigning to $_ can lead to trouble.
And actually, using $_ in general can lead to trouble...
Here's an example:
sub troublemaker {
open(FILE,"anyfile");
while (<FILE>) { };
}
foreach (1..3) {
print "Before: <$_> ";
&troublemaker;
print "After: <$_>\n";
}
Gives:
Before: <1> After: <>
Before: <2> After: <>
Before: <3> After: <>
If instead I define troublemaker as
sub troublemaker {
foreach (a..e) {}
}
Then it does not make trouble, because I get:
Before: <1> After: <1>
Before: <2> After: <2>
Before: <3> After: <3>
Good programming practice recommends using local variables wherever it's
possible. However, when I try to put 'my $_' in the definition of
'troublemaker', it doesn't work... What do you think about that?
What are perl philosophical guidelines in such a case?
Thanks,
Joel
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 3 May 1998 01:22:38 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Substiting the backslash character
Message-Id: <6iggsu$1br$1@marina.cinenet.net>
Laura Morgan (laura.morgan@itron.com) wrote:
: If I have just read a line that contains backslashes for path seperators
: into $dirname, how do I substitute the backslash for a forward slash?
$dirname =~ s!\\!/!g;
It's a lot easier to write regexes and substitutions containing back and
forward slashes if you use an alternate pattern delimiter, like ! above.
: I have tried s/\\///, and miscel. other things, but I guess I don't
: understand enough about regular expression pattern matching.
If you did want to use the 'default' / patern delimiter, the substitution
would look like
$dirname =~ s/\\/\//g;
...which is a prime example of LTS ("Leaning Toothpicks Syndrome").
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
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 2480
**************************************