[9240] in Perl-Users-Digest
Perl-Users Digest, Issue: 2835 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 10 22:07:14 1998
Date: Wed, 10 Jun 98 19:00:31 -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 Wed, 10 Jun 1998 Volume: 8 Number: 2835
Today's topics:
Re: [Q] unpack( q/%32C*/ ... ) <rootbeer@teleport.com>
Re: [Q] unpack( q/%32C*/ ... ) (Larry Rosler)
Re: Any kind of help is hard to find. (Michael Dori)
Re: Any kind of help is hard to find. (Michael Dori)
Re: Any kind of help is hard to find. (Michael Dori)
Re: Command line substitution thru subdirectories (Andre L.)
Re: conditional use statement?? <craig@lucent.com>
Re: Crazzzzy Problem!!! (Michael J Gebis)
Re: Crazzzzy Problem!!! <rootbeer@teleport.com>
Re: Embedding VRML inside a Perl Script??? <rootbeer@teleport.com>
Re: Error Trapping with Net::FTP?? (Jeffrey Drumm)
Googol bytes (was: Re: [Q] unpack( q/%32C*/ ... )) <rootbeer@teleport.com>
Having problems locating a bug! Can anyone help? - di. (Chris Reynolds)
Re: McCabe complexity analysis (Nicholas Carey)
Re: Nee help splitting row contents <rootbeer@teleport.com>
Re: Nee help splitting row contents (Tad McClellan)
Re: Newbie: perl can't find modules <rootbeer@teleport.com>
Non-blocking Perl socket calls? (Tom O'Neil)
Re: Non-blocking Perl socket calls? <rootbeer@teleport.com>
Re: pack/unpack seps <rootbeer@teleport.com>
Re: Perl Books? (Gary M. Greenberg)
Re: Perl on NT using iis 4.0 <rootbeer@teleport.com>
PERL Pivot Table <glynadam@worldnet.att.net>
Re: Perl to C translator <rootbeer@teleport.com>
Re: Pipes between C program and perl script <rootbeer@teleport.com>
Please help me solve my error.. <dah_@hotmail.com>
Re: Replacing Specified Varibles in an HTML Page <rootbeer@teleport.com>
Re: Return characters from a string (Larry Rosler)
Stages in a pipeline <sbronson@opentv.com>
Unpacking hex string into array <pete@spry.com>
Re: Unpacking hex string into array <rootbeer@teleport.com>
Why it's stupid to `use a variable as a variable name' (Mark-Jason Dominus)
Re: Why it's stupid to `use a variable as a variable na <zenin@bawdycaste.org>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 11 Jun 1998 00:41:31 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: [Q] unpack( q/%32C*/ ... )
Message-Id: <Pine.GSO.3.96.980610172852.5401H-100000@user2.teleport.com>
On Wed, 10 Jun 1998 kissel@kissel.spicerack.ibm.com wrote:
> I'm a little puzzled by the results of unpack; can someone explain the
> following results to me? I must be overlooking something.
> perl -e 'print unpack( q/%32C*/, (qq/\cA/ x 4294967295) ), qq/\n/'
> 0 # unexpected! wanted 4294967295!
perl -le '$_ = qq/\cA/ x 4294967295; print length'
This could conceivably emit a diagnostic message. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 10 Jun 1998 17:51:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: [Q] unpack( q/%32C*/ ... )
Message-Id: <MPG.fe8c9d6b47c3a49896b5@nntp.hpl.hp.com>
In article <Pine.GSO.3.96.980610172852.5401H-100000@user2.teleport.com>,
rootbeer@teleport.com says...
> On Wed, 10 Jun 1998 kissel@kissel.spicerack.ibm.com wrote:
>
> > I'm a little puzzled by the results of unpack; can someone explain the
> > following results to me? I must be overlooking something.
>
> > perl -e 'print unpack( q/%32C*/, (qq/\cA/ x 4294967295) ), qq/\n/'
> > 0 # unexpected! wanted 4294967295!
>
> perl -le '$_ = qq/\cA/ x 4294967295; print length'
>
> This could conceivably emit a diagnostic message. :-)
Conceivably, but not on my installation of perl 5.004_03. It just prints
0 and new-line. Can you be more specific?
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Fri, 05 Jun 1998 18:38:12 GMT
From: michaeldore@hotmail.com (Michael Dori)
Subject: Re: Any kind of help is hard to find.
Message-Id: <35783987.151212471@news.nacs.net>
On 31 May 1998 20:27:21 GMT, nvp@shore.net (Nathan V. Patwardhan)
wrote:
>Michael Dori (michaeldore@hotmail.com) wrote:
>
>: re: help on an algorith for a search engine for my site, but i hope
>: that i speak for more than one new person who has asked a question,
>: been snided at or given cryptic or sar-caustic remarks, and never
>
>comp.lang.perl.misc is a WEB/CGI/HTML free zone if I'm correct, or at
>least it tries to be. People tend to freak out when they see web
>questions in this newsgroup, because of the *thousands* of web
>postings that have appeared in this NG over the last 2-3 years.
>
>Perl != CGI. Perl != WEB.
>
>In a way, it's a shame that newcomers are greeted with hostilities,
>but in another way it's a shame that Perl has been reduced to a "web
>language" and a device to make a quick buck by non-programmers. It's
>just a shame all the way around, I guess. :-(
Of course this assumes that i am a non programmer ... i am a
programmer with experience in c, c++, java, and some PERL. I was
seeking help with the algoritm because i have never writtem a search
engine.
>
>And don't forget that community is a two-way street.
I answer those questions that i can
>
>Your posting was very comedic, btw. It was entertaining to read.
and your was very condescending with a tone that cries out for
response.
------------------------------
Date: Fri, 05 Jun 1998 18:38:20 GMT
From: michaeldore@hotmail.com (Michael Dori)
Subject: Re: Any kind of help is hard to find.
Message-Id: <357a3acb.151536124@news.nacs.net>
On Thu, 4 Jun 1998 01:22:40 -0400, rjk@coos.dartmouth.edu (Ronald J
Kimball) wrote:
>Michael Dore <michaeldore@hotmail.com> wrote:
>
>> I have noticed that all the help that is proffered on most questions,
>> especially from new users, is usually returned in the form of "LOOK IT
>> UP". It is mostly assumed that we have not looked it up, or are too
>> lacking in intelligence to figure it out.
>
>And that assumption is almost always correct.
>
>
>Why is it that so many new programmers are incapable of reading Perl's
>documentation?
>
>1-617-555-2816
>
>Call me up, and I will read the Camel book to you.
>
>:-P
I appreciate the offer, but i believe this falls into the general
category of style, and not mechanics...
------------------------------
Date: Fri, 05 Jun 1998 18:38:15 GMT
From: michaeldore@hotmail.com (Michael Dori)
Subject: Re: Any kind of help is hard to find.
Message-Id: <35793a41.151398515@news.nacs.net>
On Sun, 31 May 1998 23:33:59 GMT, "Michael D. Schleif"
<mike.schleif@aquila.com> wrote:
>Without intending to contribute to another thread regarding
>applicability of certain postings to this or other newsgroups, I feel
>inclined to comment here.
>
>First, I agree that a newsgroup has value inasmuch as it has purpose,
>and focuses primarily on that end. That way, those of us who might
>require a forum of varying degrees of expertise, can avail ourselves of
>various search facilities and find a newsgroup with particular focus
>matching our needs. That is, each newsgroup follows a particular
>subject that gives it scope, context and content. If the scope, context
>and content of a particular newsgroup does NOT lend itself to my
>particular needs, then I can either find a more appropriate newsgroup or
>establish one myself.
>
>That being said, it stands to reason that some users DO violate said
>scope, and others DO overextend their welcome in this and other groups
>-- whereupon, regular users who stay within the lines are also within
>their rights to chastise such errant behavior, and possibly even direct
>them elsewhere.
>
>I DO NOT, however, find that a mere instance of the words "web," "cgi"
>or "html" contained within a posting necessarily, in and of itself,
>disqualifies that posting from being relevant to this, or any other,
>newsgroup.
>
>Specifically, I believe that "algorith" [sic] is a legitimate and
>germane topic, even coupled with the concept of search engine. In fact,
>I believe that most Perlies, with any substantive experience at all,
>must find it amazing how any "WEB/CGI/HTML" programming can be effective
>if the author(s) DO NOT understand algorithms fundamental to the tasks
>underlying all "WEB/CGI/HTML" programming. A "discussion," if you will,
>about search engine algorithms in this newsgroup may precipitate the
>dissemination of useful information to many thousands of Perl
>programmers, both gods and novitiates.
>
>Nevertheless, I also agree that, when it comes time for a participant to
>seek help in integrating that search engine algorithm into a website, at
>that time there are far more appropriate forums for these specific
>questions.
what would be the correct forum? ... and the integration was not the
focus, but the algoritm itself ..... and thank you for the input
>
>As always, I welcome comments and opinions regarding my banter . . .
>
>Nathan V. Patwardhan wrote:
>> Michael Dori (michaeldore@hotmail.com) wrote:
>> : re: help on an algorith for a search engine for my site, but i hope
>>
>> comp.lang.perl.misc is a WEB/CGI/HTML free zone if I'm correct, or at
>> least it tries to be.
------------------------------
Date: Wed, 10 Jun 1998 21:00:22 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Command line substitution thru subdirectories
Message-Id: <alecler-1006982100220001@dialup-638.hip.cam.org>
In article <6lmumg$qu8$0@206.165.146.195>, due@murray.fordham.edu (Allan
M. Due) wrote:
[...]
> Poor Bob. He asked a simple Perl question in clear and concise way,
> violating none of the mores of the social structure (with the one possible
> exception of being a WinXX user). He asked specifically for an solution
> in Perl, probably because he know that this is a newsgroup devoted to
> Perl. He received some answers that did not meet the criteria of his
> post, and which were potentially not technically under the purview of the
> newsgroup. These solutions were <shudder> not of a Perl nature. Someone
> noted their lack of Perlishness, pointed this feature out, and then....
>
> The heavens erupted, the lakes burned, locusts descended from on high.
> Cats and dogs living together! A tempest of biblical proportions.
>
> Poor Bob. A tragic, typhoid Mary, kind of figure. Little did he know what
> his simple question would portend. I wonder if he ever found what he was
> looking for. I guess we will never know.
>
> AmD
Hee hee. To think it's those people who want a moderated newsgroup. :-)
A.L.
------------------------------
Date: Wed, 10 Jun 1998 20:44:16 -0500
From: "Craig M. Votava" <craig@lucent.com>
Subject: Re: conditional use statement??
Message-Id: <357F3670.41C6@lucent.com>
Jonathan-
Thanks for the pointer. I thought it was in the
FAQ too, but I didn't find it either. The DejaNews
Search did the trick!
eval 'use MD5';
if ($@) {
print "Error!\n";
} else {
print "Fount!\n";
}
Thanks!
-Craig
Jonathan Stowe wrote:
>
> Hmm,
>
> This must be a FAQ <searches through perlfaq>, strange.
>
> Oh well when was it last asked ...
>
> Ah -
>
> if you search this group on DejaNews for a thread who's subject is:
>
> 'use' a module conditonally
>
> <sic>
>
> Then you will undoubtedly find some answers.
------------------------------
Date: 11 Jun 1998 00:37:48 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Crazzzzy Problem!!!
Message-Id: <6ln8ss$a5p@mozo.cc.purdue.edu>
e_nation <info@!enation.org> writes:
}I have a virtual server on which I host my website. There are alot of
}functions automated by the use of perl/cgi scripts. However, suddenly
}they seemed to stop working.
1) Your subject line sucks, which is a no-no on this group. Somebody
else will doubtless chastise you on this further. Have fun.
2) While your problem seem like a perl problem, it's really a cgi
problem. We would really really like to help, but we simply don't
know the answer to your question. There are several .cgi groups which
probably would apply.
3) Good luck.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Thu, 11 Jun 1998 00:59:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Crazzzzy Problem!!!
Message-Id: <Pine.GSO.3.96.980610175915.5401N-100000@user2.teleport.com>
On Wed, 10 Jun 1998, e_nation wrote:
> However, When I copy their script and try it I get the 403 forbidden
> message.
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 11 Jun 1998 00:48:24 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Embedding VRML inside a Perl Script???
Message-Id: <Pine.GSO.3.96.980610174552.5401J-100000@user2.teleport.com>
On Wed, 10 Jun 1998, Craig Pickles wrote:
> How do you embed vrml inside a perl script,
Using some kind of quoting, I'd say.
> I have tried setting the content type to:
>
> print "Content-type: x-world/x-vrml\n\n";
That looks like valid Perl. Maybe your error is elsewhere; perhaps you
want to put something different into that string. Perhaps the docs, FAQs,
and newsgroups about the protocol you're using would be of some assistance
to you. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 11 Jun 1998 01:03:30 GMT
From: drummj@mail.mmc.org (Jeffrey Drumm)
Subject: Re: Error Trapping with Net::FTP??
Message-Id: <357f212a.433014737@news.mmc.org>
[posted and mailed]
On 10 Jun 1998 19:33:52 GMT, wayne@Glue.umd.edu (Wayne C. McCullough)
wrote:
>Does anyone have any suggestions for how to trap errors while useing
>Net::FTP?
>
>I am writing an app where the user can enter in most of the FTP information
>(host, user, pwd, files, etc.), so I want to be able to give the user
>an informative error when things go wrong. Like "Invalid Host name" or
>"invalid login/password"
(snip)
If any of the methods fail (including new), they return undef. You can use
the message() method inherited from Net::Cmd to get the text of the failure
message with virtually all of them ( the obvious exception being new).
#!/usr/local/bin/perl -w
use Net::FTP;
my $ftp = Net::FTP->new('somehost') or die "Couldn't connect!\n";
$ftp->login('user','pass') or die $ftp->message;
$ftp->cwd('dir') or die $ftp->message;
.
.
.
You'll probably want to do something more useful than die on failures, but
I'm sure you get the idea.
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center Information Services
420 Cumberland Ave, Portland, ME 04101
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented." -me
------------------------------
Date: Thu, 11 Jun 1998 01:29:46 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Googol bytes (was: Re: [Q] unpack( q/%32C*/ ... ))
Message-Id: <Pine.GSO.3.96.980610181852.5401T-100000@user2.teleport.com>
On Wed, 10 Jun 1998, Larry Rosler wrote, quoting me:
> > This could conceivably emit a diagnostic message. :-)
>
> Conceivably, but not on my installation of perl 5.004_03. It just prints
> 0 and new-line. Can you be more specific?
Perhaps I should have said that, in a more perl-fect world, perl would
emit a diagnostic message (such as 'out of memory!') in this situation.
Here's a better test case:
perl -wle '$_ = "x" x 1e100; print "got a googol!"'
If it doesn't produce an error message, isn't Perl claiming that you've
just malloc'd a somewhat large amount of memory? Hard to believe... :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 11 Jun 1998 01:22:36 GMT
From: cmreynolds@hotmail.com (Chris Reynolds)
Subject: Having problems locating a bug! Can anyone help? - di.txt (0/1)
Message-Id: <357f2f9f.91141793@news.sprint.ca>
I previously posted on needing help with reading a directory and the
subdirectories and the size of all the files .. well, I worked on it
and I have almost all of it complete, however, I cannot seem to figure
out where I went wrong. I can read each directory in the main
directory, however, here is the problem, I can read the first
sub-directory but if there is more then one subdirectory it skips them
and goes back to the directory before that and moves along each other
directories in order .. can anyone see what I am missing or what I did
wrong?
Thank-you!
****************
#!/public/bin/perl -w
die "\nUsage : $0 [directory]" if ($#ARGV > 0);
$indet = " ";
open (DIRECT, "$ARGV[$#ARGV]") || die "can't open directory.";
while (<DIRECT>){
@Dir=();
push (@Dir,$ARGV[$#ARGV]);
chdir ($ARGV[$#ARGV]);
DoDir ($ARGV[$#ARGV],$indet);
}close (DIRECT);
sub dir {
$Dir=join ('/',@Dir);
$Dir=~s://:/:;
$Dir=~s:/\./:/:;
}
sub DoDir {
($Dname, $indet)= @_;
my(@array,@Dirs);
my($dir,$normal,$special);
$dir =0, $normal=0, $special=0;
print "$Dname\n";
opendir (DOT,"$Dname") || return;
@array = sort(readdir(DOT));
closedir (DOT);
$temp= shift (@array);
$hold=shift (@array);
print `pwd`;
for (@array){
if (-d $_){
print "Directory\n";
$dir+=1;
push (@Dirs,$_);
next;
}
if (-f $_){
$normal+=1;
}
#print "$array[$i]\n";
# $i++;
}
# unshift (@array,$temp,$hold);
print "$dir\n $normal\n";
for (@Dirs){
push (@Dirs,$_);
dir ();
$path= "$Dir/$_";
chdir ($path);
print "$path\n";
DoDir($path,$indet);
pop(@Dirs) || die;
dir ();
}
}
------------------------------
Date: Wed, 10 Jun 1998 17:38:03 -0700
From: ncarey@harlequin.com (Nicholas Carey)
Subject: Re: McCabe complexity analysis
Message-Id: <MPG.fe8c6c7deb1d17a989680@newshost>
In article <6lma5j$hk0$1@ns1.arlut.utexas.edu>,
smcdow@arlut.utexas.edu says...
> Stefaan.Eeckels@ecc.lu (Stefaan A Eeckels) writes:
> >
> > Warning C4706: Assignment within conditional expression.
>
> Get out. Really?
>
> How annoying.
>
> I wonder why they feel like they need to do so much hand-holding.
Because one of the most common, if not the most common,
programming errors in C (and probably perl) is the
quintessential
if ( foo = 3 )
rather than
if ( foo == 3 )
It's easy to do. It's not so easy to see. and it will kill you
every time. Of course, the lazy way to solve the problem if the
comparison involves a constant if to revese it so the constant
is on the left side:
if ( 3 == foo )
because
if ( 3 = foo )
generates a compiler error since a constant isn't allowed to
be an lval in C -- that is, it can't be assigned to.
And you can turn that compiler warning off with a #pragma if
you're so inclined.
--
Nicholas Carey
------------------------------
Date: Thu, 11 Jun 1998 00:58:40 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Nee help splitting row contents
Message-Id: <Pine.GSO.3.96.980610175741.5401M-100000@user2.teleport.com>
On Wed, 10 Jun 1998, Dave wrote:
> I need to split out the contents which are separated by commas and
> return each word or phrase as an option in an html dropdown box.
You probably want the split function. If that's not where you're stuck,
could you be more specific? Thanks!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 10 Jun 1998 20:24:54 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Nee help splitting row contents
Message-Id: <6lbnl6.3td.ln@localhost>
Dave (hannum@oak.cat.ohiou.edu) wrote:
: I want to read the contents of a table(which I can do) and then return
: those contents in the following manor -
^^^^^
Glad to see that you are not in OU's English department... ;-)
: Each row has two columns. The contents of one of the columns is
: words and phrases separated by a comma. I need to split out the contents
^^^^^
I think the split() function may help you with splitting...
: which are separated by commas and return each word or phrase as an option in
: an html dropdown box.
: If somebody can help me out with some code, I would be greatly appreciative.
Show us the code you have so far, and we'll help you fix it.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 Jun 1998 01:04:39 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Newbie: perl can't find modules
Message-Id: <Pine.GSO.3.96.980610180324.5401P-100000@user2.teleport.com>
On Wed, 10 Jun 1998 DerRunt@my-dejanews.com wrote:
> Can't locate lib.pm in @INC at Makefile.PL line 4.
That generally means that your perl binary or its support files, or both,
ar misinstalled. I recommend rebuilding it from the source. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 11 Jun 1998 01:20:49 GMT
From: oneilt@we.mediaone.net (Tom O'Neil)
Subject: Non-blocking Perl socket calls?
Message-Id: <357f3021.10697421@news.keyway.net>
How do I execute a non-blocking socket call in Perl? I'm opening a
socket to an Oracle database, sending an SQL command, and then
attempting to read the results. However, the socket read I'm doing
now will continue to wait for data even when none is coming. How do I
make this socket read non-blocking so the program will continue
execution if the database is finished sending data (or has none to
send). I have the following code:
#!/usr/local/bin/perl
use Socket;
use FileHandle;
$HOST = 'xxx.xxx.xx.xxx';
$PORT = '8888';
socket (SOCKET,PF_INET,SOCK_STREAM, (getprotobyname('tcp'))[2]);
connect(SOCKET,pack('Sna4x8',AF_INET,$PORT,(gethostbyname($HOST))[4]))
|| die "can't connect to db\n";
print SOCKET "SELECT MAX(REPORT_ID) FROM SALES_REPORTS\n";
while (<SOCKET>) { print "$_"; }
Tom O'Neil
tom@netoutfit.com
------------------------------
Date: Thu, 11 Jun 1998 01:48:24 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Non-blocking Perl socket calls?
Message-Id: <Pine.GSO.3.96.980610184656.5401Y-100000@user2.teleport.com>
On Thu, 11 Jun 1998, Tom O'Neil wrote:
> How do I make this socket read non-blocking so the program will continue
> execution if the database is finished sending data (or has none to
> send).
How do you know that there's no more data coming? Are you using
ESP::Prognosticate? :-)
But maybe you want the four-arg form of select to tell whether reading
will block. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 11 Jun 1998 01:00:59 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: pack/unpack seps
Message-Id: <Pine.GSO.3.96.980610180039.5401O-100000@user2.teleport.com>
On Wed, 10 Jun 1998, Ruben Safir wrote:
> This is still not explaining how UNPACK behaves
You are still not explaining in what way the documentation is failing you.
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 11 Jun 1998 00:55:28 GMT
From: garyg@gator.net (Gary M. Greenberg)
Subject: Re: Perl Books?
Message-Id: <MPG.fe8f0beda6f2e06989682@news.gator.net>
In article <6lk5qf$kdu$1@nnrp1.dejanews.com>, ptimmins@netserv.unmc.edu
says...
[snip]
> Try O'Reilly and Assoc at www.oreilly.com
>
> Learning Perl, 2nd Edition (Schwartz, Christiansen, and Wall)
> Programming Perl, 2nd Edition (Wall, Christiansen, and Schwartz)
>
> "Learning ..." is intro, 302 pp, $29.95 American
> "Programming ..." is the main reference, 670 pp, $39.95 American
And, let's not forget that all O'Reilly later editions are 25% off to
you when you tear out the title page from your old edition and mail it
in with your order for the new one ;-p
Cheers, G.
No affiliation to www.ora.com other than as a consumer
------------------------------
Date: Thu, 11 Jun 1998 00:53:20 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Perl on NT using iis 4.0
Message-Id: <Pine.GSO.3.96.980610175238.5401K-100000@user2.teleport.com>
On Wed, 10 Jun 1998, Yong Gao wrote:
> Following code works fine by using Perl xxx.pl but under cgi directory
> in IIS4.0 it didn't work from browser point of view,
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 10 Jun 1998 20:44:37 -0400
From: "Glyn Stanley" <glynadam@worldnet.att.net>
Subject: PERL Pivot Table
Message-Id: <6ln9bg$roq@bgtnsc02.worldnet.att.net>
Anyone know of any Perl modules or programs that produce Pivot table output
from CSV files?
Thanks,
Glyn
------------------------------
Date: Thu, 11 Jun 1998 00:42:23 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Perl to C translator
Message-Id: <Pine.GSO.3.96.980610174144.5401I-100000@user2.teleport.com>
On Wed, 10 Jun 1998, N Maderna wrote:
> Probably this question has been made thousands of times, but ...
...but that would make it a Frequently Asked (or Answered) Question,
wouldn't it? :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 11 Jun 1998 00:27:37 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Pipes between C program and perl script
Message-Id: <Pine.GSO.3.96.980610172542.5401G-100000@user2.teleport.com>
On Wed, 10 Jun 1998, Christian Krakowski wrote:
> The PERL program I wrote blocks when it reads from <STDIN>.
I'm not sure what problem you're having, but a Perl program will normally
block, if needed, when you use <STDIN>. By default:
$scalar = <STDIN>; # blocks until newline
@array = <STDIN>; # blocks until eof
Is that what you're seeing? Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 10 Jun 1998 20:10:09 -0400
From: "Drew" <dah_@hotmail.com>
Subject: Please help me solve my error..
Message-Id: <6ln75u$gl6$1@camel25.mindspring.com>
Any help with this would be appreciated.. I don't know Perl or the
necessary environment or other runtime issues but..
I downloaded a Perl script made some changes (elimination of print lines and
addition of comment lines). I uploaded it back to the server.. And I
executed the script the same way (within an HTML page) as I was before I
made the changes listed above. I suddenly started receiving an error like:
==========================
500 Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, [webmaster@isp] and inform them of
the time the error occurred, and anything you might have done that may have
caused the error.
==========================
I then restored the original Perl Script to the server and I got the same
error. I then bought a Perl book and I then thought I needed to issue a
"CHGMOD +x script_name". I continued to receive the same error even though
the script was the original one.. What else has to be done to prepare a
script for the environment?
Any help or suggestions would be GREATLY appreciated.
Thanks,
-Drew
DAH_@hotmail.com
------------------------------
Date: Thu, 11 Jun 1998 01:13:02 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Replacing Specified Varibles in an HTML Page
Message-Id: <Pine.GSO.3.96.980610180642.5401R-100000@user2.teleport.com>
On Thu, 11 Jun 1998, Adam Carden wrote:
> The problem I have is how to replace the variables from the html file
> with the real ones if I just print the html file out line by line perl
> does not automatically replace any variables it finds.
And for good reason - if Perl automatically turned every $foo into the
value of $foo, how could you ever print '$foo'? :-)
But see section four of the FAQ to find out about how to do what I think
you're asking.
> begin 666 click_quote_out.html
Please don't post binaries to non-binary newsgroups; they'll just be
cancelled in most cases anyway. Thanks.
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 10 Jun 1998 17:21:57 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Return characters from a string
Message-Id: <MPG.fe8c3001153f429896b4@nntp.hpl.hp.com>
In article <6lm9gu$3u94@eccws1.dearborn.ford.com>, tph@longhorn.uucp
says...
> Zenin (zenin@bawdycaste.org) wrote:
> : Mike Baroukh <f024101@fr.ibm.com> wrote:
> : : I'd like to return char 1 to 22 of q string. Is there a way to do it without
> : : using functions like cut ?
>
> : $string = 'A' x 100;
> : $piece = substr $string, 0, 22; # 0 is first char/byte of string
>
> I would have done it this way:
>
> ($piece = $string) =~ s/^(.{22}).*/$1/;
>
> ...but maybe I'm just weird...
...
Not weird, just slow. Very slow. TMTOWTDI, but they're not all "created
equal."
#!/usr/local/bin/perl -w
use Benchmark;
$string = 'A' x 100;
sub cntrl { $piece = $string }
sub regex { ($piece = $string) =~ s/^(.{22}).*/$1/ }
sub subst { $piece = substr $string, 0, 22 }
timethese (1 << 16, {
Cntrl => 'cntrl()',
Regex => 'regex()',
Subst => 'subst()',
} );
__END__
Benchmark: timing 65536 iterations of Cntrl, Regex, Subst...
Cntrl: 5 secs ( 1.31 usr 0.01 sys = 1.32 cpu)
Regex: 23 secs ( 5.73 usr 0.06 sys = 5.79 cpu)
Subst: 6 secs ( 1.56 usr 0.02 sys = 1.58 cpu)
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Jun 1998 18:49:03 -0700
From: Scott Bronson <sbronson@opentv.com>
Subject: Stages in a pipeline
Message-Id: <357F378F.6A9E8004@opentv.com>
I've been programming in Perl for a few weeks now. Long enough to
recognize that there must be an elegant(ish) Perl solution to this
problem, but not long enough to know what it is.
I've got a bunch of fucntions. All of them accept data as an argument,
process it, and return the processed data as their result. The data is
an array of lines, but that should be unimportant.
Now, I'd like to set these functions up as a pipeline. One pipeline
configuration would be:
Print -> Format_Lists -> Number_Lines -> Remove_Header -> Get_Paragraph
So, print calls Format Lists until Format_Lists returns null, printing
out the data returned, and so on up the pipe. If I didn't want line
numbers, I just re-order the stages in the pipe:
Print -> Format_Lists -> Remove_Header -> Get_Paragraph
And if I wanted headers and formatted lists, but no line numbers:
Print -> Format_Lists -> Get_Paragraph
You get the idea. What's an efficient, flexible way to set this up in
Perl? Thanks,
- Scott
sbronson@opentv.com
------------------------------
Date: Wed, 10 Jun 1998 17:46:31 -0700
From: Dan Peterson <pete@spry.com>
Subject: Unpacking hex string into array
Message-Id: <357F28E7.A0BED730@spry.com>
How can I unpack a hex string into an array of words?
For example, given the following hex string:
$str = '0000016500000002';
@data = unpack("H8 H8", $str);
@data should contain:
(357, 2)
Obviously, the unpack command above doesn't work, or I'd just use that.
I
included it to show how I want to split the hex string.
Here's another example:
$str = '0000015d001c00110000002d00400000006d000000f0';
@data = unpack("H8 H4 H4 H8 H4 H8 H8", $str);
and @data should contain:
(349, 28, 17, 45, 64, 109, 240)
The hex strings I'm processing are actually over 700 bytes long, and
contain
around 20 values.
Thanks for any help.
PS. Please respond directly to my email address, or at least CC me.
--
------------------------------------------------------------------------
Dan Peterson System Architect SPRYNET
Email: pete@spry.com Phone: 425-957-8240 FAX:
425-957-6240
------------------------------------------------------------------------
------------------------------
Date: Thu, 11 Jun 1998 01:18:40 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Unpacking hex string into array
Message-Id: <Pine.GSO.3.96.980610181436.5401S-100000@user2.teleport.com>
On Wed, 10 Jun 1998, Dan Peterson wrote:
> For example, given the following hex string:
>
> $str = '0000016500000002';
> @data = unpack("H8 H8", $str);
>
> @data should contain:
>
> (357, 2)
Who says? :-)
But it looks to me as if you're wanting first to pack those hex values to
make a 32-bit-long string, then unpack _that_ as an integer. Could that be
what you want?
> The hex strings I'm processing are actually over 700 bytes long, and
> contain around 20 values.
So, each value is around 35 bytes long? I don't know that you're going to
be able to turn a 35-byte value into a Perl number on most modern
machinery without using something like Math::Big*. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 10 Jun 1998 21:17:20 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Why it's stupid to `use a variable as a variable name'
Message-Id: <6lnb70$lct$1@monet.op.net>
Keywords: erasable mantissa mock wristwatch
People show up in comp.lang.perl.misc all the time asking how to use
the contents of a variable as the name of another variable. For
example, they have $foo = 'snonk', and then they want to operate on
the value of $snonk.
That's very easy to do in Perl, so they usually get some people to
tell them to do it. And they usually get some people asking them why
they didn't use a hash instead. Sometimes I'm one of the people who
says to use a hash instead, and sometimes I'm one of the people who
answers the question that was asked, even though I think they should
be using a hash instead.
Anyway, a couple of weeks ago one of my clients called up with some
program that was producing wrong reports. They needed it to be fixed
by the following day. The program was going to read a database with
records like these:
this red something
that green something else
other red more
this blue still more
and build a report of how many records had each value in each
position.
It turned out that the clods who had written this program had done
something like this:
while (<RECORDS>) {
chomp;
@values = split /\t/, $_;
foreach $v (@values) {
$$v++;
}
}
print <<EOM;
Question 1:
$this users said `this'. $that users said `that'.
Question 2:
$red users said their favorite color was red.
... (and so on ) ...
EOM
Of course, the actual code was much longer and much more obfuscated.
Anyway, to make a long story short, the problem turned out to be that
there was a certain response, let's say `foo', (actually, it was
`digoxin'---go figure) which was a valid response for two totally
unrelated questions, say #7a and #11. So anyone answering `foo' to
question 7a would be counted as having answered `foo' to question 11
as well, and vice versa. At the end of the analysis, the $foo
variable contained the *sum* of all the users who answered `foo' to
either question 7a or to question 11. Then the reports used this sum
in two places, and that's why the reports were inaccurate.
This shoddy logic was so pervasive in the program that I couldn't find
an easy way to fix it. If the original programmers had used a series
of hashes instead of stuffing everything into a bunch of global
variables, it would never have happened, or at worst it would have
been easy to fix. I ended up doing a major overhaul on the program to
solve the problem. The main loop turned into something more like:
while (<RECORDS>) {
chomp;
@values = split /\t/, $_;
for ($i=1; $i <= $NUMQUESTIONS; $i++)
my $v = shift @values;
$count[$i]{$v}++
}
}
Of course, the actual code was much longer and much more obfuscated,
although it was nither as long nor as obfuscated as when I got to work
on it.
I shudder to think what would have happened to this program if one of
the responses had been named `i' or `v' or `3' or some such. One can
even imagine that that happened once upon a time, and the reponse was
to change the name instead of taking the warning.
Anyway, deriving the name of the variable from an input value turned
out to be a very stupid decision in this case, and one which cost my
client a couple of thousand dollars.
When people come into comp.lang.perl.misc asking how to do something
stupid, I'm never quite sure what to do. I can just answer the
question as asked, figuring that it's not my problem to tell people
that they're being stupid. That's in my self-interest, because it
takes less time to answer the question that way, and because someone
might someday pay me to clean up after their stupidity, as happened in
this instance. But if I do that, people might jump on me for being a
smart aleck, which has happened at times. (``Come on, help the poor
guy out; if you know what he really need why don't you just give it to
him?'')
On the other hand, I could try to answer on a different level, present
a better solution, and maybe slap a little education on `em. That's
nice when it works, but if it doesn't it's really sad to see your hard
work and good advice ignored. Also, people tend to jump on you for
not answering the question. (``Who are you to be telling this guy
what he should be doing? Just answer the question.'')
I guess there's room for both kinds of answer. Or maybe there isn't
room for either kind.
Whatever. I seem to have gone off on a tangent. The real root of the
problem code is: It's fragile. You're mingling unlike things when you
do this. And of two of those unlike things happen to have the same
name, they'll collide and you'll get the wrong answer. So you end up
having a whole long list of names which you have to be careful not to
reuse, and if you screw up, you get a very bizarre error. This is
precisely the problem that namespaces were invented to solve, and
that's just what a hash is: A portable namespace.
The main point of this article was to present a real example of a case
where using a variable as a variable name was a really stupid thing to
do. Since most of the people who post about that in
comp.lang.perl.misc seem to be trying to do the same stupid thing in
the same stupid way, I thought I'd mention it, and maybe raise the
general awareness of this problem.
------------------------------
Date: 11 Jun 98 01:33:30 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Why it's stupid to `use a variable as a variable name'
Message-Id: <897529556.658588@thrush.omix.com>
Mark-Jason Dominus <mjd@op.net> wrote:
>snip<
: The main point of this article was to present a real example of a case
: where using a variable as a variable name was a really stupid thing to
: do.
>snip<
But just don't forget that you can do it when you need to. There
are valid reasons to use soft refs, it's just that most of them
are at the wizard level.
Always, always use strict. If you have a small piece that needs
soft refs, subs, etc then mark it as such:
use strict;
{
no strict 'refs'; # eg, warning: we are doing funky things here
...magic only goes here...
}
--
-Zenin
zenin@archive.rhps.org
------------------------------
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 2835
**************************************