[10091] in Perl-Users-Digest
Perl-Users Digest, Issue: 3684 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 10 17:07:20 1998
Date: Thu, 10 Sep 98 14:00:18 -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 Thu, 10 Sep 1998 Volume: 8 Number: 3684
Today's topics:
Re: Absolute and Relative paths <merlyn@stonehenge.com>
Bogus Return Codes ($? >> 8) <george.kuetemeyer@mail.tju.edu>
How do you hide the definition of a subroutine? (Bernard Cosell)
Re: Looking for a programm in Perl!:=) (Tad McClellan)
mod_perl looping :-(. (Eric Lee Green)
Re: Objects & type checking (Sean McAfee)
Re: Objects & type checking <mark@satch.markl.com>
Re: Off topic, but ... [Was Re: Perl & Java - differenc (Jonathan Stowe)
Re: Off topic, but ... [Was Re: Perl & Java - differenc (Jonathan Stowe)
Re: Perl & Java - differences and uses <ajohnson@gpu.srv.ualberta.ca>
Re: Perl & Java - differences and uses bitnut1@my-dejanews.com
Re: Perl & Java - differences and uses <borg@imaginary.com>
Re: Perl & Java - differences and uses (Brian Wheeler)
Re: Perl & Java - differences and uses <borg@imaginary.com>
Re: Perl-Cgi-htaccess is this as simple as I think it i <dmorel@stny.lrun.com>
Re: Problem: dereferencing references to hashes (Elise Hooper)
Re: replacing text in a string (Michael J Gebis)
Returning objects? Is it possible? <mark@satch.markl.com>
SPSS Gateways in PERL <danny@spiff.bibl.ulaval.ca>
Re: Tokenizer in Perl... <jian@cisco.com>
Re: Tokenizer in Perl... (Damian Conway)
Re: What is "Robot" in Perl? (Faust Gertz)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 10 Sep 1998 20:15:15 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Absolute and Relative paths
Message-Id: <8cbtonhghr.fsf@gadget.cscaper.com>
>>>>> "Michael" == Michael Holden <michael@holdendesign.com> writes:
Michael> I have to change all <a href> links from absolute paths to
Michael> relative paths on roughly 5000 files. In the spirit of not
Michael> reinventing the wheel I was wondering if anyone knew if there
Michael> were scripts or modules out there that can assist with this.
Sounds suspicously close to my column #22 at
http://www.stonehenge.com/merlyn/WebTechniques/ -- go check that out.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 10 Sep 1998 15:59:56 -0400
From: George Kuetemeyer <george.kuetemeyer@mail.tju.edu>
Subject: Bogus Return Codes ($? >> 8)
Message-Id: <35F82FBC.7C52FA20@mail.tju.edu>
We recently upgraded our HPUX system to two processors. Since that time
we're getting a (very intermittent) bogus return code (FFFFFF) when
piping various programs. Here's the snippet of code that gets the return
code ($rc):
-----------------------------------------------------------------------------------------------------------------------------------------------------------
open(CMD, "$cmd 2>&1 |") or return undef; # pipe program to
filehandle
while (<CMD>) {
chomp;
push(@results, $_);
}
$rc = $? >> 8; # get exit value of subprocess (blue camel page
134)
close(CMD);
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks in advance!!
------------------------------
Date: Thu, 10 Sep 1998 20:00:07 GMT
From: bernie@fantasyfarm.com (Bernard Cosell)
Subject: How do you hide the definition of a subroutine?
Message-Id: <35f92f00.515636801@ganymede.rev.net>
I need to replace the definition of a subroutine, and I'm having a
devil of a time figuring out how to do it without generating 'warning'
complaints. If someone could explain how that part of Perl works, I'd
appreciate it.
The kind of thing I'd like to do is have a 'require' file that
includes definitions that "intercept" calls to a few routines in an
already-existing program. I've been trying to do something like:
*origfcn = \&fcn ;
*fcn = \&newfcn;
That doesn't work [it gets me the proper result, but gets me a warning
about redefining &fcn]. so I tried:
*origfcn = \&fcn ;
undef &fcn ;
*fcn = \&newfcn ;
and that made the error go away, but also clobbered the value of
&origfcn [so that both vars get me &newfcn now].
Clearly I'm just not really understanding how this aspect of Perl
really works... what would the 'right' way be to do this kind of
function hiding?
Thanks!
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
mailto:bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Thu, 10 Sep 1998 15:23:15 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Looking for a programm in Perl!:=)
Message-Id: <jfc9t6.q0f.ln@metronet.com>
Plate Forme Jeunes Diplomes (plateforme@wanadoo.fr) wrote:
: That is that I have ever wrote, and now, I can't do anything.
: The loop doesn't work.
: The searchnig string doesn't work.
: The print doesn't work...
: I am going to be mad!!!
^^^
'mad' is overloaded in English.
Leaves me wondering if you meant 'angry' or 'crazy'. ;-)
But I know the feeling (both of them) ...
: #!/usr/bin/perl
You need to enable warnings.
Really.
In *every* Perl program.
Especially when the program is not working right.
#!/usr/bin/perl -w
^^
^^ let perl help you debug your programs
: open (FILE,"/win95/Perl/dr129a.htm") or die ("Impossible de trouver le fichier
: : $!");
Checking the return value.
Good.
Very good.
: while (<FILE>) {
: chomp;
: $offre=$1 if ~m/(Offre.*?X)/s;
^
^ this is not doing what you think it is.
you want either:
$_ =~ /(Offre.*?X)/;
or
/(Offre.*?X)/;
which mean exactly the same thing.
=~ is a single operator composed of two characters.
= is a completely different operator.
~ is yet another different one...
: $date=$1 if ~m/(Date.*?98)/s;
^
^ since you are using the slash delimiter, you
don't need the 'm'. You only need it if you
use some other delimiter like:
m!(Offre.*?X)!; # exclamation mark delimiter
: $Ale=$1 if ~m/(Ale.*?TD)/s;
^
^ You don't need this either, unless you
have done something that you are not
showing us that would get multiple
lines into the $_ variable.
: $duree=$1 if ~m/(Recherche.*?FONT)/s;
: $descriptif= $1 if ~m/(CENTER.*?FONT)/s;
: $lieu=$1 if ~m/(Lieu.*?FONT)/s;
: $horaires =$1 if ~m/(Horaires.*?FONT)/s
If you had enabled warnings, then perl would have mentioned that
this is the _only_ place that the $horaires variable is used.
I think you are missing a print for that variable...
: }
: close (FILE)
You go through the _entire_ file before printing anything.
If you have more than one "record", then only the last one
will be output.
If you had given us some sample data, we could help you with
the details of printing each record rather than just the final record...
: print $offre ;
: print $date ;
: print $Ale ;
: print $duree ;
: print $descriptif;
: print $lieu ;
No newlines in the output?
Too hard to read.
: dave@mag-sol.com wrote:
: > Plate Forme Jeunes Diplomes <plateforme@wanadoo.fr> wrote:
: > > Hello,
: > >
: > > I am looking for a script which is very simple :
: > >
: > > - it must extract two character string which are between two words,
Your regexes above match **zero or more** characters between two words.
To really match two chars, you would do something like:
m/(Offre..X)/
^^ matches two (and *only* two characters)
Asking for help with a pattern match without providing examples
of the strings you want to match is very likely to lead to
useless advice.
In the future, please give some sample data.
Since you didn't, I get to make up what it might look like.
If it doesn't look like that, then my advice will not work either...
: > > (the script must scan all the file ( the string are repetited!)
: > > - it must put the variables a new file and save this file.
: > >
: > > If you have ever made this soft or know how can I do, can you help
: > > me please?
: >
: > I'm sure that most of us here would be very happy to help you write this
: > script. Why don't you post what you have written already and tell us why it
: > doesn't do what you want.
Maybe this will help:
--------------------------------------
#!/usr/bin/perl -w
while (<DATA>) {
chomp;
$offre=$1 if /Offre (..)X/;
$date=$1 if /Date (..)98/;
$Ale=$1 if /Ale (..)TD/;
$duree=$1 if /Recherche (..)FONT/;
$descriptif= $1 if /CENTER (..)FONT/;
$lieu=$1 if /Lieu (..)FONT/;
if (/Horaires (..)FONT/) { # got to the end of a "record"
$horaires =$1;
print "$offre\n" ;
print "$date\n" ;
print "$Ale\n" ;
print "$duree\n" ;
print "$descriptif\n";
print "$lieu\n" ;
print "$horaires\n" ;
print "----------\n";
}
}
__DATA__
Offre abX
Date cd98
Ale efTD
Recherche ghFONT
CENTER ijFONT
Lieu klFONT
Horaires mnFONT
Offre 12X
Date 3498
Ale 56TD
Recherche 78FONT
CENTER 90FONT
Lieu ABFONT
Horaires CDFONT
--------------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Sep 1998 20:12:12 GMT
From: eric@linux-hw.com (Eric Lee Green)
Subject: mod_perl looping :-(.
Message-Id: <80AF224CD57D3D88.432D9442CA02DE3C.538C5EF1EC1C9B94@library-proxy.airnews.net>
How can I make Apache and mod_perl quit looping when I have an error
in my Perl script? Typical error: I write
foo=$cgi->param('bar');
rather than
$foo=$cgi->param('bar');
and all hell breaks loose.
OS: Red Hat 5.1
Perl: 5.004
mod_perl: 1.11 (or so Red Hat claims).
Apache: 1.2.6
i.e. stock Red Hat stuff rather than "latest & greatest".
Note: I'm no Perl expert, so be gentle :-}.
--
Eric Lee Green eric@linux-hw.com http://www.linux-hw.com/~eric
Systems Specialist Linux Hardware Solutions -- Quality Designed for Linux
------------------------------
Date: Thu, 10 Sep 1998 20:15:36 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Objects & type checking
Message-Id: <IrWJ1.2045$F7.8673338@news.itd.umich.edu>
In article <m3yarrhkrs.fsf@satch.markl.com>,
Mark Lehrer <mark@satch.markl.com> wrote:
>Tom Christiansen <tchrist@mox.perl.com> writes:
>> That's your problem: you're thinking in C++. Don't do that. Perl's
>> treatment of OO is perfectly sensible--if you think in Perl. For every
>> problem that you can't solve by writing Perl exactly as though it were
>> Java or C++, there is a native Perl solution that works perfectly well.
>I agree, this is my first OO Perl project so I don't know the
>differences well, yet. The tutorials haven't done a good job of
>explaining them.
>I learned that it isn't possible to have two methods of the same class
>with the same name; which I'll assume means that I can have only one
>constructor per class.
No, you can have as many constructors as your want; they just have to have
different names. Any subroutine which returns a new object is a
"constructor":
package foo;
sub new_1 {
my $pkg = shift;
bless [ @_ ], $pkg;
}
sub new_2 {
my $pkg = shift;
bless [ 'extra', 'array', 'elements', @_ ], $pkg;
}
You can even obtain an object without calling a constructor at all:
package main;
$obj = bless [ "Bite", "me", "it's", "fun" ], "foo";
$obj->method_of_foo();
>> What would @ISA have to do with arguments?
>How else does a method know what object types were passed to it as
>arguments?
The work has already been done for you; all objects inherit from the
UNIVERSAL class, which provides the isa() method.
package A;
package B; @ISA = ('a');
package C; @ISA = ('b');
package D; @ISA = ('c');
package main;
$x = bless [ ], "D";
print $x->isa("D"), $x->isa("C"), $x->isa("B"), $x->isa("A");
This will print "1111".
>> What are you really
>> asking here? Are you asking for advice on writing variadic functions?
>Yes. I guess it isn't the most important C++ "feature" but it is nice
>to have multiple constructors (IMO).
>Of course, if this isn't thinking the "perl way" please give me some
>enlightenment! (or point me to an "FM" to read)
The facts that there is only one numeric type, and that numbers and
strings morph into each other on demand, eliminates much of the need
for function overloading. For instance, suppose you had an object which
hooked up to an output stream, and wanted to pass various datatypes to
it to be printed. In C++ you might do something like this:
class output_sink {
void print(char *string);
void print(int num);
void print(double num);
void print(char **stringarray, int size);
void print(int *numarray, int size);
void print(double *numarray, int size);
// Yes, one could use member template functions, but
// the principle is the same...
};
The first three print their argument; the second three print a list of
comma-separated values. In Perl, you could do all of this with a single
short function:
sub sink_print {
my $val = shift;
print ref $val eq "ARRAY" ? join(", ", @$val) : $val;
}
sink_print(3);
sink_print("Testing");
sink_print(["An", "array", "of", "strings"]);
sink_print(["An", 1, "array", 5, "of", 10, "mixed", 42, "types"]);
Also, in Perl, *all* functions may take an effectively unlimited number of
arguments, each of which you may examine in as much detail as you like.
With a simple modification, the above function can be made to print as
many of its argument types as you need:
sub sink_print_2 {
foreach my $val (@_) {
print ref $val eq "ARRAY" ? join(", ", @$val) : $val;
}
}
sink_print_2(3, 4.5, "A string", ["MORE", "STRINGS"]);
In my three years of frequent Perl programming, I've never needed a
function that cared about what object type it was passed. Can you go into
more detail about why this capability is needed?
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: 10 Sep 1998 16:22:22 -0400
From: Mark Lehrer <mark@satch.markl.com>
Subject: Re: Objects & type checking
Message-Id: <m3sohzhg5d.fsf@satch.markl.com>
Here's the web address to visit to buy a personality:
<*SPAM CENSORED*>
tchrist@perl.com (Tom Christiansen) writes:
> In comp.lang.perl.misc, Mark Lehrer <mark@satch.markl.com> writes:
> :> [courtesy cc of this posting sent to cited author via email]
> :unfortunately it was a spam-proof address. 8^)
>
> Then this is a spam-proof-proof message.
>
> :I agree, this is my first OO Perl project so I don't know the
> :differences well, yet. The tutorials haven't done a good job of
> :explaining them.
>
> Thank you.
>
> :I learned that it isn't possible to have two methods of the same class
> :with the same name; which I'll assume means that I can have only one
> :constructor per class.
>
> That's incorrect. The answer can be found in <*SPAM CENSORED*>.
>
> :> What would @ISA have to do with arguments?
> :
> :How else does a method know what object types were passed to it as
> :arguments?
>
> That's incorrect. The answer can be found in <*SPAM CENSORED*>.
>
> --tom
> --
> s = (char*)(long)retval; /* ouch */
> --Larry Wall in doio.c from the perl source code
------------------------------
Date: Thu, 10 Sep 1998 20:51:09 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Off topic, but ... [Was Re: Perl & Java - differences and uses]
Message-Id: <35f83af3.713860@news.btinternet.com>
On Wed, 09 Sep 1998 18:38:24 GMT, Randal Schwartz wrote :
>>>>>> "Clinton" == Clinton Pierce <cpierce1@cp500.fsic.ford.com> writes:
>
>Clinton> That's why us Michiganians had the Great Lakes installed. Works
>Clinton> a helluva lot better than a chain-link fence. Now if we could
>Clinton> only keep out the Ohio people...
>
>"Looks like we're gonna need a larger MOAT".
>
"We're gonna need a bigger boat" - they found great white sharks in
the Adriatic. We've got a good enoough moat and its getting bigger.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Thu, 10 Sep 1998 20:51:07 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Off topic, but ... [Was Re: Perl & Java - differences and uses]
Message-Id: <35f83a91.615599@news.btinternet.com>
On 09 Sep 1998 17:45:21 +0100, Jim Brewer wrote :
>Randal Schwartz <merlyn@stonehenge.com> writes:
>
>>
>> >>>>> "Bill" == Bill 'Sneex' Jones <sneaker@sneex.fccj.org> writes:
>>
>> Bill> Oh I don't know, I don't think anyone will miss
>> Bill> Washington State :]
>>
>> Hey, watch out. We have to have *some* insulating buffer
>> to keep the Canadians from flooding into Oregon.
>>
>> Washington - the great DMZ.
>> Ditto for California (shielding us from Mexico). :)
>>
>> Just another post I'll probably regret tomorrow, :)
>
>Hey, what about the Atlantic Ocean. That's a REAL DMZ. Shielding us
>from North America. Funny that. Big, cold, deep. Perfect.:)
With a warm expanding in the middle of course - anyhow judge dredd on
tv now.
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Thu, 10 Sep 1998 14:46:57 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Perl & Java - differences and uses
Message-Id: <35F82CB1.3D5C903F@gpu.srv.ualberta.ca>
George Reese wrote:
>
[snip]
! : Um, the goal was to show how "Perl accomplishes a task easier".
! : This may or may not be equivalent to "better", in your moral
! : framework; but I'm having a hard time seeing how
!
! : python -c 'import sys; import string; \
! : print string.atoi(sys.argv[1], 16)' 40
!
! : accomplishes its task easier than
!
! : perl -e 'print hex shift' 40
!
! It doesn't. And the perl version is not easier either. Just fewer
! keystrokes. Unless your sole goal is 'coding in the fewest
! keystrokes', I do not see how you can argue one version is
! meaningfully different than the other.
this example is not about key-strokes at all...I've no axe to grind
with python, but in the above examples, my vote is that the perl
version is definitely easier to read --- and we know that in any
comparison such as this, it'll always come down to personal
subjectivity ... perhaps you think the implicit 'shift' argument or
the lack of parens obfuscates the code:
perl -le 'print hex($ARGV[0])' 40
is that less clear than the python version? even to a relative
newcomer to either language? You can always claim that the perl
version is equally hard to read and maintain, but until you supply
hard data involving non-trivial numbers of beginner programmers
supporting your position your claim is devoid of any objective
content (as is mine).
Perhaps you meant something altogether different when you said in
another post:
! My claim is so sweeping, all you need to do is come up with a single
! situation in which Perl accomplishes a task easier.
but I'm at a loss to see what that might be.
regards
andrew
------------------------------
Date: Thu, 10 Sep 1998 20:09:01 GMT
From: bitnut1@my-dejanews.com
Subject: Re: Perl & Java - differences and uses
Message-Id: <6t9bkt$r8o$1@nnrp1.dejanews.com>
>------------------------------------
> George Reese <borg@imaginary.com>:
> Perl has no real use. If you have to do scripting or text processing,
> use Python. Otherwise, use Java.
>------------------------------------
I hate to throw cold water on both Perl and Python camps but there are
interpreters that are: 1. Intrinsically better (meaning: can accomplish
similar tasks without the noise and illogical constructs that plague Perl and
Python); and 2. ANSI standard (or soon to be).
Perl and Python will end up in the dustbin sooner or later and
no amount of your kicking and screaming is going to save them.
B.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 10 Sep 1998 20:31:27 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <zGWJ1.728$E9.2496809@ptah.visi.com>
In comp.lang.java.programmer Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> wrote:
[ example of different, but similar ways of doing the same thing in
both languages deleted ]
: Perhaps you meant something altogether different when you said in
: another post:
: ! My claim is so sweeping, all you need to do is come up with a single
: ! situation in which Perl accomplishes a task easier.
: but I'm at a loss to see what that might be.
You showed an instance in which, in your opinion, the perl code was
easier to read. I think in a single line, it is hard to demonstrate
that either way. It is across a full set of course that you can
establish that.
What I am looking for is a set of functionality that is easier to
accomplish in perl. That was not it.
--
George Reese (borg@imaginary.com) http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
"Keep Ted Turner and his goddamned Crayolas away from my movie."
-Orson Welles
------------------------------
Date: 10 Sep 1998 20:43:31 GMT
From: bdwheele@educ.indiana.edu (Brian Wheeler)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6t9dlj$2il$1@jetsam.uits.indiana.edu>
In article <6t9bkt$r8o$1@nnrp1.dejanews.com>,
bitnut1@my-dejanews.com writes:
>
>>------------------------------------
>> George Reese <borg@imaginary.com>:
>> Perl has no real use. If you have to do scripting or text processing,
>> use Python. Otherwise, use Java.
>>------------------------------------
>
> I hate to throw cold water on both Perl and Python camps but there are
> interpreters that are: 1. Intrinsically better (meaning: can accomplish
> similar tasks without the noise and illogical constructs that plague Perl and
> Python); and 2. ANSI standard (or soon to be).
And these interpreters are?
>
> Perl and Python will end up in the dustbin sooner or later and
> no amount of your kicking and screaming is going to save them.
Funny, because people were saying that about COBOL...and its *still*
here being used. Languages live or die depending on if the users *like* to
use the language...standardization and 'illogical constructs' are a secondary
goal.
Brian Wheeler
bdwheele@indiana.edu
------------------------------
Date: Thu, 10 Sep 1998 20:49:53 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <RXWJ1.735$E9.2521386@ptah.visi.com>
In comp.lang.java.programmer John Porter <jdporter@min.net> wrote:
: Um, the goal was to show how "Perl accomplishes a task easier".
: This may or may not be equivalent to "better", in your moral
: framework; but I'm having a hard time seeing how
: python -c 'import sys; import string; \
: print string.atoi(sys.argv[1], 16)' 40
: accomplishes its task easier than
: perl -e 'print hex shift' 40
Actually, I just did a test and showed both to people who know neither
language (IMHO, the best judges in a case like this). The funny thing
to mee is that both seem like 6 and 1/2 dozen. Which is why I find it
funny anyone would even bring this up as an example. But the
non-experienced in python and perl to whom I showed this seemed to
have a serious problem with 'hex shift' and found the python version
more straight forward.
I find that interesting. Nevertheless, either way, I think this
example shows nothing except that the two languages do things
differently.
Can't the "I love perl" crowd come up with some meaningful functional
benefit of perl?
--
George Reese (borg@imaginary.com) http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
"Keep Ted Turner and his goddamned Crayolas away from my movie."
-Orson Welles
------------------------------
Date: Thu, 10 Sep 1998 19:44:13 GMT
From: dmorel <dmorel@stny.lrun.com>
Subject: Re: Perl-Cgi-htaccess is this as simple as I think it is?
Message-Id: <35F82CC0.4C7BD1F@stny.lrun.com>
OK so this is the kind of thing I was worried about.
In then the opinion of Jeff at least, I am dealing with a relatively
serious
security issue here?
I would love to hear any other sugestions as to how I may be able to add
this variable
for use with .htaccess, or any other solution you may have. OR is there a
secure way to
get around the problems that Jeff is mentioning?
Many thanks for the input, I knew I must be missing something, it is never
THAT easy :)
-david
Jeff Zucker wrote:
> And someone can't fudge the http_referrer by sending their own header?
>
> - Jeff
>
> Daniel Adams wrote:
> >
> > Well, for a start it is a trivial matter to test where the form was
> > submitted from and, if it wasn't from your domain, to reject the
> > input.
> > Hells, even *I* can do this, and I'm Mr Newbie. I do this on about
> > half my
> > scripts anyway,
> >
> > --
> >
> > Dan Adams
> > dan@fearsome.net
> >
> > Jeff Zucker wrote in message <35F7F1B5.2035566D@vpservices.com>...
> > >dmorel wrote:
> > >> [...]
> > >> I need to set a variable for the number of times they
> > >> are allowed to enter.
> > >> [...]
> > >> could I not have a script that would read the contents
> > >> of a form (user-name, password, number of times allowed)
> > >
> > >What would prevent someone from creating their own form on their own
> > box
> > >with the same variables (with times_allowed = 1 zillion) and
> > submitting
> > >it to your script?
> > >
> > >- Jeff
------------------------------
Date: Thu, 10 Sep 1998 19:56:24 GMT
From: elhoop@unx.sas.com (Elise Hooper)
Subject: Re: Problem: dereferencing references to hashes
Message-Id: <35f82dd8.197413645@newshost.unx.sas.com>
On Tue, 08 Sep 1998 12:35:33 +0100, James Powell
<jamespo@N0SPAMyahoo.com> wrote:
>Okay, I have a pointer to a hash fetched from a DBI call
>
> $hshrf = $sth->fetchrow_hashref;
>
>I can access elements if I know their name by
>$hshrf->{'crud'}
>
>How can I dereference $hshrf so I can supply it to
>keys to find all the keys in the hash?
>f. ex. keys($$hshrf) doesn't work
>
>I've had a look in the camel book and can't work it out!
>Please email me if poss.
>
>Thanks,
>
>James
You need to dereference your hash qua hash:
#1. Create a hash
%myhash = (krazy=>"kat", gabby=>"hayes");
#2. Create a reference
$myhashref = \%myhash;
#3. Extract the keys (this is the key)
@keys = keys %$myhashref;
E
just gettin started myself
------------------------------
Date: 10 Sep 1998 20:07:23 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: replacing text in a string
Message-Id: <6t9bhr$an8@mozo.cc.purdue.edu>
Mark Lehrer <mark@satch.markl.com> writes:
}What is the best way to substitute a few characters in the middle of
}a string? I am using the slowest possible method:
}$foo="123abc789";
}$newstr=substr($foo,0,3) . "456" . substr($foo,6);
You might mean:
substr($foo,3,3)='456';
Take a look at "Benchmark" which lets you answer this question by
trying it out. (Benchmark should be already on your system.)
It may be possible to find a speedy regex to do this, but my regex ran
so slowly I don't even want to bother posting it. Benchmark it!
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 10 Sep 1998 16:12:30 -0400
From: Mark Lehrer <mark@satch.markl.com>
Subject: Returning objects? Is it possible?
Message-Id: <m3u32fhglt.fsf@satch.markl.com>
Hello. I am trying to write a routine that returns an object, like
so (simplified example):
sub pick_shape {
if ($_[0] eq "square") {
return new square();
} else {
return new triangle();
}
}
So, if I call this:
$foo=pick_shape("square");
I cannot call methods of this object; for example, if I were to say:
print STDOUT $foo->area();
It gives me an error:
Can't call method "area" without a package or object reference at ./test.pl line 11.
I am sure I'm doing something silly since I'm such a newbie. Any clues?
Thanks!
Mark
------------------------------
Date: Thu, 10 Sep 1998 20:34:22 GMT
From: "Danny J. Sohier" <danny@spiff.bibl.ulaval.ca>
Subject: SPSS Gateways in PERL
Message-Id: <35F839E2.6F55E8E1@spiff.bibl.ulaval.ca>
Hi folks,
Does anyone know where I could find
gateways to SPSS scripted in PERL ?
Thanks for any advice
Danny J. Sohier
dsohier@bibl.ulaval.ca
------------------------------
Date: Thu, 10 Sep 1998 12:59:21 -0700
From: Jian Zhang <jian@cisco.com>
Subject: Re: Tokenizer in Perl...
Message-Id: <35F82F99.D8461342@cisco.com>
Mike Stok wrote:
> DB<1> $s = 'module my_module(33: 3){'
>
> DB<2> @string_array = $s =~ /(\w+|\s+|.)/g
>
> DB<3> X string_array
> @string_array = (
> 0 'module'
> 1 ' '
> 2 'my_module'
> 3 '('
> 4 33
> 5 ':'
> 6 ' '
> 7 3
> 8 ')'
> 9 '{'
> )
>
> Hope this helps,
>
> Mike
>
> --
> mike@stok.co.uk | The "`Stok' disclaimers" apply.
> http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
> http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
> stok@colltech.com | Collective Technologies (work)
Thank you very much, Mike. Your short script is exactly what I am looking for.
Thanks again.
JZ
------------------------------
Date: 10 Sep 1998 20:37:33 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Tokenizer in Perl...
Message-Id: <6t9dad$b5u$1@towncrier.cc.monash.edu.au>
Jian Zhang <jian@cisco.com> writes:
>Hi,
>I am new to Perl and working on a simple parser. I'm looking for a way
>doing tokenization in Perl.
There are specific tools for this in the CPAN. One is Parse::RecDescent,
which is actually a recursive descent parser generator, but which does a
reasonable job tokenizing as well:
use Parse::RecDescent;
$Parse::RecDescent::tokensep = ''; # MAKE WHITESPACE SIGNIFICANT
my $lexer = new Parse::RecDescent <<EOLEXER; # BUILD LEXER
lex: token(s)
token: /module\b/ # KEYWORDS (THE \b IS IMPORTANT)...
| /function\b/ #
| /\d+/ # INTEGER VALUE
| ':' # PUNCTUATION...
| '(' #
| ')' #
| /[a-z]\w+/i # IDENTIFIER
| /./ # ANYTHING ELSE
EOLEXER
$data = ' module my_module(33: 3){';
@string_array = @{$lexer->lex($data)};
Note however that Parse::RecDescent can be slow on large inputs
(though I'm working feverishly on rectifying that :-)
If it's a problem you may find Parse::Lex or even Parse::Yapp a
better option.
Damian
------------------------------
Date: Thu, 10 Sep 1998 20:16:09 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: What is "Robot" in Perl?
Message-Id: <35f831ba.3709446@news.wwa.com>
On Fri, 11 Sep 1998 16:59:22 GMT, burningboy@hotmail.com (James Bond
098) wrote:
>"Robot" ,I've encountered this word many times in Perl ,etc. "Robot
>Rules ... some thing like that!, what does it means? -.-''
My guess is you are seeing references to Web Robots. See _The Web
Robots Pages_
<http://info.webcrawler.com/mak/projects/robots/robots.html>.
>From the _The Web Robots FAQ_
<http://info.webcrawler.com/mak/projects/robots/faq.html#what>:
>What is a WWW robot?
>A robot is a program that automatically traverses the Web's hypertext
>structure by retrieving a document, and recursively retrieving all
>documents that are referenced.
>Note that "recursive" here doesn't limit the definition to any specific
>traversal algorithm; even if a robot applies some heuristic to the
>selection and order of documents to visit and spaces out requests
>over a long space of time, it is still a robot.
>
>Normal Web browsers are not robots, because the are operated by
>a human, and don't automatically retrieve referenced documents
>(other than inline images).
>
>Web robots are sometimes referred to as Web Wanderers, Web
>Crawlers, or Spiders. These names are a bit misleading as they give
>the impression the software itself moves between sites like a virus;
>this not the case, a robot simply visits sites by requesting documents
>from them.
If you want to create robots with Perl, a good place to start is with
LWP::RobotUA .
Streben nach Wahrheit
Faust Gertz
Philosopher at Large
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3684
**************************************