[9283] in Perl-Users-Digest
Perl-Users Digest, Issue: 2878 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 15 19:07:13 1998
Date: Mon, 15 Jun 98 16:00:29 -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 Mon, 15 Jun 1998 Volume: 8 Number: 2878
Today's topics:
Re: A hash question <zenin@bawdycaste.org>
Re: A hash question (Bob Trieger)
Re: A hash question (Mark-Jason Dominus)
Re: A hash question (Craig Berry)
Re: Care to check a script of mine? (James B. Crigler)
Case of newbie and .db jharris01@my-dejanews.com
Re: Certified Perl Programmers <gnat@frii.com>
Re: CGI Perl Programming Problem. emery@wizweb.com
Re: CGI Perl Programming Problem. (Bob Trieger)
CODE: Change specs of icons in Win95 (Andy Lester)
Re: conditional curiosity... <dean@mail.biol.sc.edu>
Re: Curly braces in if elsif contructs (Bob Trieger)
Re: Curly braces in if elsif contructs <probavm@h8mail.laf.cat.com>
Re: Curly braces in if elsif contructs <zenin@bawdycaste.org>
Re: Forking, SIG handlers, etc. (Long) <gnat@frii.com>
Re: Handling of the ASCII behavior of ^M (Mark-Jason Dominus)
Re: HELP WITH SOME NEWBIE HACKED CODE??? 6xtippet@CyberJunkie.com
Re: how do I save a perl file <kperrier@blkbox.com>
I need a simple scrip that... <lsain@vnet.net>
Re: I need a simple scrip that... <probavm@h8mail.laf.cat.com>
Re: I need a simple scrip that... (Bob Trieger)
Keeping the global value of a local variable. letranger@my-dejanews.com
Keeping the global value of a local variable. jlamport@calarts.edu
Re: Keeping the global value of a local variable. (Chris Nandor)
MIME-tools and MailTools modules confusion (Paul L. Lussier)
Re: mod_perl newsgroup? <ask@netcetera.dk>
Re: Need a jumpstart with creating csv (Gary M. Greenberg)
Need printer interface script in Perl for Solaris 2 (Allan G. Weber)
Re: Perl5 and the X11 libraries. <tresing@globalscape.net>
Re: Perl5 and the X11 libraries. (Stuart McDow)
Re: REVIEW: Perl CGI Programming - No Experience Requir (Chris Nandor)
Re: REVIEW: Perl CGI Programming - No Experience Requir (Craig Berry)
Re: REVIEW: Perl CGI Programming - No Experience Requir (Chris Nandor)
Re: strange error message .. "value of <handle> ..." (Michael J Gebis)
Re: Unpacking hex string into array <jack.chastain@attws.com>
Use of DBD::Oracle from cron (Todd Hivnor)
Re: Windows NT, how to copy binary files ! (Bob Trieger)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Jun 1998 21:15:50 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: A hash question
Message-Id: <897945879.503464@thrush.omix.com>
Paul Cameron <pcameron@soils.umn.edu> wrote:
: I finally getting around to using hashes and I ran into this problem.
Using hash will cause you all kinds of problems down the road. :-)
: I've got two arrays and I want to build a hash so that array1 will be
: the key and array2 will be the value.
@info{@names} = @data;
Yes, info is a hash, even with an @ sign on it in this usage.
Or, if you must go the long way:
for (my $i = 0 $i <= $#names; $i++) {
$info{$names[$i]} = $data[$i];
}
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: Mon, 15 Jun 1998 21:10:21 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: A hash question
Message-Id: <6m42n4$htu$7@ligarius.ultra.net>
[ posted and mailed ]
-> Paul Cameron <pcameron@soils.umn.edu> wrote:
-> -> I finally getting around to using hashes and I ran into this problem.
-> ->
-> -> I've got two arrays and I want to build a hash so that array1 will be
-> -> the key and array2 will be the value. The way its set up now I'm only
-> -> getting the last key,value pair I put in the hash. I just wondering if
-> -> anyone has any ideas on how to make this work or is it just not
-> -> possible. Here's some of the code.
-> ->
-> -> @names = "a bunch of names";
-> -> @data = "info about those names";
-> ->
-> -> $count = @data;
-> -> for ($i = 0; $i < $count; $i++ ) {
-> -> %info = ( "$names[$i]", "$data[$i]" );
-> -> }
Change the %info line to:
$info{$names[$i]} = $data[$i];
or
foreach (@names) {
%info{$_} = shift @data;
}
or
a dozen other ways to do it.
HTH
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
and hang up when the recording starts. "
------------------------------
Date: 15 Jun 1998 17:52:00 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: A hash question
Message-Id: <6m4520$8bk$1@monet.op.net>
Keywords: boar inexperience muriatic silt
In article <35858853.41C6@soils.umn.edu>,
Paul Cameron <pcameron@soils.umn.edu> wrote:
>I've got two arrays and I want to build a hash so that array1 will be
>the key and array2 will be the value.
Concise method:
@info{@names} = @data;
Straightforward method:
for ($i = 0; $i < @data; $i++ ) {
$info{$names[$i]} = $data[$i];
}
>for ($i = 0; $i < $count; $i++ ) {
> %info = ( "$names[$i]", "$data[$i]" );
>}
When you write
%info = (...)
that assignes the list on the right to the hash, replacing whatever
values were in the hash before. That's why only the last pair
sticks; you over-wrote the others.
Also, as style point. In this:
"$data[$i]"
the quotes are at best superfluous, and at worst wrong. You should
leave them out.
------------------------------
Date: 15 Jun 1998 22:00:54 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: A hash question
Message-Id: <6m45im$42l$4@marina.cinenet.net>
Paul Cameron (pcameron@soils.umn.edu) wrote:
: I've got two arrays and I want to build a hash so that array1 will be
: the key and array2 will be the value. The way its set up now I'm only
: getting the last key,value pair I put in the hash. I just wondering if
: anyone has any ideas on how to make this work or is it just not
: possible. Here's some of the code.
:
: @names = "a bunch of names";
: @data = "info about those names";
Presumably the real arrays are actually multi-member arrays, and not
one-member arrays created through dubious magic like your examples above.
:
: $count = @data;
: for ($i = 0; $i < $count; $i++ ) {
: %info = ( "$names[$i]", "$data[$i]" );
: }
Your loop there rewrites %info from scratch on each iteration, so of
course you only get the last pair. A much more perlish way to write it
your way would be
die "Mismatched array sizes" unless @names == @data;
for (my $i = 0; $i < @data; $i++) {
$info{$names[$i]} = $data[$i];
}
But the ludicrously rich expressive power of Perl comes to your aid, so
you can simplify this to
@info{@names} = @data;
...a technique called a "hash slice." You might want to keep the die (or
warn) if the sizes don't match, of course.
---------------------------------------------------------------------
| 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: 15 Jun 1998 18:56:22 -0400
From: crigler@seo.com (James B. Crigler)
Subject: Re: Care to check a script of mine?
Message-Id: <lzvhq2e0kp.fsf@jim.seo.com>
>>>>> "Tom" == Tom Phoenix <rootbeer@teleport.com> writes:
Tom> On Thu, 11 Jun 1998, Aloud.com wrote:
>> The induhviduals who commisioned the script aren't happy with the
>> speed. They have boosted the bandwith of the second webserver so
>> the connection is fast. Now that they have address everything
>> else, the finger is now pointing at our scripts. We don't know how
>> to optimise the script any further. Is there any one out there who
>> would look over our script and suggest areas of improvements?
Tom> Maybe your script is especially slow at what it's doing, or
Tom> maybe it isn't. But in any case, Perl programs are
Tom> not-infrequently accused of being too slow, often on the grounds
Tom> that "since Perl programs aren't compiled, they can't be as fast
Tom> as C programs." As with other half-truths, there's more to the
Tom> story.
Tom gives much good advice: you should heed it. One thing not
mentioned in Tom's reply (and not mentioned in the original post,
which I had to look up the hard way, since it had expired), is that if
you're doing this with standard CGI, then you're incurring perl
startup time in addition to execution time. If you're using Apache,
you should get and compile in the mod_perl module, which
(approximately) gives the server a running perl.
--
Jim Crigler <crigler@seo.com>
Schwartz Electro-Optics, Inc. Voice: (407)298-1802 x200
3404 N. Orange Blossom Trl. Fax: (407)290-9666
Orlando FL 32804-3498 USA
------------------------------
Date: Mon, 15 Jun 1998 21:45:34 GMT
From: jharris01@my-dejanews.com
Subject: Case of newbie and .db
Message-Id: <6m44lv$m4o$1@nnrp1.dejanews.com>
I just dove into PERL and I am curious about the dbmopen function. I have a
238M .db file that I would like to open up and peek into. Once I figure this
out then I can decide what I want to do with the db. Can someone point me in
the direction of how to open and just print out the .db file?
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 15 Jun 1998 13:44:15 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: Certified Perl Programmers
Message-Id: <5qemwq4fhs.fsf@prometheus.frii.com>
Rosemary I H Powell <Rosie@dozyrosy.demon.co.uk> writes:
> Why don't you make it $4 and donate $2 to Randal's legal fund and we'd
> all benefit?
Well, Randal would benefit. Randal isn't yet everyone, although I
believe his ascendency to a ball of all-encompassing light is
scheduled for 1Q 2004.
Nat
------------------------------
Date: Mon, 15 Jun 1998 22:01:45 GMT
From: emery@wizweb.com
Subject: Re: CGI Perl Programming Problem.
Message-Id: <6m45k9$o5l$1@nnrp1.dejanews.com>
In article <6m3oa3$c2c$1@ligarius.ultra.net>,
sowmaster@juicepigs.com (Bob Trieger) wrote:
>
> [ posted and mailed ]
> emery@wizweb.com wrote:
> -> I wrote this particular Perl program that is available to be used on
> -> the Internet. Usually there is not a problem to put up a submit form
> -> for querying by Perl. In this case, however, there is a series of
> -> steps to follow through and information needs to get to one form to
> -> the next. I thought it may have been satisfactory to put the needed
> -> info into the form by hidden types. Only the problem is that if
> -> someone else at the same time is using the site the two users infos
> -> will get mixed (the values in the form will change).
>
> >> Snipples <<
>
> -> Could you give me some suggestions. Is there and environment variable
> -> that would tell me the history of the client (last location)? This
> -> might help.
>
> You are asking this in the wrong newsgroup. You will get much more help in
>
> news:comp.infosystems.www.authoring.cgi
>
> The simple answer is cookies.
>
> HTH
>
> Bob Trieger
> sowmaster@juicepigs.com
> " Cost a spammer some cash: Call 1-800-239-0341
> and hang up when the recording starts. "
>
Thanks for the information.
Cookies may taste good; but I found out that if I put all the needed
info into a virtual HTML form hidden input it will make each person's
input there own.
If you want to keep something - hide it!
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 15 Jun 1998 22:41:39 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: CGI Perl Programming Problem.
Message-Id: <6m482b$qkt$1@strato.ultra.net>
[ posted and mailed ]
Please note change in follow-up
emery@wizweb.com wrote:
-> Cookies may taste good; but I found out that if I put all the needed
-> info into a virtual HTML form hidden input it will make each person's
-> input there own.
->
-> If you want to keep something - hide it!
Doing what you described is going to take a login script and a user database
if you want it to carry over. Cookies will keep everyone separate except those
that may share a computer with others and coincedentally also happen upon your
site. The chances of this happening are next to nil since there are a
bazillion sites out there and everybody has different interests.
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
and hang up when the recording starts. "
------------------------------
Date: 15 Jun 1998 22:32:17 GMT
From: petdance@maxx.mc.net (Andy Lester)
Subject: CODE: Change specs of icons in Win95
Message-Id: <6m47dh$are$1@supernews.com>
In the latest in my attempts to get the new folks to realize there's a
world of useful stuff out there, here's a little script I wrote that
updates the icon specs in my Win95 system to look at a new server:
\\Advisor gets changed to \\Webster, and the file is rewritten.
It's a no-brainer, but only because the Win32::Shortcut module exists.
I'm certainly glad it does.
#!perl -w
use strict;
use Win32::Shortcut;
my $filespec = shift or die "Must pass a filespec";
for my $filename ( glob( $filespec ) ) {
my $shortcut = Win32::Shortcut->new( $filename );
if ( $shortcut->{IconLocation} =~
s[^\\\\advisor\\][\\\\Webster\\]i ) {
$shortcut->Save( "$filename" );
warn "$filename\n";
} # if
}
--
--
Andy Lester: <andy@petdance.com> http://tezcat.com/~andy/
Chicago Shows List: <shows@ChicagoMusic.com> http://ChicagoMusic.com/
------------------------------
Date: 15 Jun 1998 16:52:04 -0400
From: Dean Pentcheff <dean@mail.biol.sc.edu>
Subject: Re: conditional curiosity...
Message-Id: <m3emwqe6bv.fsf@mail.biol.sc.edu>
"Brent Verner" <REPLY_TO_damonbrent@earthlink.net> writes:
> is there any benefit (aside from less lines of code) to using :
>
> $a = $b if $b;
>
> rather than :
>
> if ($b)
> {
> $a = $b;
> }
>
> is the former less expensive?
#!/usr/local/bin/perl
use Benchmark;
timethese(1000000, {
'equalsif' => '$b = int rand 2; $a = $b if $b;',
'ifequals' => '$b = int rand 2; if ($b) {$a = $b;}',
}
);
Perl 5.004_4 on a Dell Pentium 333 running Linux 2.0.34:
Benchmark: timing 1000000 iterations of equalsif, ifequals...
equalsif: 3 secs ( 2.39 usr 0.00 sys = 2.39 cpu)
ifequals: 4 secs ( 2.40 usr 0.00 sys = 2.40 cpu)
Y'know, I just don't think it matters.
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)
------------------------------
Date: Mon, 15 Jun 1998 20:50:43 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Curly braces in if elsif contructs
Message-Id: <6m41if$htu$2@ligarius.ultra.net>
[ posted and mailed ]
stephen farrell <sfarrell@farrell.org> wrote:
-> well of the three styles,
->
-> if
-> {
-> ...
-> }
-> else
-> {
-> ...
-> }
->
-> takes up too much space, and
->
-> if {
-> ...
-> } else {
-> ...
-> }
->
-> takes up too little space, so
->
-> if {
-> ...
-> }
-> else {
-> ...
-> }
->
-> seems just right =).
Who are you? Goldilocks? :)
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
and hang up when the recording starts. "
------------------------------
Date: Mon, 15 Jun 1998 16:00:40 -0500
From: "Vincent M. Probasco" <probavm@h8mail.laf.cat.com>
Subject: Re: Curly braces in if elsif contructs
Message-Id: <35858B78.6B2D0B94@h8mail.laf.cat.com>
Personally, I like ...
if{}else{}if{}elsif{}elsif{}if{}else{}if{}elsif{}elsif{}if{}else{}if{}if{}if{}elsif{}
if{}elsif{}else{}if{}else{}if{}if{}if{}elsif{}if{}else{}if{}elsif{}if{}if{}elsif{}if{}else{}
But that's just me. :)
------------------------------
Date: 15 Jun 1998 21:09:24 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Curly braces in if elsif contructs
Message-Id: <897945493.514320@thrush.omix.com>
scott@softbase.com wrote:
>snip<
: I dislike this, and the equivalent C
: if () {
: } else {
: }
: on the grounds that it obfuscates the code unnecessarily.
Actually I find that your style obfuscates code unnecessarily.
It makes the else block look like it's floating by itself, which
it in no way is.
: An important
: keyword should not be left on the ground amongst a dense undergrowth of
: squiggles. It needs to be held up high where people can notice it.
It's not left anywhere. The if/else/elsif's are by definition
tied to the others. The cuddled brace just makes this point
clearer, not obfuscated.
: Also, the obfuscatory style defeats good block structuring by defeating
: the logical structure of the code. Both the if and else are important
: and need to begin a block, not be nested in a squiggle forest.
They have it, the brace. What do you think a block is defined by?
It's not the key word, that's for sure.
: For every construct, you'll find people who argue different ways.
Yep.
Let the flames begin!
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: 15 Jun 1998 12:22:14 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: Forking, SIG handlers, etc. (Long)
Message-Id: <5qg1h64jah.fsf@prometheus.frii.com>
"Gabriele R. Fariello" <gabriele@kollwitz.doit.wisc.edu> writes:
> Alas, it seems that some SIGs get lost.
Excellent conclusion to draw. There are a couple of things you can
do:
(1) make sure you're using version 5.004 of Perl. It had some
changes to make signal handlers a tad more reliable.
(2) use waitpid() in a non-blocking fashion, and not wait(), so you
can catch multiple deaths.
Here's the relevant bit from The Perl Cookbook (by Tom Christiansen
and Nathan Torkington, to be published by O'Reilly and Associates in
August, plug plug :-):
Problem
Your program forks children, but the dead children
accumulate, fill up your process table, and aggravate your
system administrator.
Solution
If you don't need to record which children have
terminated:
$SIG{CHLD} = 'IGNORE';
To keep better track of deceased children, install a
SIGCHLD handler to call waitpid:
use POSIX ":sys_wait_h";
$SIG{CHLD} = \&REAPER;
sub REAPER {
my $stiff;
while ($stiff = waitpid(-1, &WNOHANG) > 0) {
# do something with $stiff if you want
}
$SIG{CHLD} = \&REAPER; # install *after* callin
g waitpid
}
Discussion
When a process exits, the system keeps it in the process
table so the parent can check its status--whether it
terminated normally or abnormally. Fetching a child's
status (thereby freeing it to drop from the system
altogether) is rather grimly called ``reaping'' dead
children,[FOOTNOTE: This entire recipe is full of ways to
harvest your dead children. If this makes you queasy, we
understand.] and involves a call to wait or waitpid. Some
Perl functions (piped opens, system, and backticks) will
automatically reap the children they make, but you must
explicitly wait when you use fork to manually start
another process.
The simplest way to avoid dead children accumulating is to
tell the system that you're not interested in them by
setting $SIG{CHLD} to "IGNORE". If you want to know which
children die and when, though, you'll need to use waitpid.
The waitpid function reaps a single process. Its first
argument is the process to wait for--use -1 to mean any
process--and its second argument is a set of flags. We
use the WNOHANG flag to make waitpid immediately return 0
if there are no dead children. A flag value of 0 is
supported everywhere, indicating a blocking wait. Call
waitpid from a SIGCHLD handler, as we do in the Solution,
to reap the children as soon as they die.
There is another function to reap children, wait, but it
does not have a non-blocking option. This means that if
you inadvertently call it when there are running child
processes but none that have exited, your program will
pause until there is a dead child.
Because the kernel keeps track of undelivered signals
using a bit vector, one bit per signal, if two children
die before your process is scheduled, you will get only a
single SIGCHLD. This means you must always loop when you
reap in a SIGCHLD handler, and so can't use wait.
The capsule summary is that when two children can die "simultaneously",
your SIGCHLD handler is only called once. This means you *must* loop
in your SIGCHLD handler. wait() blocks, so you can use it. You then
must call waitpid() with WNOHANG so it won't block.
If you don't have WNOHANG, you're screwed. Fortunately, it's part of
the POSIX standard and most operating systems have it.
Nat
------------------------------
Date: 15 Jun 1998 17:32:58 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Handling of the ASCII behavior of ^M
Message-Id: <6m43ua$8a1$1@monet.op.net>
In article <qyln2bedd8j.fsf@gargantua.enst.fr>,
Akim Demaille <demaille@inf.enst.fr> wrote:
>Thanks, but it looks like the explanation were not detailed enough :)
>The point is also that the spaces must more erase what was previously
>printed (it is meant to simulate what a line printer does).
The code example you posted was quite clear. Sorry that I wasn't
paying enough attention to get it right.
I think this version does what you want.
It's even shorter, and a lot funnier.
while (<>) {
chomp;
my @sublines = split /\cM/;
$line = shift @sublines;
foreach $sline (@sublines) {
my $mask = $sline;
$mask =~ tr/\x00 /\xff\x00/;
$mask =~ tr/\x00/\xff/c;
$mask .= ("\x00" x (length($line) - length($mask)))
if length($mask) < length($line);
$line = ($line & ~$mask) | ($sline & $mask); # :)
}
print $line, "\n";
}
------------------------------
Date: Mon, 15 Jun 1998 22:30:49 GMT
From: 6xtippet@CyberJunkie.com
Subject: Re: HELP WITH SOME NEWBIE HACKED CODE???
Message-Id: <3585a00a.892988669@news.usaor.net>
On Tue, 16 Jun 1998 01:53:30 +1000, Stephan Carydakis
<steph@hotkey.net.au> wrote:
>Hi All,
>
>I have a quaestion about the following code:
> if ($stat_bar > ($FORM{'montot'} / $how_much)) {
> print "* ";
> $stat_bar=0;
> }
>My problem is with the last 'if' statement. What I think should happen
>is every time the condition is met(10 times all up), the script spews
>out '* ' to STDOUT.
>
>What actually happens is it spews out 10 '* ' all at once, and not 1 at
>a time as I would expect. Can someone tell me why this is so?
Because i/o is buffered by default. To force a flush the buffers on
every print assign a nonzero value to $|.
Hope this helps
Lee
------------------------------
Date: 15 Jun 1998 17:49:03 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: how do I save a perl file
Message-Id: <ysilnqyi8m8.fsf@blkbox.com>
hhaque@aol.com (HHaque) writes:
> I access a unix account by telnet. I need to know how I can write and save a
> script file. I am new to unix.
Run, don't walk, to your nearest bookstore and purchase (or order) UNIX in a
Nutshell. Read it. Learn it. Live it.
Kent
------------------------------
Date: 15 Jun 1998 20:41:23 GMT
From: "Andy Sain" <lsain@vnet.net>
Subject: I need a simple scrip that...
Message-Id: <01bd98b7$2bf11960$ca7852a6@immortal>
I need a simple script that will track my .html pages and tell me what
traffic each are getting...and free woudl be nice:-)
Thanks...please send replies to groups as well as lsain@vnet.net or ICQ me
at 650225
THanks,
ANdrew
--
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Andrew Sain <mailto:lsain@vnet.net> ICQ 650225
Web Hosting & Design <http://www.net-matrix.com/>
GraphX Kingdom <http://www.net-matrix.com/graphx/>
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Mon, 15 Jun 1998 16:05:21 -0500
From: "Vincent M. Probasco" <probavm@h8mail.laf.cat.com>
Subject: Re: I need a simple scrip that...
Message-Id: <35858C91.9E6326A5@h8mail.laf.cat.com>
Prepare to be flamed !
------------------------------
Date: Mon, 15 Jun 1998 21:07:02 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: I need a simple scrip that...
Message-Id: <6m42gu$htu$5@ligarius.ultra.net>
[ posted and mailed ]
"Andy Sain" <lsain@vnet.net> wrote:
-> I need a simple script that will track my .html pages and tell me what
-> traffic each are getting...and free woudl be nice:-)
How much of it have you got written so far and where are you having a problem?
Please post the snippet of your script that the problems are occuring.
c.l.p.m is not Wal-mart.
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
and hang up when the recording starts. "
------------------------------
Date: Mon, 15 Jun 1998 22:08:59 GMT
From: letranger@my-dejanews.com
Subject: Keeping the global value of a local variable.
Message-Id: <6m461r$okf$1@nnrp1.dejanews.com>
Okay, I've looked through all of the perl docs, but I'm still a little
confused about the order of evaluation of operands of an assignment operator
when used with local(). Specifically, will this do what I want it to:
local $foo = $foo;
(That is, localize $foo and initialize it to contain the value of the global
$foo.) Does it make a difference how I parenthesize things, or whether I'm
using local on a list rather than a scalar? I.e. will all of these be
equivalent:
(local $foo) = $foo;
local($foo) = $foo;
and will this work:
local ($foo, $bar) = ($foo, $bar);
And just for future reference, does my() work the same way? Are there any
strange perl "traps for the unwary" I should be aware of when doing this sort
of thing?
(For now, I've been doing this, just to be safe:
my $temp = $foo;
local $foo = $temp;
But that seems like a rather inelegant way of doing things.)
Any clarification on these issues would be much appreciated! Thanks.
-jason
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 15 Jun 1998 22:16:05 GMT
From: jlamport@calarts.edu
Subject: Keeping the global value of a local variable.
Message-Id: <6m46f7$pgq$1@nnrp1.dejanews.com>
Okay, I've looked through all of the perl docs, but I'm still a little
confused about the order of evaluation of operands of an assignment operator
when used with local(). Specifically, will this do what I want it to:
local $foo = $foo;
(That is, localize $foo and initialize it to contain the value of the global
$foo.) Does it make a difference how I parenthesize things, or whether I'm
using local on a list rather than a scalar? I.e. will all of these be
equivalent:
(local $foo) = $foo;
local($foo) = $foo;
and will this work:
local ($foo, $bar) = ($foo, $bar);
And just for future reference, does my() work the same way? Are there any
strange perl "traps for the unwary" I should be aware of when doing this sort
of thing?
(For now, I've been doing this, just to be safe:
my $temp = $foo;
local $foo = $temp;
But that seems like a rather inelegant way of doing things.)
Any clarification on these issues would be much appreciated! Thanks.
-jason
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 15 Jun 1998 22:36:10 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Keeping the global value of a local variable.
Message-Id: <pudge-1506981833260001@dynamic404.ply.adelphia.net>
In article <6m46f7$pgq$1@nnrp1.dejanews.com>, jlamport@calarts.edu wrote:
# Okay, I've looked through all of the perl docs, but I'm still a little
# confused about the order of evaluation of operands of an assignment operator
# when used with local(). Specifically, will this do what I want it to:
#
# local $foo = $foo;
#
# (That is, localize $foo and initialize it to contain the value of the global
# $foo.) Does it make a difference how I parenthesize things, or whether I'm
# using local on a list rather than a scalar? I.e. will all of these be
# equivalent:
#
# (local $foo) = $foo;
# local($foo) = $foo;
#
# and will this work:
#
# local ($foo, $bar) = ($foo, $bar);
Do that. Yes. Of course, you could just experiment and find out, right?
Don't do:
(local $foo, $bar) = ($foo, $bar);
Only $foo is local()ized.
(local $a, my $b, local($c, $d)) = ($a, $b, $c, $d);
# And just for future reference, does my() work the same way? Are there any
Yes.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 15 Jun 1998 13:53:22 -0400
From: plussier@baynetworks.com (Paul L. Lussier)
Subject: MIME-tools and MailTools modules confusion
Message-Id: <h67btrublgt.fsf@baynetworks.com>
Hi all,
I was scanning through the MIME-tools and MailTools documentation and
noticed that both sets of docs stated that many of the Mail:: modules
are now superclasses of the MIME:: modules.
Does this mean I can get away with just using the Mail:: modules for dealing
with MIME attachments?
All I'm looking to do is read an e-mail in, determine whether or not
it has any MIME attachments, and if so, separate the pieces storing them
as the appropriate file types.
It appears that to do this, I would want to use the MIME::Parser module. Is
this correct?
Thanks,
--
Seeya,
Paul
------------------------------
Date: 15 Jun 1998 23:21:52 +0200
From: Ask Bjoern Hansen <ask@netcetera.dk>
Subject: Re: mod_perl newsgroup?
Message-Id: <m3ium2cqdr.fsf@balder.netcetera.dk>
Kevin Miles <kmiles@erols.com> writes:
> Sorry for the mispost, but which newsgroup is most appropriate for
> mod_perl questions?
The mailinglist will be the best place,
<URL:http://perl.apache.org/#more> will tell you how to subscribe.
ask
------------------------------
Date: Mon, 15 Jun 1998 22:03:10 GMT
From: garyg@gator.net (Gary M. Greenberg)
Subject: Re: Need a jumpstart with creating csv
Message-Id: <MPG.fef63503b5e9015989684@news.gator.net>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <35849c48.40570517@nntp.ix.netcom.com>, ringuetb@ix.netcom.com
says...
> I'd like to take the contents of a text file and write it to a
> comma-delimited file. Don't know where to begin.
> Appreciate any help.
> Pls post to this newsgroup or e-mail to barry.ringuet@piog.com
> Thanks,
> Barry Ringuet
>
Do you want:
(1) each letter separated by a comma?
(2) each sentence separated by a comma?
(3) each paragraph separated by a comma?
(4) each word separated by a comma?
(5) something else?
Notice that c.l.p.m. is overrun with posts that are less than clear
and lack enough information for a responder to provide assistance.
You should probably buy the Camel, Llama, or both, read them and
then you will quickly be able to do all that you desire with Perl.
hope that's useful. Cheers, g.
Cheers, Gary
------------------------------
Date: 15 Jun 1998 14:48:24 -0700
From: weber@sipi.usc.edu (Allan G. Weber)
Subject: Need printer interface script in Perl for Solaris 2
Message-Id: <6m44r8$m48$1@sipi.usc.edu>
Has anybody ever written a Unix printer interface script in Perl? On Solaris 2
they normally go in /etc/lp/interfaces and are written in sh. The spooler
starts them up with a various arguments and they are supposed to send the print
data to the printer along with any control commands.
I recently installed the "netatalk" package for doing Appletalk networking on
Solaris in order to send files to Appletalk printers. The package came with
SunOS 4 (printcap, lpd, etc.) printing all set up but nothing for the spooling
system used on Solaris 2 systems.
I wrote a very simple Perl script for doing the interface function and the
spooler seems happy with it. I can do lp commands and pages pop out of the
printer. However I left out most of the error catching, trapping, and other
stuff. I have a feeling this script will fail the first time somebody tries to
cancel a job, or the printer dies, etc.
If somebody has done a more complete implementation of an interface script I'd
like very much to get a copy. Alternatively, if somebody knows a good reason
why Perl shouldn't be used for this sort of task, I'd like to hear it.
Thanks in advance
Allan Weber
Univ. of Southern California
Signal and Image Processing Institute
weber@sipi.usc.edu
------------------------------
Date: Mon, 15 Jun 1998 16:24:56 -0500
From: Thomas Resing <tresing@globalscape.net>
Subject: Re: Perl5 and the X11 libraries.
Message-Id: <35859127.E637A40C@globalscape.net>
Thomas Resing wrote:
> I have a question regarding security and Perl.
> For security reasons, the X11 libraries are restricted from normal users
> of our linux server. <snip>
Whoops, I assumed the server was running linux, it is actually running
BSDI 2.1
I should also point out I am not administrating this server but, I have
been asked to research the connection between Perl and X11.
Thanks again,
Tom
--
...........................................................
Tom Resing Programmer/Analyst
GlobalSCAPE www.globalscape.net
...........................................................
------------------------------
Date: 15 Jun 1998 22:06:01 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Perl5 and the X11 libraries.
Message-Id: <6m45s9$3na$1@ns1.arlut.utexas.edu>
Thomas Resing <tresing@globalscape.net> writes:
>
> For security reasons, the X11 libraries are restricted from normal
> users of our linux server.
Security reasons? What security reasons? Did one of your users use
/usr/X11R6/lib/libX11_s.2.1.0 to hold up a bank?
Splain, please.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: Mon, 15 Jun 1998 21:14:22 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <pudge-1506981711380001@dynamic404.ply.adelphia.net>
In article <6m3u7o$42l$1@marina.cinenet.net>, cberry@cinenet.net (Craig
Berry) wrote:
# On the array vs. list question: Would it be accurate to say that an array
# is an lvalue (in the C parser sense), a list an rvalue, and that the usual
# lvalue -> rvalue transformation is available?
#
# Forgive me if this analogy is woefully misguided, or if it already appears
# in the docs somewhere -- I couldn't find it, if the latter.
No, a list can be an lvalue, and an array can be an rvalue.
($a, $b, $c) = @a;
@a = some_list();
$a = @a;
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 15 Jun 1998 21:49:40 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6m44tk$42l$3@marina.cinenet.net>
Chris Nandor (pudge@pobox.com) wrote:
: In article <6m3u7o$42l$1@marina.cinenet.net>, cberry@cinenet.net (Craig
: Berry) wrote:
:
: # On the array vs. list question: Would it be accurate to say that an array
: # is an lvalue (in the C parser sense), a list an rvalue, and that the usual
: # lvalue -> rvalue transformation is available?
:
: No, a list can be an lvalue, and an array can be an rvalue.
:
: ($a, $b, $c) = @a;
Isn't that really the *elements of a list* being lvalues? To me, this is
analogous with the C code
int a[3];
a[0] = 1;
/* and so forth */
The array a is an rvalue; a[0], an element of a, is an lvalue.
: @a = some_list();
: $a = @a;
Silent conversion from lvalue to rvalue as needed is explicitly part of
the analogy I'm suggesting; only rvalue->lvalue conversion is forbidden
in the absence of operators which accomplish this transformation.
---------------------------------------------------------------------
| 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: Mon, 15 Jun 1998 22:30:24 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <pudge-1506981827400001@dynamic404.ply.adelphia.net>
In article <6m44tk$42l$3@marina.cinenet.net>, cberry@cinenet.net (Craig
Berry) wrote:
# : No, a list can be an lvalue, and an array can be an rvalue.
# :
# : ($a, $b, $c) = @a;
#
# Isn't that really the *elements of a list* being lvalues?
Not really. You are assigning to a list. Hence the term "list context".
The caller is a list.
($a, $b) = some_sub(); $c = some_sub();
print $a, $b, $c;
sub some_sub { wantarray ? (1, 2) : 3}
Of course, this just brings up the unfortunate, and incorrect, name of the
wantarray() function. But c'est la vie.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 15 Jun 1998 20:51:50 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: strange error message .. "value of <handle> ..."
Message-Id: <6m41h6$kbt@mozo.cc.purdue.edu>
tadmc@flash.net (Tad McClellan) writes:
}Allan M. Due (due@murray.fordham.edu) wrote:
}: In article <byronj-1506981301410001@t-man.nd.edu.au>, Byron Jones
}: (byronj@nd.edu.au) posted...
}: |(please cc any replies to my email address as i don't check this group
}: |frequently)
}: Folks in this newsgroup often find such requests annoying.
} ^^^^^^^^^^^^^^
}It is not specific to this newsgroup.
I've experienced times when my news service was pretty flaky, and I
would have a pretty good chance of missing responses through no fault
of my own, so I feel for these people. But on the other hand, I
almost always forget to send the mail.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Mon, 15 Jun 1998 16:58:58 -0400
From: Jack Chastain <jack.chastain@attws.com>
To: Dan Peterson <pete@spry.com>
Subject: Re: Unpacking hex string into array
Message-Id: <35858B12.C824C3BA@attws.com>
I have recently had some fun working with binary strings in hex format. I
believe you are missing the problem.
A string which contains the characters '0000016500000002' contains a total
of 32 Hex characters - not 16 as your code indicates ('H8 H8'). The
characters stored (you can see this by adding the line print "@data\n"; to
your example) will be 30303030 30313635. This is correct, as a zero is "30"
in hex representation - two hexadecimal values.
If you want to read the hex representation of an 8-character string (a
REALLY poor way to store data!), then you should probably read the data as
A8, then do something like this:
@data = unpack("A8", $str);
print hex @data[0] . "\n";
for the first value ('0000165'), this returns 357, which is the decimal
value of the hex 165. If, on the other hand, 165 is the decimal value for
which you want the hex (A5) value, then you may have to use sprintf as
documented in teh camel book under the description of 'hex'.
Finally, one thing that should have been immediately obvious, but missed my
attention, was in using H4 - for some reason, I expected H4 to read 4 bits,
then another H4 to read another four. Silly me - the computer cannot discern
less than a single byte, so I obviously moved on to the next byte and
grabbed the first four bits there!
The key to remember: H (and h) read BITS - not desired characters. Using od
is sometimes helpful, though I use a file editor to help me along.
Best of luck.
Jack Chastain.
Dan Peterson wrote:
> 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: 15 Jun 1998 22:12:17 GMT
From: hivnor@shore.net (Todd Hivnor)
Subject: Use of DBD::Oracle from cron
Message-Id: <6m4681$7af@fridge.shore.net>
I'm using perl 5.004_04 with DBI 0.93, DBD:Oracle 0.48,
and Oracle 7.3 on Solaris 2.5.
I have a script which works from the command
line, but which doesn't work from cron. The script
tries to use DBD::Oracle. It generates the
following error:
Can't load '/usr/local/perl/lib/site_perl/
sun4-solaris/auto/DBD/Oracle/Oracle.so'
for module DBD::Oracle: ld.so.1:
/usr/local/perl/bin/perl: fatal: libsunmath.so.1:
can't open file: errno=2 at /usr/local/perl/lib/sun4-solaris/5.00404/
DynaLoader.pm line 166.
I have set $ENV{LD_LIBRARY_PATH} to include oracle/lib.
I have also tried setting a zillion other environment variables,
to try and re-create my non-cron environment. But I haven't
been able to figure out what is different in my command line
environment versus my cron environment. My cron environment
is able to autoload other .so files, like Socket.so , DBI.so
and Dumper.so.
What else changes in a cron environment? There must be other
changes besides just environment variables, right?
Any clues?
Todd Hivnor
hivnor at shore dot net
------------------------------
Date: Mon, 15 Jun 1998 20:53:43 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Windows NT, how to copy binary files !
Message-Id: <6m41nv$htu$3@ligarius.ultra.net>
[ posted and mailed ]
JahanJ@yahoo.com (Jahan K. Jamshidi) wrote:
-> I know how to read a ascii file using perl and write it out somewhere else.
-> I
-> have problem reading a binary file and write out to a new location (kind of
-> like copying the an executable program to a new locaiton). Does perl support
->
-> this function? Any help is greatly appriciated.
perldoc -f binmode
HTH
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
and hang up when the recording starts. "
------------------------------
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 2878
**************************************