[27946] in Perl-Users-Digest
Perl-Users Digest, Issue: 9310 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 17 14:06:01 2006
Date: Sat, 17 Jun 2006 11:05:04 -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 Sat, 17 Jun 2006 Volume: 10 Number: 9310
Today's topics:
Re: Activeperl and 3DES encryption - probably simple <bart@nijlen.com>
Re: Activeperl and 3DES encryption - probably simple <tom@tom.com>
balanced paren regex's ivowel@gmail.com
Re: balanced paren regex's <rvtol+news@isolution.nl>
Re: File::Find - passing argument to &wanted <hobosalesman@gmail.com>
Re: File::Find - passing argument to &wanted <wyzelli@yahoo.com>
Re: File::Find - passing argument to &wanted <john@castleamber.com>
Re: File::Find - passing argument to &wanted <john@castleamber.com>
How to handle modules error? <SaltyBall@Hell.com>
Re: How to handle modules error? <jeffpeng@pobox.com>
Re: How to handle modules error? <SaltyBall@Hell.com>
Re: How to handle modules error? <bart@nijlen.com>
Re: How to handle modules error? <christoph.lamprecht.no.spam@web.de>
Re: How to handle modules error? <SaltyBall@Hell.com>
Re: How to handle modules error? <john@castleamber.com>
Re: Perl Web Developer Wanted! <wyzelli@yahoo.com>
Re: Testing a new password <bart@nijlen.com>
Re: What is Expressiveness in a Computer Language <jo@durchholz.org>
Re: What is Expressiveness in a Computer Language <raffaelcavallaro@pas-d'espam-s'il-vous-plait-mac.com>
Re: windows mozilla perl helper app scripts <no_one@nowhere.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Jun 2006 02:07:51 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: Activeperl and 3DES encryption - probably simple
Message-Id: <1150535271.788289.138080@u72g2000cwu.googlegroups.com>
thomas wrote:
> I have to admit; I am not a perl programmer but I need to test that file
> encrypted by my program can be decrypted in unix environment using perl
> script.
> As far as I know Activeperl comes with libraries supporting 3DES encryption.
Yes, and also a bunch of other algorithms. DES might be a good choice
if you don't need a very strong algorithm and if you don't need much
speed (3DES is only 3 times DES).
> How would a script encrypting a file look like? It needs to take four
> parameters: input file, output file, encryption key and initialization
> vector - last two base 64 encoded.
I think this wouldn't be too difficult:
DES encryption/decryption:
http://cpan.uwinnipeg.ca/htdocs/Crypt-DES/Crypt/DES.html
Base64:
http://cpan.uwinnipeg.ca/htdocs/MIME-Base64/MIME/Base64.html
General encryption/decryption
http://cpan.uwinnipeg.ca/htdocs/Crypt-CBC/Crypt/CBC.html
AFAIK, Crypt::CBC and MIME::Base64 should be included in recent Perl
versions, maybe you would need additional installs of Crypt::Blowfish
or Crypt::DES.
Hope this helps,
--
Bart
------------------------------
Date: Sat, 17 Jun 2006 15:44:36 GMT
From: "thomas" <tom@tom.com>
Subject: Re: Activeperl and 3DES encryption - probably simple
Message-Id: <ErVkg.25048$VE1.5565@newssvr14.news.prodigy.com>
Hi Bart,
Unfortunately I am not a Perl programmer. I was hoping to find some simple,
ready to use and complete example.
I, of course, spent some time searching on google and I found nothing. There
are many complete examples for .Net and Java but I found none in Perl! I
think I will simply change my approach and either buy some third party
software or use Java.
Thank you,
Tomasz
------------------------------
Date: 17 Jun 2006 06:51:57 -0700
From: ivowel@gmail.com
Subject: balanced paren regex's
Message-Id: <1150552317.696575.320120@y41g2000cwy.googlegroups.com>
[posted earlier in perl.modules, but no answer.]
dear perl users: I want to write a function that extracts "ordinary"
subroutines from perl code. (an equivalent task is extracting all
macros from a latex file.) I am not trying to be too clever. let's
presume I can recognize subs because subs and only subs always start at
the first character of a line and are not anonymous. a sub is followed
by a name and can contain nested expressions.
I can do plain pattern matching to find the first occurance of the
first sub: '^sub \w+'. but now I am stuck. I need to continue
on with a Text::Balanced expression right after, and after the
text::balanced is done, continue on with my regex search (\G).
my $text=
"
{ text }
expressions
sub a {
if (1==1) { print "true"; } # if string or comment could contain
unbalanced paren, even better
}
more expressions
sub b {
if (0) { print "false" }
}
";
and I want to call a subroutine getnextsub() that first will return
"sub a {\n if (1==1) { print \"true\"; } # if string or
comment could contain unbalanced paren, even better\n }"
and on the next call will return
"sub b {\n if (0) { print \"false\" }\n }";
this must be a fairly common problem (e.g., extracting tex macro
arguments, etc.), but short of mimicking C in writing very low-level
paren counter subroutines on individual characters, I cannot see how to
solve this. I do understand the issue of how to treat nested subs, but
this right now is only a secondary concern.
help appreciated.
sincerely, /iaw
------------------------------
Date: Sat, 17 Jun 2006 16:20:59 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: balanced paren regex's
Message-Id: <e71a62.168.1@news.isolution.nl>
ivowel@gmail.com schreef:
> I want to write a function that extracts "ordinary"
> subroutines from perl code.
Search CPAN on 'balanced' or on 'parse'.
See also
http://search.cpan.org/search?module=PPI
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 17 Jun 2006 00:14:11 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <1150528451.041772.150020@p79g2000cwp.googlegroups.com>
Uri Guttman wrote:
> it is called inbreeding. php was first written in perl but the
> designers have/had no experience in language development and they all
<SNIP>
> perl is so good because it had one designer and his background was
> lingustics and computers which make for a solid background for a
> computer language designer.
Perl is my favourite language... but I'm actually a web designer/artist
more than a programmer, so I find PHPs ease of use, integration with
HTML, and mountain of available scripts/classes really attractive.
Power and ease of use always seem to be a trade off, so even if perl
can write a more powerful/stable/faster/elegant bulletin board system
it wouldn't be my first choice just because of the extra time involved
in writing it.
However PHP does remind me in many ways of actionscript/lingo... almost
a programming language for non-programmers.
Meh, I like it... everything has shortcomings, even perl.
------------------------------
Date: Sat, 17 Jun 2006 08:04:08 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <YHOkg.10902$ap3.405@news-server.bigpond.net.au>
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7u06kqnc9.fsf@mail.sysarch.com...
> >>>>> "HS" == Hobo Salesman <hobosalesman@gmail.com> writes:
>
> HS> Besides that I plan on concentrating more on PHP in the future, a
> HS> language for which naming conventions are apparently completely
> HS> unheard of... I can't imagine what happened in the development of
> HS> that language that caused them to choose function names like that.
>
> it is called inbreeding. php was first written in perl but the
> designers have/had no experience in language development and they all
> just poured in their genes into a bucket and watched what
> devolved. every recessive and degenerate trait was expressed in the
> phenotype. think of the british royals developing a web language. sorry
> for the imagery.
I don't often laugh out loud readint this newsgroup, but this one got me.
Well expressed.
P
--
print "just another wannabe\n"
------------------------------
Date: 17 Jun 2006 17:33:23 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <Xns97E57FB971F5Acastleamber@130.133.1.4>
"Hobo Salesman" <hobosalesman@gmail.com> wrote:
[PHP]
> of... I can't imagine what happened in the development of that language
We can only wonder :-D. The people who developed PHP in the beginning had
clearly very little experience with developing a language. Somehow I have
the idea they wanted to improve on Perl, but made new, and often bigger,
mistakes.
As to the camel case naming: one of the hardest things in programming is
learning to use the style of other people when switching to a project or
different language.
Try to avoid camel case, since it will make your programs harder to read
for quite some Perl programmers.
Once you are able to fit in with any programming culture, you are a real
traveller eh... programmer.
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: 17 Jun 2006 17:34:49 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <Xns97E57FF807190castleamber@130.133.1.4>
Uri Guttman <uri@stemsystems.com> wrote:
> it is called inbreeding. php was first written in perl but the
> designers have/had no experience in language development and they all
> just poured in their genes into a bucket and watched what
> devolved. every recessive and degenerate trait was expressed in the
> phenotype. think of the british royals developing a web language. sorry
> for the imagery.
LOL
> perl is so good because it had one designer and his background was
> lingustics and computers which make for a solid background for a
> computer language designer.
And yet it has its own oddness here and there.
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: Sat, 17 Jun 2006 18:33:15 +0800
From: SaltyBall <SaltyBall@Hell.com>
Subject: How to handle modules error?
Message-Id: <4493da3b$1@127.0.0.1>
Hi,
I am new to perl, I have write a simple "while loop" to call a perl
modules to do loop something, sometimes the modules generate error and
it exit the script completely.
How can I collect the error message and run the modules again if error
occur?
to summarize:
(current situation)
while something;
{ call the modules (it breaks when error occur) ; }
(improvement)
while something;
{call the modules;
=>if the modules fail, call it again;
}
------------------------------
Date: Sat, 17 Jun 2006 19:20:30 +0800
From: "pyh" <jeffpeng@pobox.com>
Subject: Re: How to handle modules error?
Message-Id: <e70p09$lh1$1@news.cn99.com>
Did you try calling 'eval'? you could do the action in an eval block,when
the eval executed false,it store the failed reasons in $@ .then you could
catch the $@ and re-run the actions.
"SaltyBall" <SaltyBall@Hell.com> ???? news:4493da3b$1@127.0.0.1...
> Hi,
>
> I am new to perl, I have write a simple "while loop" to call a perl
> modules to do loop something, sometimes the modules generate error and
> it exit the script completely.
>
> How can I collect the error message and run the modules again if error
> occur?
>
> to summarize:
>
> (current situation)
> while something;
> { call the modules (it breaks when error occur) ; }
>
> (improvement)
> while something;
> {call the modules;
> =>if the modules fail, call it again;
> }
>
------------------------------
Date: Sat, 17 Jun 2006 19:56:09 +0800
From: SaltyBall <SaltyBall@Hell.com>
Subject: Re: How to handle modules error?
Message-Id: <4493edaa$1@127.0.0.1>
Thanks very much!
I have find the following about eval from google, I will try it later.
-----------------------------------------------------------------------
Perl's Built-In Exception Handling Mechanism
Perl has a built-in exception handling mechanism, a.k.a the eval {}
block. It is implemented by wrapping the code that needs to be executed
around an eval block and the $@ variable is checked to see if an
exception occurred. The typical syntax is:
eval {
...
};
if ($@) {
errorHandler($@);
}
Within the eval block, if there is a syntax error or runtime error, or a
die statement is executed, then an undefined value is returned by eval,
and $@ is set to the error message. If there was no error, then $@ is
guaranteed to be a null string.
----------------------------------------------------------------------
pyh wrote:
> Did you try calling 'eval'? you could do the action in an eval block,when
> the eval executed false,it store the failed reasons in $@ .then you could
> catch the $@ and re-run the actions.
>
>
> "SaltyBall" <SaltyBall@Hell.com> ???? news:4493da3b$1@127.0.0.1...
>> Hi,
>>
>> I am new to perl, I have write a simple "while loop" to call a perl
>> modules to do loop something, sometimes the modules generate error and
>> it exit the script completely.
>>
>> How can I collect the error message and run the modules again if error
>> occur?
>>
>> to summarize:
>>
>> (current situation)
>> while something;
>> { call the modules (it breaks when error occur) ; }
>>
>> (improvement)
>> while something;
>> {call the modules;
>> =>if the modules fail, call it again;
>> }
>>
>
>
------------------------------
Date: 17 Jun 2006 05:06:37 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: How to handle modules error?
Message-Id: <1150545997.005956.240710@f6g2000cwb.googlegroups.com>
SaltyBall wrote:
> I am new to perl, I have write a simple "while loop" to call a perl
> modules to do loop something, sometimes the modules generate error and
> it exit the script completely.
>
> How can I collect the error message and run the modules again if error
> occur?
This demonstrates the principle:
#!perl
use strict;
use warnings;
eval ('use myModule;');
if ($@) {
print 'module not loaded';
# reload here
}
else {
print 'module loaded';
}
You can keep trying to load the module again and again (same syntax as
above), but watch out for endless loops obviously. $@ holds the error
message (if any) from your most recent eval-call.
One thought about your design: if the module fails to load the first
time, why would it not fail the second time then ? Are you loading it
over network/internet or so, and not trusting the connection ?
Hope this helps,
--
Bart
------------------------------
Date: Sat, 17 Jun 2006 16:58:42 +0200
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: How to handle modules error?
Message-Id: <e715av$it9$1@online.de>
SaltyBall wrote:
> Thanks very much!
> I have find the following about eval from google, I will try it later.
You don't need to google.
Perl documentation is available on your system:
perldoc -f eval
HTH,
Christoph
--
perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
------------------------------
Date: Sun, 18 Jun 2006 00:43:22 +0800
From: SaltyBall <SaltyBall@Hell.com>
Subject: Re: How to handle modules error?
Message-Id: <449430fa$1@127.0.0.1>
thanks
Bart Van der Donck wrote:
> SaltyBall wrote:
>
>> I am new to perl, I have write a simple "while loop" to call a perl
>> modules to do loop something, sometimes the modules generate error and
>> it exit the script completely.
>>
>> How can I collect the error message and run the modules again if error
>> occur?
>
> This demonstrates the principle:
>
> #!perl
> use strict;
> use warnings;
> eval ('use myModule;');
> if ($@) {
> print 'module not loaded';
> # reload here
> }
> else {
> print 'module loaded';
> }
>
> You can keep trying to load the module again and again (same syntax as
> above), but watch out for endless loops obviously. $@ holds the error
> message (if any) from your most recent eval-call.
>
> One thought about your design: if the module fails to load the first
> time, why would it not fail the second time then ? Are you loading it
> over network/internet or so, and not trusting the connection ?
>
> Hope this helps,
>
------------------------------
Date: 17 Jun 2006 17:36:21 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How to handle modules error?
Message-Id: <Xns97E5803A754C9castleamber@130.133.1.4>
SaltyBall <SaltyBall@Hell.com> wrote:
> thanks
salty balls are normally down, as should be your replies.
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: Sat, 17 Jun 2006 08:06:55 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: Perl Web Developer Wanted!
Message-Id: <zKOkg.10903$ap3.3284@news-server.bigpond.net.au>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrne9682b.7n8.tadmc@magna.augustmail.com...
> Uri Guttman <uri@stemsystems.com> wrote:
> >>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
<snip>
>
> s/who/what/;
I haven't posted here for a while, life does that from time to time, but
this thread makes me realise,
God I miss you guys...
Ok, back to work now...
P
--
just some random idiot
------------------------------
Date: 17 Jun 2006 06:21:49 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: Testing a new password
Message-Id: <1150550509.652202.162960@y41g2000cwy.googlegroups.com>
Jim Gibson wrote:
> [...]
> For a slightly better approach, I would start the password with a
> lowercase letter, an uppercase letter, and a digit, add as many
> characters as need to meet the length requirement, and then do a random
> shuffle of the characters.
One other suggestion is to avoid characters like these in passwords:
0 vs O (zero vs capital O)
1 vs l vs I (integer one vs lower case L vs capital i)
...
The display of those will obviously depend on the font, but many users
don't copy/paste passwords.
--
Bart
------------------------------
Date: Sat, 17 Jun 2006 13:03:19 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e70nha$q1o$1@online.de>
Raffael Cavallaro schrieb:
> On 2006-06-16 17:59:07 -0400, Joachim Durchholz <jo@durchholz.org> said:
>
>> I think it's easier to start with a good (!) statically-typed language
>> and relax the checking, than to start with a dynamically-typed one and
>> add static checks.
>
> This is purely a matter of programming style. For explorative
> programming it is easier to start with dynamic typing and add static
> guarantees later rather than having to make decisions about
> representation and have stubs for everything right from the start.
Sorry for being ambiguous - I meant to talk about language evolution.
I agree that static checking could (and probably should) be slightly
relaxed: compilers should still do all the diagnostics that current-day
technology allows, but any problems shouldn't abort the compilation.
It's always possible to generate code that will throw an exception as
soon as a problematic piece of code becomes actually relevant; depending
on the kind of run-time support, this might abort the program, abort
just the computation, or open an interactive facility to correct and/or
modify the program on the spot (the latter is the norm in highly dynamic
systems like those for Lisp and Smalltalk, and I consider this actually
useful).
I don't see static checking and explorative programming as opposites.
Of course, in practice, environments that combine these don't seem to
exist (except maybe in experimental or little-known state).
Regards,
Jo
------------------------------
Date: Sat, 17 Jun 2006 09:08:59 -0400
From: Raffael Cavallaro <raffaelcavallaro@pas-d'espam-s'il-vous-plait-mac.com>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <2006061709085950073-raffaelcavallaro@pasdespamsilvousplaitmaccom>
On 2006-06-17 07:03:19 -0400, Joachim Durchholz <jo@durchholz.org> said:
> I don't see static checking and explorative programming as opposites.
> Of course, in practice, environments that combine these don't seem to
> exist (except maybe in experimental or little-known state).
Right. Unfortunately the philosophical leanings of those who design
these two types of languages tend to show themselves as different
tastes in development style - for example, static type advocates don't
often want a very dynamic development environment that would allow a
program to run for testing even when parts of it arent defined yet, and
dynamic type advocates don't want a compiler preventing them from doing
so because the program can't yet be proven statically correct. Dynamic
typing advocates don't generally want a compiler error for ambiguous
typing - for example, adding a float and an int - but static typing
advocates generally do. Of course there's little reason one couldn't
have a language that allowed the full range to be switchable so that
programmers could tighten up compiler warnings and errors as the
program becomes more fully formed. Unfortunately we're not quite there
yet. For my tastes something like sbcl*, with its type inference and
very detailed warnings and notes is as good as it gets for now. I can
basically ignore warnings and notes early on, but use them to allow the
compiler to improve the code it generates once the program is doing
what I want correctly.
[*] I don't mean to exclude other common lisp implementations that do
type inference here - I just happen to use sbcl.
------------------------------
Date: Sat, 17 Jun 2006 17:05:00 GMT
From: Philip <no_one@nowhere.net>
Subject: Re: windows mozilla perl helper app scripts
Message-Id: <0DWkg.25065$VE1.18334@newssvr14.news.prodigy.com>
Mumia W. wrote:
> Philip wrote:
>
>> I was trying to get a perl based helper app to work with a mozilla
>> browser on windows.
>>
>> I have installed activeperl on my XP PC and I can run the helper
>> script from the MS-DOS window. ie
>>
>> helper.pl download_file.suffix.
>>
>> I then set helper.pl as the helper app for a my chosen file type
>> within the browser preference set up dialog. However, when I try to
>> handle the download through the browser I get the following error dialog:
>>
>> "<temporary download.suffix file> could not be opened because an
>> unknown error occurred.
>>
>> Sorry about that, try saving to disk first and then opening the file"
>>
>> I suspect that it is because windows perl scripts are not executed and
>> handed arguments as transparently as real executable helper apps.
>>
>> Is there a way around this problem? Have I incorrectly set up perl?
>
>
> Perhaps you could create a batch file (.BAT) that would invoke perl like
> so:
>
> c:\path\to\perl.exe helper.pl download_file.suffix
>
Yes that worked. Thanks.
I found a utility called pl2bat that made it easier.
Seems funny though that you can't get windows to work otherwise, but
then windows isn't unix.
------------------------------
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 9310
***************************************