[12190] in Perl-Users-Digest
Perl-Users Digest, Issue: 5790 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 26 14:07:27 1999
Date: Wed, 26 May 99 11:00:25 -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, 26 May 1999 Volume: 8 Number: 5790
Today's topics:
Re: "cat"-ing three files into three files. nilrame@my-deja.com
ANNOUNCE: New Perl documentation available <tchrist@mox.perl.com>
Re: Better solution ? nilrame@my-deja.com
Re: can't write to text-file from web form <bhaskart@my-deja.com>
Re: DBM File will not open after Redhat 6.0 upgrade <bruce@flair.law.ubc.ca>
Error with HTTP::Message kawaru@my-dejanews.com
Re: FAQ 3.4: How do I debug my Perl programs? <cassell@mail.cor.epa.gov>
Re: FAQ 3.7: Is there a pretty-printer (formatter) for <bill@fccj.org>
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe <bill@fccj.org>
Re: FileHandle problems (Andrew Allen)
Re: Get spaces off. (Larry Rosler)
Re: Help needed! (Larry Rosler)
Re: Help needed! <jdporter@min.net>
Re: Help needed! (Tony Greenwood)
Re: How do i add two values? <aqumsieh@matrox.com>
Re: In favor of extending "my" to apply to subroutines (Andrew Allen)
Re: leeches, compilers, and perl, oh my (all mine?) <gbartels@xli.com>
ModUtils: simple utilities for perl modules <hasant@trabas.co.id>
ModUtils: simple utilities for perl modules <hasant@trabas.co.id>
ModUtils: simple utilities for perl modules <hasant@trabas.co.id>
Re: need an anti-leech script (John Stanley)
Re: need an anti-leech script (John Stanley)
Re: newbi: UNIX to NT <cassell@mail.cor.epa.gov>
OO: Perl resources (Ryan Ngi)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 May 1999 17:43:26 GMT
From: nilrame@my-deja.com
Subject: Re: "cat"-ing three files into three files.
Message-Id: <7ihbru$3j5$1@nnrp1.deja.com>
In article <87pv3ypefu.fsf@camel.cpsgroup.com>,
Dale Henderson <dhenders@cpsgroup.com> wrote:
>
>
> I'm trying to concatenate three files into three identical output
> files.
>
> This is what I have so far:
>
> foreach $fname (@INFILES){
> open (INFILE,"+<$fname") || die "Can't open $fname: $!";
> flock(INFILE,$LOCK_EX ) || die "Can't lock $fname: $!";
> $file.=<INFILE>;
> truncate(INFILE,0);
> close (INFILE);
> }
> # A crash here will cause data loss :(
>
> foreach $fname (@OUTFILES){
> open (OUTFILE,">$fname") || die "Can't open $fname: $!";
> flock(OUTFILE,$LOCK_EX ) || die "Can't lock $fname: $!";
> print OUTFILE $file;
> close (OUTFILE);
> }
>
> The code above has several inperfections. For one it is prone to data
> loss. For another if the data are large, it will take up a large
> amount of memory.
>
> Any ideas on how I should improve this code?
>
>
I've modified the above code to look like this
foreach $fname(@FILES){
$fh{$fname}=new FileHandle("+<$fname");
unless ($fh{$fname}) {warn "Can't open $fname: $!";next}
flock($fh{$fname},$LOCK_EX ) || die "Can't lock $fname: $!";
$file.=<$fh{$fname}>;
}
foreach $fname (@FILES){
truncate($fh{$fname},0);
print $fh{$fname} $file;
close ($fh{$fname});
}
this new version will dump the data back into the original files. Which
is a nice feature. However, it still has some problems. There is still
potential for data loss. And it will still have problems with large
files. The only real improvement is the potential for data loss is less.
I would really appreciate some help on this.
(I'm really starting to miss Gnus)
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 26 May 1999 10:33:24 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: ANNOUNCE: New Perl documentation available
Message-Id: <374c2254@cs.colorado.edu>
If you don't want to go the whole _57 route, I've created
three tarballs. Each holds both pods and manified pods for
easy copying into your mandir1 (and for funcs, mandir3).
1 Everything from the src/perl/pod/ directory, plus manifications
and splitpoddage. Does not include module pods, though.
http://language.perl.com/newdocs/allpod.tar.gz (1.77M)
2 Just the faq pods, plus their manifications.
This is also in allpods.
http://language.perl.com/newdocs/faqpod.tar.gz (221K)
3 The result of running splitpod, plus manifications. This
goes in mandir3. This is also in allpods, but in an
obvious subdirectory.
http://language.perl.com/newdocs/funcpods.tar.gz (177K)
I still haven't updated roffitall yet.
--tom
--
"When the big wind blows, the tree falls down, but the reed just bends."
- Johnny Clegg and Savuka
------------------------------
Date: Wed, 26 May 1999 17:26:59 GMT
From: nilrame@my-deja.com
Subject: Re: Better solution ?
Message-Id: <7ihat0$2uu$1@nnrp1.deja.com>
In article <x790ai88sc.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "DH" == Dale Henderson <dhenders@cpsgroup.com> writes:
>
> >>>>> "tvn007" == tvn007 <tvn007@my-dejanews.com> writes:
> tvn007> Hi, Here is the problem:
>
> tvn007> To pad 2000 "X" to thousand of lines
>
> DH> how about:
>
> DH> while(<>){
> DH> s/^/"X"x2000/e if (1..2000);
> DH> print;
> DH> }
>
> i don't understand the original problem but your code can be improved
I read the problem as prepend 2000 "X"'s to the first 1000 lines of a
file. (I made a typo 1..2000 should be 1..1000)
>
> why do a s/// and the /e when just plain printing will do.
It was quick and dirty and what came to mind.
> perl -pe 'print "X" x 2000 if ( 1 .. 2000 )'
>
I never can remember those switches :)
> if the x expression is not constant folded then you could save it in a
> BEGIN and print the var:
>
> perl -pe 'BEGIN {$x = "X" x 2000} print $x if ( 1 .. 2000 )'
I thought of something like this (After I posted). However to do the
prepending (that my original does) you would need something like.
perl -pe 'BEGIN {$x = "X" x 2000} print $x$_ if ( 1 .. 1000 )'
(fixed the typo too)
>
> uri
>
> --
> Uri Guttman ----------------- SYStems ARCHitecture and Software
Engineering
> uri@sysarch.com --------------------------- Perl, Internet, UNIX
Consulting
> Have Perl, Will Travel -----------------------------
http://www.sysarch.com
> The Best Search Engine on the Net -------------
http://www.northernlight.com
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 26 May 1999 17:05:05 GMT
From: Bhaskar Thiagarajan <bhaskart@my-deja.com>
Subject: Re: can't write to text-file from web form
Message-Id: <7ih9jv$1pb$1@nnrp1.deja.com>
Thanks for making me do this...I got my test script to work...but since
I didn't have my original script and I started over, I can't seem to
remember what I did wrong. But I think it had to do with the way I
specified the filename. Using a variable and the single and double
quotes in the open command had something to do with it for sure! (I
guess the unix and Win32 versions have different rules on this)
Cheers
Bhaskar
In article <374B44F8.33367192@well.com>,
Greg McCann <gregm@well.com> wrote:
> Bhaskar Thiagarajan wrote:
> [snip]
> > To make things real simple...I changed my script to just open a file
and
> > write 'hello world' and close it...wouldn't work from the browser
but no
> > problems from the command line.
> [snip]
>
> I and others could guess at your problem, but posting your test script
(not from
> memory - copy and paste) will guarantee more accurate answers.
>
> Greg
>
> --
>
> ======================
> Gregory McCann
> http://www.calypteanna.com
>
> "Be kind, for everyone you meet is fighting a great battle." Saint
Philo of
> Alexandria
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 26 May 1999 09:39:01 -0700
From: Bruce Atherton <bruce@flair.law.ubc.ca>
Subject: Re: DBM File will not open after Redhat 6.0 upgrade
Message-Id: <374C23A5.90EBC81A@flair.law.ubc.ca>
I R A Aggie wrote:
>
> On Tue, 25 May 1999 18:48:44 -0700, Bruce Atherton <bruce@flair.law.ubc.ca>, in
> <374B52FC.6FCC44B0@flair.law.ubc.ca> wrote:
>
> + If I copy the old "database.db" over to "database", the dbmopen() call
> + fails.
>
> With what error? Perusing 'perldoc -f dbmopen', we see:
>
> You can control which DBM library you use by loading that library
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> before you call dbmopen():
>
> use DB_File;
> dbmopen(%NS_Hist, "$ENV{HOME}/.netscape/history.db")
> or die "Can't open netscape history file: $!";
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> James
Oddly, the message I am getting is "File exists". This is odd because I
don't get the message if I delete the file, let the script create the
file, and then run the script again. It doesn't mind the file existing
unless I try opening the old database.
I've tried both "use DB_File" and "use AnyDBM_File" to no avail. I've
tried specifying the .db extension in the dbmopen call and not. No
change.
I've even tried changing the mode parameter of dbmopen from 0666 to
undef. At least that resulted in a change. The dbmopen call still
failed, but $! wasn't set to anything.
The perl, which I assume was installed by Redhat 6.0, is 5.005_3.
Again, any help appreciated.
------------------------------
Date: Wed, 26 May 1999 16:55:05 GMT
From: kawaru@my-dejanews.com
Subject: Error with HTTP::Message
Message-Id: <7ih917$1ao$1@nnrp1.deja.com>
I'm trying to write a cgi script in perl that will
POST to another cgi program. When I try to create
a HTTP::Request as a POST operation in the format:
my $req = new HTTP::Request POST =>
'http://test.test.com/test.cgi',
[ page => 'test',
test1 => 'test',
test2 => 'test',
test3 => 'test'];
$req->authorization_basic('username',
'password');
I get the error:
Can't call method "clone" on unblessed reference
at C:\Perl\site\5.005\lib/HTTP/Message.pm line 50.
I can get GET requests to work without any
problem, it's just the POST ones that bomb. Any
suggestions would be greatly appreciated.
--
William Hurley
void@expulsion.org
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 26 May 1999 10:49:08 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Tom and Gnat <perlfaq-suggestions@perl.com>
Subject: Re: FAQ 3.4: How do I debug my Perl programs?
Message-Id: <374C3414.4024D3F3@mail.cor.epa.gov>
Tom Christiansen wrote:
> [snip of usual good stuff]
>
> Have you tried `use strict'? It prevents you from using symbolic
> references, makes you predeclare any subroutines that you call as
> bare words, and (probably most importantly) forces you to
> predeclare your variables with `my' or `use vars'.
If the problem is understanding the error messages, have
you considered trying 'use diagnostics;' also? It will
print out the relevant sections from the perldiag manpage
and give you more explanation of the possible cause(s)
of your errors.
> [more snippage...]
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 26 May 1999 10:41:54 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: FAQ 3.7: Is there a pretty-printer (formatter) for Perl?
Message-Id: <374c0802.0@usenet.fccj.cc.fl.us>
In article <374bec00@cs.colorado.edu>, Tom Christiansen
<perlfaq-suggestions@perl.com> wrote:
> (This excerpt from perlfaq3 - Programming Tools
> ($Revision: 1.38 $, $Date: 1999/05/23 16:08:30 $)
> part of the standard set of documentation included with every
> valid Perl distribution, like the one on your system.
> See also http://language.perl.com/newdocs/pod/perlfaq3.html
> if your negligent system adminstrator has been remiss in his duties.)
>
> Is there a pretty-printer (formatter) for Perl?
>
My wife has actually hand-painted mine.
I was very angry at first, but it does brighten the office a bit.
-Sneex- :]
______________________________________________________________________
Bill Jones Data Security Specialist http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to
our own... Your thoughts will adapt to service us...
...Resistance is futile...
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: Wed, 26 May 1999 10:43:37 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <374c086c.0@usenet.fccj.cc.fl.us>
In article <slrn7klkcn.mq8.sitaram@diac.com>, sitaram@diac.com (Sitaram
Chamarty) wrote:
> On Sun, 23 May 1999 04:34:13 GMT, finsol@ts.co.nz
> <finsol@ts.co.nz> wrote:
>>In article <374745c3@cs.colorado.edu>,
>> tchrist@mox.perl.com (Tom Christiansen) wrote:
>>technology? Come on, Perl is just another programming language - time
>>you got in touch with the real world.
>
<snip>
>
> Tom's tone may offend, but he almost always has a point.
Scary, huh?
-Sneex- :]
______________________________________________________________________
Bill Jones Data Security Specialist http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to
our own... Your thoughts will adapt to service us...
...Resistance is futile...
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: 26 May 1999 17:04:33 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: FileHandle problems
Message-Id: <7ih9j1$pbn$3@fcnews.fc.hp.com>
tertullian@my-dejanews.com wrote:
: Hithertofore I've stuck to DBI stuff but now I'm giving files a go
: and having problems.
: Documentation and camel book say ...
: if ($fh->open "< file") {
My documentation (perldoc Filehandle) says:
if ($fh->open("< file"))
: perl says ...
: String found where operator expected at sub009.cgi line 20,
: near "->open "< file"
My guess it the "operator expected" is a '('!
Andrew
------------------------------
Date: Wed, 26 May 1999 09:19:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Get spaces off.
Message-Id: <MPG.11b5bee9718bc32b989b00@nntp.hpl.hp.com>
In article <374c1813.1139538746@news.inet.it> on Wed, 26 May 1999
15:50:18 GMT, Andrea L. Spinelli <aspinelli@ismes.it> says...
> On Wed, 26 May 1999 08:23:58 GMT, paul@vdkamer.nl (PaulK) wrote:
>
> >$teststring= 'Hello this is a test string ';
> >How do get $teststring to be 'Hello this is a test string';
> $teststring =~ s/\s*$//;
Only if you like doing more work than necessary.
$teststring =~ s/\s+$//;
As it says in the FAQ.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 26 May 1999 08:55:57 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help needed!
Message-Id: <MPG.11b5b9544fbd7d10989aff@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <McU23.15700$me.7262697@WReNphoon4> on Wed, 26 May 1999
07:10:53 -0800, hannibal josh <hannibal59@hotmail.com> says...
> Can some friendly people help me to
> find what is problem with this script,it dont work,
> error-message is"Can't find string terminator "End_of_prog" anywhere before
> EOF at xx/xx/xx.cgi line xx.
> I am beginner with perl and cant find solution to problem.
perlfaq4: "Why don't my <<HERE documents work?"
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 26 May 1999 16:21:01 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Help needed!
Message-Id: <7ih71a$vpv$1@nnrp1.deja.com>
In article <McU23.15700$me.7262697@WReNphoon4>,
hannibal59@hotmail.com (hannibal josh) wrote:
> Can some friendly people help me to
> find what is problem with this script,it dont work,
> error-message is"Can't find string terminator "End_of_prog" anywhere
before
> EOF at xx/xx/xx.cgi line xx.
>...
> $command = <<'End_of_prog';
> $ping = `ping -s $host 64 1` ;
> End_of_prog
>...
The here document tag is matched literally, including any spaces
inside (or before) it. The easiest way to fix your problem, then,
is to remove any whitespace before End_of_prog at the end of the
here document:
$command = <<'End_of_prog';
$ping = `ping -s $host 64 1` ;
End_of_prog
Or, you could put those spaces into the tag:
$command = <<' End_of_prog';
$ping = `ping -s $host 64 1` ;
End_of_prog
Or you could read section 1.11 of The Perl Cookbook.
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 26 May 1999 16:51:36 GMT
From: webdesign@accrington-web.co.uk (Tony Greenwood)
Subject: Re: Help needed!
Message-Id: <37551131.12350748@news.freeserve.co.uk>
Hey! hannibal59@hotmail.com (hannibal josh)
>error-message is"Can't find string terminator "End_of_prog" anywhere before
>EOF at xx/xx/xx.cgi line xx.
> __EOF__
>
>
This is what it can't find.. press return and make sure theres nothing
else on the line. Just __EOF__ and absoloutly nothing else. I get the
problem and thats how I fix it.. it may help you or there may be other
reasons...
--
Tony Greenwood
webdesign@accrington-web.co.uk
PORTFOLIO:www.accrington-web.co.uk
------------------------------
Date: Wed, 26 May 1999 11:43:09 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: How do i add two values?
Message-Id: <x3yu2szygz6.fsf@tigre.matrox.com>
Poohba <poohba@io.com> writes:
> I am trying to add two values from the same field but on different arrays.
Hmmm... something like:
$sum = $ary1[$field_num] + $ary2[$field_num];
??
> I am not sure how many arrays there are. I am using a foreach loop and it
> skips to last entry and i want it to subtract the first field in the last
> entry from the first field in the next to last entry. How is this done?
Your foreach() loop looks to me exactly identical to a while()
loop. Of course, from here, all of your code look like a while() loop!
In fact, I can see a syntax error, but I won't tell you which line
it's in.
Perhaps if you made things a tiny little bit clearer by, let's say,
posting some code?
------------------------------
Date: 26 May 1999 16:39:39 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: In favor of extending "my" to apply to subroutines as well as variables
Message-Id: <7ih84b$pbn$2@fcnews.fc.hp.com>
Steven Elliott (elliotsl@mindspring.com) wrote:
: > The bad news is that it this is irrelevant to method calls.
: > A method call finds a subroutine by the name it holds in the
: > symbol table of its referent. If it's my(), it's not in the
: > symbol table. If it's not in the symbol table, it's not a method.
: It does not bother me that a subroutine declared as private using "my sub"
: (assuming it works roughly as I described in my previous post) would not be
: a true method in the sense that it would not be possible to invoke it using
: the referent. That:
: package SomePackage;
: require 5.006;
: ...
: my sub private_sub {
: ...
: $obj->private_sub();
: is not possible. Even if it were possible it it does not buy you anything
: since the package is known. The above, if it were possible, would be the
: same as
: private_sub($obj);
Not quite. I would rather write my classes allowing somebody to
override any of my methods, even the private ones (although I strongly
object to people overriding my private methods in the real world :) I
don't know _why_, but that's the point of (allowing) subclassing-- you
never know how clever the next guy is.
Andrew
------------------------------
Date: Wed, 26 May 1999 12:40:10 -0400
From: Greg Bartels <gbartels@xli.com>
Subject: Re: leeches, compilers, and perl, oh my (all mine?)
Message-Id: <374C23EA.F1B0914C@xli.com>
Tom Christiansen wrote:
>
> [courtesy cc of this posting mailed to cited author]
>
> In comp.lang.perl.misc,
> Greg Bartels <gbartels@xli.com> writes:
> :he wants to hide it via a compiler, you want to hide it by
> :witholding any knowledge you may have of the subject
> :(not helping him).
>
> If I had information that would allow you to fire the nukes in Montana,
> I'd withhold that as well. It's a moral decision.
>
> --tom
> --
> X-Windows: It was hard to write; it should be hard to use.
> --Jamie Zawinski
there is no immorality in it. he wants to protect his copyrighted
code. you want to protect open source. youre both doing it by
withholding information.
how would his actions in any way hurt whats already available
in open source?
you've got him dressed up like Darth Vader for wanting to
protect his copyright. and all i've been trying to say is:
"he's not the bad guy". perhaps misguided, but not
evil incarnate.
is there some score keeping that should be done so that if
someone uses some open-source code, they must contribute
a similar amount of code or they are bad people?
maybe people who only download code, but never contribute
should make a monetary donation to CPAN or some similar site.
then they wont be considered nasty low down varmits.
the only way I can see this being wrong is if you are saying
soemthing to the effect of "all copyrighted code must have
freely available source code or said owners are bad"
then you say I'm practicing owrellian prevarication,
and you compare using an open-source compiler to
using atomic bombs? Come on Tom.
on one hand: using open-source, publicly availably software
to compile some copyrighted code.
on the other: Dr. Evil ransoming the world for a billion
dollars, and a fur coat for Mr. Bigglesworth.
Greg
------------------------------
Date: Wed, 26 May 1999 16:40:14 GMT
From: Hasanuddin Tamir <hasant@trabas.co.id>
Subject: ModUtils: simple utilities for perl modules
Message-Id: <7ih85d$oh$1@nnrp1.deja.com>
Hi,
I'm recently developing a small module that provides
some simple utilities for other perl modules called
ModUtils.
I wanted to have a way so I don't need to code the
same routines over and over again. So I wrote
functions such as Error(), Usage(), Flag(), and
Ref_or_Plain().
It's currently in version 0.02 but I have not released
it yet to the public domain. So I post this message to
find out if I could gain earlier feedback about either
the idea, the name space or the code.
Below, I include description and the code of two functions for
review. If anyone interested, I would love to send the
whole module.
thanks,
-hasan-
DESCRIPTION
-----------
Usage( ARG [, PREFIX] )
Terminates program caused by insufficient argument.
It croak()-s with message explains how to correctly
calling the routine.
Example:
package MyModule;
use ModUtils qw(Usage);
sub func {
@_ or Usage('NAME');
my($name) = @_;
print "$name\n";
}
When func() gets called without argument, it terminates
with message:
usage: func( NAME ) at FILE line LINE
## FILE and LINE are taken care by Carp::croak()
Flag( NAME [, VALUE] )
This is for toggle-like functions. NAME is the toggle
name and VALUE is the value. If no VALUE supplied, returns
current value of NAME.
Example:
sub debug { Flag('debug', $_[0] }
sub username { Flag('username', $_[0] }
sub password { Flag('password', $_[0] }
.... and so on
CODE
----
my %Flag;
sub Flag {
my($flag, $value) = @_;
defined($flag) || Usage('FLAG [, $VALUE]', undef, 0);
$Flags{$flag} = $value if defined $value;
$Flags{$flag};
}
sub Usage {
my $arg = defined $_[0] ? " $_[0] " : '';
my($sub) = (caller 1)[3];
$sub =~ s/.*:://;
my $level = defined $_[2] ? $_[2] : 1;
local($Carp::CarpLevel) = $level;
my $prefix = '';
if (defined $_[1]) {
if ($_[1]) {
$prefix = "$_[1]\->";
} else {
my $pack = caller;
$prefix = "$pack\:\:";
}
}
Carp::croak("usage: $prefix$sub($arg)");
}
-------------------------------------------
Hasanuddin Tamir <hasant@trabas.co.id>
TRABAS <http://www.trabas.co.id/>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 26 May 1999 16:50:44 GMT
From: Hasanuddin Tamir <hasant@trabas.co.id>
Subject: ModUtils: simple utilities for perl modules
Message-Id: <7ih8p3$16q$1@nnrp1.deja.com>
Hi,
I'm recently developing a small module that provides
some simple utilities for other perl modules called
ModUtils.
I wanted to have a way so I don't need to code the
same routines over and over again. So I wrote
functions such as Error(), Usage(), Flag(), and
Ref_or_Plain().
It's currently in version 0.02 but I have not released
it yet to the public domain. So I post this message to
find out if I could gain earlier feedback about either
the idea, the name space or the code.
Below, I include description and the code of two functions for
review. If anyone interested, I would love to send the
whole module.
thanks,
-hasan-
DESCRIPTION
-----------
Usage( ARG [, PREFIX] )
Terminates program caused by insufficient argument.
It croak()-s with message explains how to correctly
calling the routine.
Example:
package MyModule;
use ModUtils qw(Usage);
sub func {
@_ or Usage('NAME');
my($name) = @_;
print "$name\n";
}
When func() gets called without argument, it terminates
with message:
usage: func( NAME ) at FILE line LINE
## FILE and LINE are taken care by Carp::croak()
Flag( NAME [, VALUE] )
This is for toggle-like functions. NAME is the toggle
name and VALUE is the value. If no VALUE supplied, returns
current value of NAME.
Example:
sub debug { Flag('debug', $_[0] }
sub username { Flag('username', $_[0] }
sub password { Flag('password', $_[0] }
.... and so on
CODE
----
my %Flag;
sub Flag {
my($flag, $value) = @_;
defined($flag) || Usage('FLAG [, $VALUE]', undef, 0);
$Flags{$flag} = $value if defined $value;
$Flags{$flag};
}
sub Usage {
my $arg = defined $_[0] ? " $_[0] " : '';
my($sub) = (caller 1)[3];
$sub =~ s/.*:://;
my $level = defined $_[2] ? $_[2] : 1;
local($Carp::CarpLevel) = $level;
my $prefix = '';
if (defined $_[1]) {
if ($_[1]) {
$prefix = "$_[1]\->";
} else {
my $pack = caller;
$prefix = "$pack\:\:";
}
}
Carp::croak("usage: $prefix$sub($arg)");
}
-------------------------------------------
Hasanuddin Tamir <hasant@trabas.co.id>
TRABAS <http://www.trabas.co.id/>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 26 May 1999 16:54:43 GMT
From: Hasanuddin Tamir <hasant@trabas.co.id>
Subject: ModUtils: simple utilities for perl modules
Message-Id: <7ih90h$199$1@nnrp1.deja.com>
Hi,
I recently developed a small module that provides
some simple utilities for other perl modules called
ModUtils.
I wanted to have a way so I don't need to code the
same routines over and over again. So I wrote
functions such as Error(), Usage(), Flag(), and
Ref_or_Plain().
It's currently in version 0.02 but I have not released
it yet to the public domain. So I post this message to
find out if I could gain earlier feedback about either
the idea, the name space or the code.
Below, I include description and the code of two functions for
review. If anyone interested, I would love to send the
whole module.
thanks,
-hasan-
DESCRIPTION
-----------
Usage( ARG [, PREFIX] )
Terminates program caused by insufficient argument.
It croak()-s with message explains how to correctly
calling the routine.
Example:
package MyModule;
use ModUtils qw(Usage);
sub func {
@_ or Usage('NAME');
my($name) = @_;
print "$name\n";
}
When func() gets called without argument, it terminates
with message:
usage: func( NAME ) at FILE line LINE
## FILE and LINE are taken care by Carp::croak()
Flag( NAME [, VALUE] )
This is for toggle-like functions. NAME is the toggle
name and VALUE is the value. If no VALUE supplied, returns
current value of NAME.
Example:
sub debug { Flag('debug', $_[0] }
sub username { Flag('username', $_[0] }
sub password { Flag('password', $_[0] }
.... and so on
CODE
----
my %Flag;
sub Flag {
my($flag, $value) = @_;
defined($flag) || Usage('FLAG [, $VALUE]', undef, 0);
$Flags{$flag} = $value if defined $value;
$Flags{$flag};
}
sub Usage {
my $arg = defined $_[0] ? " $_[0] " : '';
my($sub) = (caller 1)[3];
$sub =~ s/.*:://;
my $level = defined $_[2] ? $_[2] : 1;
local($Carp::CarpLevel) = $level;
my $prefix = '';
if (defined $_[1]) {
if ($_[1]) {
$prefix = "$_[1]\->";
} else {
my $pack = caller;
$prefix = "$pack\:\:";
}
}
Carp::croak("usage: $prefix$sub($arg)");
}
-------------------------------------------
Hasanuddin Tamir <hasant@trabas.co.id>
TRABAS <http://www.trabas.co.id/>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 26 May 1999 16:57:09 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: need an anti-leech script
Message-Id: <7ih955$nq$1@news.NERO.NET>
In article <slrn7km9c2.dlq.fl_aggie@thepentagon.com>,
I R A Aggie <fl_aggie@thepentagon.com> wrote:
>
>Oh, gawd...that's too funny. Did they contact you, or redesign their
>pages?
Changed their page. They never quite understood what was happening, I
think, and probably still don't.
------------------------------
Date: 26 May 1999 16:58:50 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: need an anti-leech script
Message-Id: <7ih98a$pb$1@news.NERO.NET>
In article <374b1398@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
> [courtesy cc of this posting mailed to cited author]
>
>In comp.lang.perl.misc, Jerome O'Neil <jeromeo@atrieva.com> writes:
>:If one were to use, say, an image of a camel off of some publisher's web
>:site, you wouldn't have a problem with that?
>
>This is an unrelated issue. Please don't strawman.
Strawman is a noun. Taking an image from someone else's web site and
using it on your own is precisely the issue you raised. It isn't the
issue the original author brought up exactly, but you redirected it.
------------------------------
Date: Wed, 26 May 1999 10:30:54 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newbi: UNIX to NT
Message-Id: <374C2FCE.F0EB903F@mail.cor.epa.gov>
Don Stefani wrote:
>
> hello!
> I am brand new to programming and am trying to learn the basics so I can be
> a better webpage designer.
> I have active perl on my windows machine, and all the study books and
> scripts I can get from the web are for UNIX. May I ask you please, how do I
> make a UNIX perl / CGI program NT ready?
>
> Can someone send to the right referal pages?
Well, you'll be glad to know that all the docs you could
want (to make those eyeballs keep burnin' :-) are already
on your machine. When you installed ActiveState Perl,
you should have let it load an HTML tree on your disk
so you have plenty of Perl info right there on your machine.
In fact, you should have a shortcut to it in your Start
menu, for easy reference.
Take a look, starting at the top of the left-hand frame.
Under "Getting Started", it tells you what you have, and
how to get going. Then, under "ActivePerl Components", it
shows you about PerlScript and web programming with
PerlScript. It also tells you about PPM - read that, since
it will let you install a host of great, easy-to-use
modules. Like CGI.pm, which will make your web-programming
life much easier.
Look over the ActivePerl FAQ and the 'core' Perl FAQ.
There are answers to scores of common questions about Perl
and making Perl work the way you want. So the next time
you have a question, you'll tell yourself, "Wait, wasn't
there a comprehensive answer to that in the FAQ?" If you
read through the FAQ and still can't make your code work,
posting a small illustrative snippet here will get a
more favorable response if: [1] your code is cut-and-pasted
from a (semi-)working example; [2] you did look through
the FAQ; [3] you use the -w flag and the statements
'use strict;' and 'use diagnostics;' in your program; and
[4] you tell what the program does, what it is supposed to
do, and what errors you get.
BTW, use ppm to get that CGI.pm module I mentioned. It's
a great way to test your Perl programs before sticking them
on your website.
Every time you use PPM to get a new module, it will update
your HTML documentation tree too, so you can read about
whatever modules you snag, and look over the example code.
> Thank you, thank you very much.
> Don (my eyeballs are burnin') Stefani
>
> ....."I dig all the free knowledge on the web, thanks"
Then be aware that most of that so-called knowledge is
really more like ignorance.
Sturgeon's Law: "90% of everything is crap."
Cassell's Corollary: "If Ted Sturgeon had seen the Web, he
would have upped that percentage."
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 20 May 1999 15:58:28 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: OO: Perl resources
Message-Id: <374430ca.60361882@news.inet.co.th>
where can i find the free OO: perl resources on internet?
please suggest
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5790
**************************************