[16427] in Perl-Users-Digest
Perl-Users Digest, Issue: 3839 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 28 21:10:26 2000
Date: Fri, 28 Jul 2000 18:10:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964833015-v9-i3839@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 28 Jul 2000 Volume: 9 Number: 3839
Today's topics:
Re: plotting graph (Gwyn Judd)
Re: Reference question (was Callback in SNMP module) (Mark W. Schumann)
Re: return value of `eval "use lib"' <sumus@aut.dk>
Re: return value of `eval "use lib"' <sumus@aut.dk>
Re: Script for copy all the site <gellyfish@gellyfish.com>
Re: Should truncate length be 0? (Larry R) (BUCK NAKED1)
Re: Should truncate length be 0? (Larry R) <lr@hpl.hp.com>
Re: Should truncate length be 0? (BUCK NAKED1)
Re: Should truncate length be 0? <hayati@math.berkeley.edu>
Re: strict and subroutine variables <bart.lateur@skynet.be>
Re: Suggestion for syntax change <iltzu@sci.invalid>
Re: taking subroutine name as a parameter <bart.lateur@skynet.be>
Re: taking subroutine name as a parameter <eyalb@aks.com>
Re: test <gellyfish@gellyfish.com>
Re: Wraping file with XML code (Mark W. Schumann)
Re: Writing HTML within Perl (BUCK NAKED1)
Re: WWWBoard.PL (Steve Leibel)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 29 Jul 2000 00:38:07 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: plotting graph
Message-Id: <slrn8o49rd.4k9.tjla@thislove.dyndns.org>
I was shocked! How could Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
say such a terrible thing:
>I was shocked! How could Abigail <abigail@foad.org>
>say such a terrible thing:
>>print v74.117.115.116.32;
>>print v97.110.111.116.104.101.114.32;
>>print v80.101.114.108.32;
>>print v72.97.99.107.101.114.10;
>
>What is this thing? I have no idea where in the documentation it would
>be and I've never seen anything like it. Anyone?
Whoops ignore this question, I got it (find rock, bang head)
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Bureaucrat, n.:
A politician who has tenure.
------------------------------
Date: 28 Jul 2000 18:47:24 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Reference question (was Callback in SNMP module)
Message-Id: <8lt2hs$amn@junior.apk.net>
In article <8ls54r$6ia$1@dipsy.missouri.edu>,
Justin McNutt <mcnuttj@nin.iats.missouri.edu> wrote:
>Got another question w.r.t. refs that has sprung from the shorter
>syntax I learned from the aforementioned thread.
>
>When I do this:
>
>#use strict;
>use SNMP;
>...
>print "Received error $sess->{ErrorStr} querying ",$vb->[tag],".",$vb->[iid],".\n";
>
>I get:
>
>Unquoted string "tag" may clash with future reserved word at [blah].pm line 34.
>Unquoted string "iid" may clash with future reserved word at [blah].pm line 34.
Didn't you mean $tag and $iid?
>If I uncomment 'use strict;' it won't compile at all.
Indeed.
>In other modules where I have used such variables, I have always done:
>
>$vb->[$SNMP::Varbind::tag_f]
Right, with a dollar sign as part of the name of the scalar.
>or circumvented the entire problem like this:
>
>$var = $sess->getnext($vb); # $var = $vb->[val_f] after this.
You sure about that? val_f without any punctuation prefix?
>Ideas?
See above.
>My thanks for the help I have gotten so far. I feel I'm close to fully
>grasping refs in perl (I created my first sub that uses "\%thishash" correctly
>today! Woo hoo!) and your advice has helped significantly.
You seem to be on the right track, but I wonder whether you totally
understand Perl variable naming yet. Or perhaps I've missed something
myself.
Does this help?
------------------------------
Date: 29 Jul 2000 00:14:12 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: return value of `eval "use lib"'
Message-Id: <66ppewcr.fsf@macforce.sumus.dk>
sweth+perl@gwu.edu (Sweth Chandramouli) writes:
> In article <8zunupl4.fsf@macforce.sumus.dk>,
> Jakob Schmidt <sumus@aut.dk> wrote:
> >In that case
> >
> >eval "use lib LIST"; @_ and die @_;
I know I said @_
> Although I don't think it is functionally any different than
> the test of @_
I meant $@ of course. Sorry.
--
Jakob
------------------------------
Date: 29 Jul 2000 00:24:34 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: return value of `eval "use lib"'
Message-Id: <4s59evvh.fsf@macforce.sumus.dk>
Bart Lateur <bart.lateur@skynet.be> writes:
> Can you give an example of where use dies, and
> require+import ignores the error?
I thought I had one with
use lib qw( nonexistantdir );
and
require lib; import lib qw( nonexistantdir );
but now I just can't make use lib LIST die. I thought it used to die when
you asked to include a directory which doesn't exist. But it doesn't.
I'm a little confused.
Unless this is abnormal behavour at my site there's really no way of testing
for success. eval "use lib LIST"; $@ and die $@; will never die if the
eval'ed use never dies and the Cookbook Patch posted by Sweth won't either...
If that's the case it would leave testing for exixtence of the dirs specified
in LIST as the only solution.
--
Jakob
------------------------------
Date: 27 Jul 2000 21:52:56 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Script for copy all the site
Message-Id: <8lq7f8$r2m$1@orpheus.gellyfish.com>
On Wed, 26 Jul 2000 14:36:32 -0500 Pablo Lambert wrote:
> Hello:
> I am searching for a tool that allows me copy some remote site
> via http, to my local filesystem. I have already downloaded
> CPAN/sitemapper, but this tool only make a map of the site.
>
> I have also try MasterSnooper.pl but does not work recursively. It works
> only with one page and does not follow the links.
>
> I think that the perl community is so smart that this litte tools must
> be done!
>
mirror, wget blah balh hsjs ... none of them Perl. If you want to achieve
this in Perl you will want to read the documentation for libwww-perl that
can be obtained from CPAN.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Fri, 28 Jul 2000 17:09:06 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Should truncate length be 0? (Larry R)
Message-Id: <665-39820482-93@storefull-246.iap.bryant.webtv.net>
Larry, I just corrected the regex per your suggestion below... and now
my file won't compile. Did you make an error?
for($num) {s/(1[123]|[4-90])$/$1th/ =A0 or
=A0=A0s/1$/1st/ or s/2$/2nd/ =A0 =A0 or
=A0=A0=A0=A0s/3$/3rd/};
close COUNT or warn $!;
Thanks,
Dennis
------------------------------
Date: Fri, 28 Jul 2000 16:57:11 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Should truncate length be 0? (Larry R)
Message-Id: <MPG.13ebbdb719e3098e98ac08@nntp.hpl.hp.com>
In article <665-39820482-93@storefull-246.iap.bryant.webtv.net> on Fri,
28 Jul 2000 17:09:06 -0500 (CDT), BUCK NAKED1 <dennis100@webtv.net>
says...
> Larry, I just corrected the regex per your suggestion below... and now
> my file won't compile. Did you make an error?
>
> for($num) {s/(1[123]|[4-90])$/$1th/ =A0 or
> =A0=A0s/1$/1st/ or s/2$/2nd/ =A0 =A0 or
> =A0=A0=A0=A0s/3$/3rd/};
> close COUNT or warn $!;
Did you look at what you just posted? Obviously there are transmission
artifacts in there that look like =A0. Tabs translated? I dunno. I
just copied and edited your posting. But take the critters out and all
will be well.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 28 Jul 2000 16:56:30 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Should truncate length be 0?
Message-Id: <665-3982018E-91@storefull-246.iap.bryant.webtv.net>
Thanks abunch, Larry and Bart! I appreciate it. --Dennis
------------------------------
Date: Sat, 29 Jul 2000 00:48:23 GMT
From: Katia Hayati <hayati@math.berkeley.edu>
Subject: Re: Should truncate length be 0?
Message-Id: <8lt9km$dra$1@nnrp1.deja.com>
In article <m3l2oskqu9qqpc7dqru1ervfflu2c383b3@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> wrote:
> However, This sequence:
>
> seek FILE, 0, 0;
> print FILE, $data;
> truncate FILE, tell FILE;
>
> *has already failed* on me, on a fews platforms. IT truncated the file
> to the wrong length, even though I think that tell() returned the
> correct offset.
Does that mean that truncate() can be trusted to work only with a 2nd
argument of 0?
Thanks,
Katia Hayati
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 28 Jul 2000 22:53:06 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: strict and subroutine variables
Message-Id: <be34os8k0l5e16oohg09gqlo32uflppi05@4ax.com>
Pasquale wrote:
>Let me re-word the question. How do I get the value of a declared variable in
>one subroutine passed to another subroutine?
Either return it in the first sub, after which you can pass the value as
a parameter to the second sub, or don't limit the scope to the first
sub. For example:
{
my $common;
sub one {
$common = shift;
}
sub two {
return $common;
}
}
one(42);
print two();
--
Bart.
------------------------------
Date: 29 Jul 2000 00:17:52 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Suggestion for syntax change
Message-Id: <964829165.16562@itz.pp.sci.fi>
In article <3981F30A.4F430E8B@mindspring.com>, Keith G. Murphy wrote:
>jason wrote:
>> allow parenthesis to increase the negative index evaluation order .. ie.
>> old behaviour remains
>> (LIST)[0..-2]
>> creates an empty list
>> (LIST)[0..(-2)]
>> for a 5 element list creates
>> (LIST)[0..3]
>
>Hmmm, it's probably Ilmari's turn to point out problems with that as
>well. How would you keep (-2) somewhere else in the '[]' from turning
>magical?
The only objection I can think of here is that Perl already has IMHO
way too many "magic parens". To me that's reason enough to avoid it,
but if someone disagrees I can't really argue with that.
A special variable wouldn't require remembering any new syntax.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Fri, 28 Jul 2000 22:58:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: taking subroutine name as a parameter
Message-Id: <br34oso929ff37pge24grqan9rm1e9mnnp@4ax.com>
Andrew J. Perrin wrote:
>Instead, use a real reference:
>
>sub hi {
> print "Hello, world\n";
>}
>
>my $hisub = \&hi;
>
>&$hisub;
Or, with limitations, for safety reasons:
sub f1 { print "I am f1\n"; }
sub f2 { print "Ego sum f2\n"; }
%dispatch = ( f1 => \&f1, f2 => \&f2 );
for my $x ('f1', 'f2', 'f3') {
($dispatch{$x} || sub { die "dispatch error!"})->();
}
--
Bart.
------------------------------
Date: 29 Jul 2000 02:50:02 +0300
From: Eyal Ben-David <eyalb@aks.com>
Subject: Re: taking subroutine name as a parameter
Message-Id: <m24s596cid.fsf@localhost.localdomain>
Bart Lateur <bart.lateur@skynet.be> writes:
> Andrew J. Perrin wrote:
>
> >Instead, use a real reference:
> >
> >sub hi {
> > print "Hello, world\n";
> >}
> >
> >my $hisub = \&hi;
> >
> >&$hisub;
>
> Or, with limitations, for safety reasons:
>
> sub f1 { print "I am f1\n"; }
> sub f2 { print "Ego sum f2\n"; }
>
> %dispatch = ( f1 => \&f1, f2 => \&f2 );
>
> for my $x ('f1', 'f2', 'f3') {
> ($dispatch{$x} || sub { die "dispatch error!"})->();
> }
>
> --
> Bart.
Why maintain a dispatch table when Perl already has one?
Here is an example:
use strict;
sub f1 { print "I am f1: @_\n"; }
sub f2 { print "Ego sum f2: @_\n"; }
sub call_sub_by_name {
my $name = shift;
no strict 'refs';
&{"$name"}(@_);
}
call_sub_by_name("f1", 1, 2, 3, 4);
call_sub_by_name("f2", 5, 6, 7, 8);
You can call directly without the wrapper subroutine call_sub_by_name()
but then you will have to put no strict 'refs' globally.
no strict 'refs';
${'f1'}(1,2,3,4);
${'f2'}(5,6,7,8);
Eyal.
------------------------------
Date: 27 Jul 2000 21:58:57 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: test
Message-Id: <8lq7qh$r34$1@orpheus.gellyfish.com>
On Tue, 25 Jul 2000 12:08:49 +0800 wang yin wrote:
>
>
Do not do 'test' posts to this (or indeed any other) group - this is
what misc.test, alt.test, uk.test and the like are for - please read
the helpful messages in news.announce.newusers for more information
on this.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 28 Jul 2000 18:45:04 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Wraping file with XML code
Message-Id: <8lt2dg$a2j@junior.apk.net>
In article <39819FC8.CC279424@eurodyn.com>,
Sasa Danicic <Sasa.Danicic@eurodyn.com> wrote:
>I've need to wrap a binary file with a portion of XML-like code.
>XML-like code is something so called "an envelope".
Why? To send through email? For printing? To stuff into a
Storable object?
>How can I wrap a binary file with an envelope, in fact how can I read
>the file first and at last add some XML-ish string at the beggining of
>the file?
By your other posts here (unless I'm confusing you with someone else)
you seem to know enough Perl to do this. I must not be understanding
the question. But if this is what you really mean, here's an idea:
use constant BLOCKSIZE => 4096;
sub wrap_file ($$)
{
my $source_file = shift;
my $dest_file = shift;
open (SOURCE, "<$source_file") || die "can't open source file \"$source_file\": $!";
open (DEST, ">$dest_file") || die "can't open destination file \"$dest_file\": $!";
print DEST $xml_like_header;
# error checking elided:
my $buffer = ' ' x BLOCKSIZE;
while sysread (SOURCE, BLOCKSIZE, $buffer)
{
syswrite (DEST, $bytes, $buffer);
}
close SOURCE;
close DEST;
0;
}
This isn't what you mean, is it?
------------------------------
Date: Fri, 28 Jul 2000 17:14:11 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Writing HTML within Perl
Message-Id: <667-398205B3-27@storefull-246.iap.bryant.webtv.net>
Sorry, I meant to make the above post a new thread. Will do.
Regards,
--Dennis
------------------------------
Date: Fri, 28 Jul 2000 15:09:37 -0700
From: stevel@bluetuna.com (Steve Leibel)
Subject: Re: WWWBoard.PL
Message-Id: <stevel-2807001518180001@192.168.100.2>
In article <8lrbs4$i37$1@localhost.localdomain>, neil@brevity.org (Neil
Kandalgaonkar) wrote:
> It's a CGI script, and requires a Perl interpreter and a properly configured
> http server. It runs on Windows.
>
> Oh, and by the way, it is among the worst code I have ever seen. Someone
> recently asked about how bad Matt's scripts were and I was tempted to
> include a dissection of wwwboard.pl.
>
Since wwwboard.pl gets trashed regularly in this newsgroup, I thought I'd
share some thoughts about it based on personal experience.
A noncommercial site I've been associated with for a long time has been
using wwwboard.pl for over three years. The message board has been very
successful, with over 200,000 messages to date; a large community of
people who have met in person and become lifelong friends; and a huge
lurker population generating a million page views per month. For a
text-only noncommercial site this is very impressive.
I'm not writing to defend the wwwboard.pl code. We've spent lots of time
beefing it up, adding concurrency control, better error handling, password
protection, numerous bug fixes, and so on.
Regardless of the technical merit of wwwboard.pl, it has helped us build a
huge online community. Sometimes we forget what code is for -- to provide
benefit to people. A simple scripts like wwwboard.pl that is out there
adding genuine value to the world is a good thing. Ultimately it's why
programmers program: to use our talent and energy in the service of
others.
Most production code is neither as pretty nor as correct as we would
wish. But as a small, free script that has brought utility and happiness
to literally hundreds of thousands of real people, wwwboard.pl is one of
the finest examples of the programmers art. It runs and it's useful.
That's no small accomplishment in this business.
Steve L
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3839
**************************************