[27978] in Perl-Users-Digest
Perl-Users Digest, Issue: 9342 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 22 11:05:42 2006
Date: Thu, 22 Jun 2006 08:05:05 -0700 (PDT)
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, 22 Jun 2006 Volume: 10 Number: 9342
Today's topics:
Re: extraction of multiple extensions of a file path na <corff@zedat.fu-berlin.de>
Re: multiple system calls running at the same time guser@packetstorm.org
Re: Native language versions (Anno Siegel)
Re: Native language versions <tadmc@augustmail.com>
Re: perl programmer needed <tadmc@augustmail.com>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <tadmc@augustmail.com>
Re: Special variable "@$" <zen13097@zen.co.uk>
Re: Special variable "@$" <tadmc@augustmail.com>
Unset $1 <mndr@snafu.de>
Re: Unset $1 (Anno Siegel)
Re: Unset $1 <rvtol+news@isolution.nl>
Re: Unset $1 <rvtol+news@isolution.nl>
Re: What is a type error? <find@my.address.elsewhere>
Re: What is a type error? <cdsmith@twu.net>
Re: What is a type error? <chris.uppal@metagnostic.REMOVE-THIS.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Jun 2006 14:50:18 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: extraction of multiple extensions of a file path name ...
Message-Id: <4fvp1aF1kk8cvU2@uni-berlin.de>
martin <martps100@gmail.com> wrote:
: bascially I have ful path name to some files with no, single, or
: multiple extensinos, for example:
: /dir1/dir2/.../dirN/filename.ext1.ext2.ext3
: The extensions coud be anything, I just used ext1, ext2, so on.
: I like to extraxt two things:
: 1- all the extensions up to the last one , in this case
: ext1.ext2 (without .ex3)
probably .ext3 ?
What is your definition of an extension? Does it always start with a dot,
but does not contain a dot in itself? If so,
: 2- How can I extract the full pathname up to but not including last
: extension, i.e. to get:
: /dir1/dir2/.../dirN/filename.ext1.ext2
Let $filename contain your full path and file, then
$filename=~s/\.[^.]+$/;
will contain your new filename stripped off last extension and dot.
Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
------------------------------
Date: 22 Jun 2006 06:04:56 -0700
From: guser@packetstorm.org
Subject: Re: multiple system calls running at the same time
Message-Id: <1150981496.658472.226220@g10g2000cwb.googlegroups.com>
Thanks for the information. It pointed me to the POE project which
appears to be just what I was looking for.
Basically when the scheduler calls the poller script, the script delay
is caused if the poller has never discovered the node and has not
stored the community string (using net-snmp perl). A 3 second timeout
per attempt for N community strings can cause alot of delay before the
program stores the data (stored as a placeholder node if it cannot walk
the device, otherwise more data is populated into the db).
Looking over the POE docs I think the Child Process 3 cookbook example
will be what I am looking for. Plus it even includes an example of
limiting the children so the program does not go wild spawning child
procs.
-Greg
------------------------------
Date: 22 Jun 2006 13:21:08 GMT
From: anno4000@radom.zrz.TU-Berlin.DE (Anno Siegel)
Subject: Re: Native language versions
Message-Id: <4fvjq4F1k2f6pU1@news.dfncis.de>
In article <1150974224.552872.262280@g10g2000cwb.googlegroups.com>,
"Ian" <nisbeti@googlemail.com> writes:
> Has anyone tried translating the command set of Perl into other
> languages (French, Japanese, Arabic etc.), so that native speakers do
> not need to learn any English in order to program, then writing a
> suitable compiler?
The meaning of computer language keywords and their meaning
in a natural language have little to do with one another.
Knowing what "print" means in English desn't help you any
when it comes to its usage in a Perl context. So, even if
your approach were feasible, the benefit would be small.
The hard part to learn about computer language components
is their interaction, not their individual meaning.
Anno
------------------------------
Date: Thu, 22 Jun 2006 09:37:52 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Native language versions
Message-Id: <slrne9laq0.2ot.tadmc@magna.augustmail.com>
Ian <nisbeti@googlemail.com> wrote:
> Has anyone tried translating the command set of Perl into other
> languages (French, Japanese, Arabic etc.)
How do you say "grep" in French or Japanese?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 22 Jun 2006 09:52:55 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl programmer needed
Message-Id: <slrne9lbm7.2ot.tadmc@magna.augustmail.com>
my-name-is@slim.shady.com <my-name-is@slim.shady.com> wrote:
> I have a perl program that will allow to be used on one of my websites. I
> need this cracked so I can use it on my other sites.
What does "cracked" mean when you say it?
To most folks, "cracked" means "do something illegal".
Can it be that you are advertising for criminals in a public forum?
That would seem to me to not be in your best interests.
> please email at brian@doubletakedecoys.com
Then why does your From header say my-name-is@slim.shady.com?
Do you have permission to use the shady.com domain name?
Is your name Brian Ruther?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 22 Jun 2006 09:54:44 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <slrne9lbpk.2ot.tadmc@magna.augustmail.com>
Dr.Ruud <rvtol+news@isolution.nl> wrote:
> tadmc@augustmail.com schreef:
>
>> http://mail.augustmail.com/~tadmc/clpmisc.shtml
>
> ITTSB:
> http://www.augustmail.com/~tadmc/clpmisc/
Doh!
What I really meant was:
http://www.augustmail.com/~tadmc/clpmisc.shtml
^^^
^^^
That's what it says now (Revision: 1.6). Thanks for the catch.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Jun 2006 13:10:21 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: Special variable "@$"
Message-Id: <449a96bd$0$4377$da0feed9@news.zen.co.uk>
narra.madan@gmail.com <narra.madan@gmail.com> wrote:
> can any one explain the meaning of the perl special variable @$;
> the variable is used in the code..
> tha part of the code is shown below..
>
> #! c:\perl\bin\perl
> use strict;
use warnings;
>
> my(@fields);
> @fields=qw("hello" "how" "are" "u");
Better written as:
my @fields = qw(hello how are you);
(Unless you *really* wanted the quotes).
And yes, "you" is better than "u" :-)
> print "@fields\n";
>
> &do(\@fields);
"do" is a poor name for a subroutine. The casual reader may confuse it
with the "do" keyword.
Do you know what the "&" does on a function call? If not, you don't
need to use it.
deref_test(\@fields);
> print "@fields\n";
>
> sub do
> {
> my($fields_1,@fields,$var);
It's better practice to declare your variables only when you need
them, not well in advance.
>
> $fields_1=@_;
This is your problem. You are using the array @_ in scalar context.
Using an array in scalar context returns the number of elements in the
array (in this case 1, since you passed just one parameter to this
subroutine). To do the assignment is list context:
($fields_1) = @_;
(but $fields_1 is still a horrible name for a variable!)
> @fields=@$fields_1;
And now you try to de-reference an integer, giving an error:
Can't use string ("1") as an ARRAY ref while "strict refs" in use at ...
> $var=$fields[0];
>
> print "$var\n";
> }
Better written as:
sub deref_test {
my ($fields_ref) = @_;
my $var = $fields_ref->[0];
print "Var = '$var'\n";
}
(untested).
------------------------------
Date: Thu, 22 Jun 2006 09:21:15 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Special variable "@$"
Message-Id: <slrne9l9qr.2ot.tadmc@magna.augustmail.com>
narra.madan@gmail.com <narra.madan@gmail.com> wrote:
> is there any problem in the code....
Of course there is, it generates an error message and aborts!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 22 Jun 2006 15:10:10 +0200
From: "Martin D." <mndr@snafu.de>
Subject: Unset $1
Message-Id: <4fvj5kF1kv47dU1@uni-berlin.de>
Hi NG,
possibly a trivia, but:
Ho to unset $1 afer a regexp match?
------------------------------
Date: 22 Jun 2006 13:29:47 GMT
From: anno4000@radom.zrz.TU-Berlin.DE (Anno Siegel)
Subject: Re: Unset $1
Message-Id: <4fvkabF1k2f6pU2@news.dfncis.de>
In article <4fvj5kF1kv47dU1@uni-berlin.de>,
"Martin D." <mndr@snafu.de> writes:
> Hi NG,
>
> possibly a trivia, but:
> Ho to unset $1 afer a regexp match?
Run another match that matches but doesn't capture anything.
Anno
------------------------------
Date: Thu, 22 Jun 2006 15:37:52 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Unset $1
Message-Id: <e7edgt.1f4.1@news.isolution.nl>
Martin D. schreef:
> possibly a trivia, but:
> Ho to unset $1 afer a regexp match?
Why would you ever want to do that? I suspect an error in the program
logic.
OK, maybe if $1 occupies a lot of memory.
You can use something like this:
'' ~= /()/ ;
(but $1 will (still) be defined)
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Thu, 22 Jun 2006 16:02:58 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Unset $1
Message-Id: <e7ef0e.13k.1@news.isolution.nl>
Dr.Ruud schreef:
> Martin D.:
>> possibly a trivia, but:
>> Ho to unset $1 afer a regexp match?
> '' ~= /()/ ;
>
> (but $1 will (still) be defined)
Ah, as Anno said:
'X' ~= /X/ ;
'' ~= /.?/ ;
but not
'' ~= // ;
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Thu, 22 Jun 2006 09:01:10 -0500
From: Matthias Blume <find@my.address.elsewhere>
Subject: Re: What is a type error?
Message-Id: <m27j398f2x.fsf@hanabi.local>
Pascal Costanza <pc@p-cos.net> writes:
> Chris Smith wrote:
>
>> While this effort to salvage the term "type error" in dynamic
>> languages is interesting, I fear it will fail. Either we'll all
>> have to admit that "type" in the dynamic sense is a psychological
>> concept with no precise technical definition (as was at least hinted
>> by Anton's post earlier, whether intentionally or not) or someone is
>> going to have to propose a technical meaning that makes sense,
>> independently of what is meant by "type" in a static system.
>
> What about this: You get a type error when the program attempts to
> invoke an operation on values that are not appropriate for this
> operation.
>
> Examples: adding numbers to strings; determining the string-length of
> a number; applying a function on the wrong number of parameters;
> applying a non-function; accessing an array with out-of-bound indexes;
> etc.
Yes, the phrase "runtime type error" is actually a misnomer. What one
usually means by that is a situation where the operational semantics
is "stuck", i.e., where the program, while not yet arrived at what's
considered a "result", cannot make any progress because the current
configuration does not match any of the rules of the dynamic
semantics.
The reason why we call this a "type error" is that such situations are
precisely the ones we want to statically rule out using sound static
type systems. So it is a "type error" in the sense that the static
semantics was not strong enough to rule it out.
> Sending a message to an object that does not understand that message
> is a type error. The "message not understood" machinery can be seen
> either as a way to escape from this type error in case it occurs and
> allow the program to still do something useful, or to actually remove
> (some) potential type errors.
I disagree with this. If the program keeps running in a defined way,
then it is not what I would call a type error. It definitely is not
an error in the sense I described above.
------------------------------
Date: Thu, 22 Jun 2006 08:09:32 -0600
From: Chris Smith <cdsmith@twu.net>
Subject: Re: What is a type error?
Message-Id: <MPG.1f045282b0c5d5469896de@news.altopia.net>
Pascal Costanza <pc@p-cos.net> wrote:
> What about this: You get a type error when the program attempts to
> invoke an operation on values that are not appropriate for this operation.
>
> Examples: adding numbers to strings; determining the string-length of a
> number; applying a function on the wrong number of parameters; applying
> a non-function; accessing an array with out-of-bound indexes; etc.
Hmm. I'm afraid I'm going to be picky here. I think you need to
clarify what is meant by "appropriate". If you mean "the operation will
not complete successfully" as I suspect you do, then we're closer... but
this little snippet of Java (HORRIBLE, DO NOT USE!) confuses the matter
for me:
int i = 0;
try
{
while (true) process(myArray[i++]);
}
catch (IndexOutOfBoundsException e) { }
That's an array index from out of bounds that not only fails to be a
type error, but also fails to be an error at all! (Don't get confused
by Java's having a static type system for other purposes... we are
looking at array indexing here, which Java checks dynamically. I would
have used a dynamically typed language, if I could have written this as
quickly.)
I'm also unsure how your definition above would apply to languages that
do normal order evaluation, in which (at least in my limited brain) it's
nearly impossible to break down a program into sequences of operations
on actual values. I suppose, though, that they do eventually happen
with primitives at the leaves of the derivation tree, so the definition
would still apply.
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
------------------------------
Date: Thu, 22 Jun 2006 15:53:50 +0100
From: "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Subject: Re: What is a type error?
Message-Id: <449aaea0$2$656$bed64819@news.gradwell.net>
Chris Smith wrote:
> Some people here seem to be
> saying that there is a universal concept of "type error" in dynamic
> typing, but I've still yet to see a good precise definition (nor a good
> precise definition of dynamic typing at all).
How about this, at least as a strawman:
I think we're agreed (you and I anyway, if not everyone in this thread) that we
don't want to talk of "the" type system for a given language. We want to allow
a variety of verification logics. So a static type system is a logic which can
be implemented based purely on the program text without making assumptions
about
runtime events (or making maximally pessimistic assumptions -- which comes to
the same thing really). I suggest that a "dynamic type system" is a
verification logic which (in principle) has available as input not only the
program text, but also the entire history of the program execution up to the
moment when the to-be-checked operation is invoked.
I don't mean to imply that an operation /must/ not be checked until it is
invoked (although a particular logic/implementation might not do so). For
instance an out-of-bound array access might be rejected:
When the attempt was made to read that slot.
When, in the surrounding code, it first became
unavoidable that the about read /would/ be reached.
When the array was first passed to a function which
/might/ read that slot.
...and so on...
Note that not all errors that I would want to call type errors are necessarily
caught by the runtime -- it might go happily ahead never realising that it had
just allowed one of the constraints of one of the logics I use to reason about
the program. What's known as an undetected bug -- but just because the runtime
doesn't see it, doesn't mean that I wouldn't say I'd made a type error. (The
same applies to any specific static type system too, of course.)
But the checks the runtime does perform (whatever they are, and whenever they
happen), do between them constitute /a/ logic of correctness. In many highly
dynamic languages that logic is very close to being maximally optimistic, but
it doesn't have to be (e.g. the runtime type checking in the JMV is pretty
pessimistic in many cases).
Anyway, that's more or less what I mean when I talk of dynamically typed
language and their dynamic type systems.
> I suspect you'll see the Smalltalk version of the objections raised in
> response to my post earlier. In other words, whatever terminology you
> think is consistent, you'll probably have a tough time convincing
> Smalltalkers to stop saying "type" if they did before. If you exclude
> "message not understood" as a type error, then I think you're excluding
> type errors from Smalltalk entirely, which contradicts the psychological
> understanding again.
Taking Smalltalk /specifically/, there is a definite sense in which it is
typeless -- or trivially typed -- in that in that language there are no[*]
operations which are forbidden[**], and none which might not be invoked
deliberately (e.g. I have code which deliberately reads off the end of a
container object -- just to make sure I raise the "right" error for that
container, rather than raising my own error). But, on the other hand, I do
still want to talk of type, and type system, and type errors even when I
program Smalltalk, and when I do I'm thinking about "type" in something like
the above sense.
-- chris
[*] I can't think of any offhand -- there may be a few.
[**] Although there are operations which are not possible, reading another
object's instvars directly for instance, which I suppose could be taken to
induce a non-trivial (and static) type logic.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 9342
***************************************