[26148] in Perl-Users-Digest
Perl-Users Digest, Issue: 8339 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 19 18:05:23 2005
Date: Fri, 19 Aug 2005 15:05:09 -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 Fri, 19 Aug 2005 Volume: 10 Number: 8339
Today's topics:
Re: Dynamic Typing, Defencive Programming and Prototype <vtatila@mail.student.oulu.fi>
how to read file from sub-directories and do an average <a@cuhk.edu.hk>
Re: how to read file from sub-directories and do an ave <noreply@gunnar.cc>
Re: LWP::Simple and Cookies not working <evil666overlord@yahoo.co.uk>
Re: LWP::Simple and Cookies not working <no@email.com>
opinions on standard iterations? <joe@pong.tunestar.net>
Perl server, SOAP and .NET client, how to communicate <nospam@nospam.com>
Re: Perl server, SOAP and .NET client, how to communica <scobloke2@infotop.co.uk>
Re: PERL vs. Ruby <ceo@nospam.on.net>
seLinux in FC3 can make all my shell and perl scripts f <a@cuhk.edu.hk>
Re: seLinux in FC3 can make all my shell and perl scrip <no@email.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 Aug 2005 23:36:58 +0300
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: Dynamic Typing, Defencive Programming and Prototypes (Was: Interfaces and Type Safety)
Message-Id: <de5ftp$fne$1@news.oulu.fi>
Tassilo v. Parseval wrote:
>> better if I could be warned audibly by emiting the bell char \a
>> reckon that's a no-can-do in Win32 as signals aren't implemented and
>> END blocks not run when you die.
> Don't the pseudo-signals __WARN__ and __DIE__ work on windows, too?
> use warningsd FATAL => 'all';
> $SIG{ __DIE__ } = sub {
> for (1 .. 10) {
> print STDERR "\a"; # need auto-flushed handle here
> select undef, undef, undef, 0.2;
> }
> }
I'm not actually sure having never delt with signals before. It would seem
your example compiles but as soon as I try doing something after this sig
handler definition, I get a syntax error. Most likely my bad, though.
> Or use one of the Win32 modules to emmit this annoying "oh-oh" Windows
> system sound. :-)
I've turned all system sounds off explicitely so I'm not sure what It'll
play if anything. Maybe the good old standard beep from the PC Speaker.
Overloading:
> Note that tied hashes or arrays are conceptually overloading the subscript
> operator.
Yes, it seems so. Still I don't mind, that's awfully convenient and the
semantics are clear, too, especially the database examples I've seen. As to
bad operator overloading I've never liked the bitshits doing printing and
input in C++ as there's already a clearly defined meaning for those ops.
Still you have to choose some existing operator to overload if any,
Prototypes:
> The need for pre-declarations in certain languages has to do with the
> way the compilers are implemented.
I guessed that, though I must confess I know next to nothing about compiler
design. Another logical way to look at it is that it's unlikely that Perl
would have intentional, syntactic sault for dealing with prototypes. It is
easy to typo either of the two protos, the forward declaration or the actual
proto before the function body, which results in a prototype mismatch. C's
include files, forward declarations and a zillion other things have caused
me so much grief and frustration that I'm glad higher-level languages like
Perl or Java get well around these issues.
>> is there a way of automatically copying the
>> prototype from the implementation and placing it before the function
> Source filtering is probably the only way as it happens early enough,
> But it's a heavy and in parts error-prone weapon.
Yes, I've noticed. Source filtering was suggested to me in an earlier post
about making Perl operators English like or such that they read out well in
speech. I discovered after a while that it is a mixed blessing. As soon as
you have to work on a system that's just standard, it does help if you
haven't tweaked things an awful lot at home.
--
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/
------------------------------
Date: Sat, 20 Aug 2005 04:09:02 +0800
From: "Ross" <a@cuhk.edu.hk>
Subject: how to read file from sub-directories and do an average?
Message-Id: <de5e8a$2dgd$1@justice.itsc.cuhk.edu.hk>
I have the following directories under a dir called raw data-1, and under
each subdir, say, 4601-4.SMP, there is a single file under there. indeed
that single file has a fixed format and i'm going to extract numerical
values there to write to a new file along with two from 4601-4B.SMP and
4601-4C.SMP. Since a user does not follow nomenclature strictly, sometimes
he names a dir, say, 4601-4A.SMP instead of 4601-4.SMP, how could i achieve
extracting 3 files and write to a single file? Finally i would find the
average of the numerical values obtained from the 3 files.
admin/home/admin> ls -al raw\ data-1/
total 96
drwxr-xr-x 23 admin admin 4096 Aug 20 03:59 .
drwxr-xr-x 9 admin admin 4096 Aug 20 03:59 ..
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4594-3.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4594-3B.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4594-3C.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4601-4.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4601-4B.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4601-4C.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4605-5.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4605-5B.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4605-5C.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4612-2.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4612-2B.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4612-2C.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4614-6.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4614-6B.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4614-6C.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4618-1.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4618-1B.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4618-1C.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4620-1.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4620-1B.SMP
drwxr-xr-x 2 admin admin 4096 Aug 20 03:59 4620-1C.SMP
------------------------------
Date: Fri, 19 Aug 2005 22:20:32 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to read file from sub-directories and do an average?
Message-Id: <3mmt8gF17511qU1@individual.net>
Ross wrote:
> how could i achieve
> extracting 3 files and write to a single file? Finally i would find the
> average of the numerical values obtained from the 3 files.
Assuming you want to do it in Perl, these links might be helpful:
http://perldoc.perl.org/perlintro.html
http://learn.perl.org/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 19 Aug 2005 13:02:11 -0400
From: "EvilOverlord" <evil666overlord@yahoo.co.uk>
Subject: Re: LWP::Simple and Cookies not working
Message-Id: <9119e03c6d8dd1c8cae5d0c4ccdb836f@localhost.talkaboutprogramming.com>
Hi,
Did you ever find a solution to this problem?
I ran into exactly the same problem today trying to write very much the
same perl script as yours.
Enabling debug and examining the cookie shows that it seems to have been
accepted OK. Ebay simply thinks otherwise. I have also changed the user
agent with no luck either.
I really don't know why eBay are so determined to stop me doing a simple
completed items search.
------------------------------
Date: Fri, 19 Aug 2005 18:48:04 +0100
From: Brian Wakem <no@email.com>
Subject: Re: LWP::Simple and Cookies not working
Message-Id: <3mmkakF16tojvU2@individual.net>
EvilOverlord wrote:
> Hi,
>
> Did you ever find a solution to this problem?
>
> I ran into exactly the same problem today trying to write very much the
> same perl script as yours.
>
> Enabling debug and examining the cookie shows that it seems to have been
> accepted OK. Ebay simply thinks otherwise. I have also changed the user
> agent with no luck either.
>
> I really don't know why eBay are so determined to stop me doing a simple
> completed items search.
Who are you talking to?
Don't re-invent the wheel -
http://search.cpan.org/search?query=ebay&mode=module
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: Fri, 19 Aug 2005 19:29:53 GMT
From: Average_Joe <joe@pong.tunestar.net>
Subject: opinions on standard iterations?
Message-Id: <slrndgccne.96p.joe@pong.tunestar.net>
Hello Newsgroup.
Just soliciting some general opinions.
What would you say is the most sexy, easy to use iterator?
My favorite is to return an object supporting a next() method, (when next()
returns references or lists.) or a getline() method for lines of text. Boring,
but effective.
A close second is to return a code reference:
$code = someFunction();
while( $entry = $code->() ){
}
Easy, uncluttered, simple to do. $code->() can accept arguments if needed,
returning hashes and lists are sane.
I've been thinking about overloading <> so it becomes:
This is listed as "iteration" in overload, I'm left with the notion that it's
supposed to be the standard approach, yet I've never seen it in use for
returning references and lists.
while($entry = <$object>){
# huh?
}
This looks "dirty" to me, except maybe if $entry is plain-text, but where
$entry is a reference to something just seems to weird. One nice thing, I guess
is that you can have it both ways. <$object> OR $object->next() are the same
method.
One quirk, is that if next() is supposed to return a list. Like:
while( @record = <$object>) { ... }
I suppose you could do that, but one would think it should return ALL the
records, if each record is a list, it's kind of confusing.
What about:
while($object){
++$object; # The "iterator".
%rec = %{$object}; # The current value.
$rec = ${$object}; # Same thing.
}
Does that seem sane? To me it seems "more sane", except that you can't always
do --$object (Like if $object were reading from standard input)
Also seems too involved, have to implement 4 different functions instead
of a single 'next()' (and you have to keep track of a "current entry")
Finally, (more serious question I guess) what do you do about callbacks?
Say you use a module that uses a collector style callback. Maybe it performs a
search or something and calls your code reference for each hit.
You wanted to use it as part of your module, but you want your module to return
an iterator. How would you create a callback that can exit and then return
where it left off? Short of altering the module, the only way I can think of is
to build a whole list or use some sort of thread/fork.
Opinions?
Jamie
--
http://www.geniegate.com Custom web programming
User Management Solutions Perl / PHP / Java / UNIX
------------------------------
Date: Fri, 19 Aug 2005 15:26:52 +0000 (UTC)
From: "Vic Russell" <nospam@nospam.com>
Subject: Perl server, SOAP and .NET client, how to communicate
Message-Id: <de4tns$ip5$1@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com>
Can anyone give me a simple example of how to pass arguments between a .NET
(VB in my case) client and a Perl (SOAP::Lite) server. I have a small system
going which works with a Perl client but I need to replace it with a .NET
one. At the moment I can't get a simple string sent to the Perl server
although the correct Perl module is being executed.
I can return arguments to the .NET client but only in what seems a clumsy
way one parameter at a time rather than sending the full object back.
Any tips here VERY gladly received. It is a bit of a steep learning curve I
seem to have let myself in for!
Kind regards,
Vic
------------------------------
Date: Fri, 19 Aug 2005 17:25:27 +0000 (UTC)
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Perl server, SOAP and .NET client, how to communicate
Message-Id: <de54m7$1h2$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com>
Vic Russell wrote:
> Can anyone give me a simple example of how to pass arguments between a .NET
> (VB in my case) client and a Perl (SOAP::Lite) server. I have a small system
> going which works with a Perl client but I need to replace it with a .NET
> one. At the moment I can't get a simple string sent to the Perl server
> although the correct Perl module is being executed.
>
> I can return arguments to the .NET client but only in what seems a clumsy
> way one parameter at a time rather than sending the full object back.
>
> Any tips here VERY gladly received. It is a bit of a steep learning curve I
> seem to have let myself in for!
>
Similar questions have had this sort of response:
"You probably want to have a namespace on the returned data items.
See the INTEROPERABILITY section of the SOAP::Lite docs."
You might want to post example code (as per the posting guidelines)
although a VB.Net newsgroup might also be a more appropriate venue.
------------------------------
Date: Fri, 19 Aug 2005 15:28:34 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: PERL vs. Ruby
Message-Id: <4305FA94.6020605@nospam.on.net>
Ralph H. Stoos Jr. wrote:
> All,
>
> I have taken a company sponsored course in PERL taught by a fellow
> system engineer. He tried his best but, I am still an old dog and
> well.. that new tricks thing seems to apply.
>
> It seems that all courses I find assume you have other programming
> experience either in C, C++, or Java. Since I have none of these
> skills, I am hoping to somehow pick up an OOP language.
>
> So, I have folks recommending Ruby over PERL as a good language on which
> to cut my coding teeth.
>
> Any opinions on the subject would be appreciated.
Well, this is certainly my opinion, but... I wouldn't recommend Ruby
based on what you've described. If you are having a difficult time with
Perl, then Ruby is only going to be that much worse for you more than
likely. The paradigm in Ruby is a bit different IMO.
The *reason* most languages "assume" you have experience with another
language is because at the root, developing in ANY language requires
some grasping of fundamental concepts which factor into your successful
use of whatever language you are currently considering. It's just that
in order to do that, you have to dive in with ONE of them. But I would
not recommend Ruby for this.
Nor would I recommend Perl as a starting place for learning the craft of
development either. A lot of schools and universities teach Java as an
introductory course, I think. Maybe start there? Bruce Eckel also has
some introductory "Thinking In C++" and "Thinking In Java" free on the
Web which you can download and read.
And don't learn PERL from ANYONE!! If they are going to teach you PERL,
then politely decline. Only accept if they are going to teach you Perl.
You may think I'm being funny, but someone who volunteers to teach you
PERL more than likely isn't going to teach you Perl.
But feel free to come back here with legitimate questions in Perl if you
want. Just don't post to comp.misc.perl; it doesn't exist!
-ceo
------------------------------
Date: Sat, 20 Aug 2005 03:54:52 +0800
From: "Ross" <a@cuhk.edu.hk>
Subject: seLinux in FC3 can make all my shell and perl scripts fail
Message-Id: <de5ddo$2db5$1@justice.itsc.cuhk.edu.hk>
Just want to remind to those who are frustrated as I had been in the last
two weeks who had completely no idea what was happening... Thanks to a nice
guy making such a suggestion to me. change the SELINUX from enforcing to
disabled in
etc/selinux/config
if needed.
------------------------------
Date: Fri, 19 Aug 2005 21:00:14 +0100
From: Brian Wakem <no@email.com>
Subject: Re: seLinux in FC3 can make all my shell and perl scripts fail
Message-Id: <3mms2eF17d5btU1@individual.net>
Ross wrote:
> Just want to remind to those who are frustrated as I had been in the last
> two weeks who had completely no idea what was happening... Thanks to a
> nice guy making such a suggestion to me. change the SELINUX from enforcing
> to disabled in
>
> etc/selinux/config
>
> if needed.
First thing I did on our new RHEL4 server was turn that crap off. It stops
almost everything from working.
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
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 8339
***************************************