[21895] in Perl-Users-Digest
Perl-Users Digest, Issue: 4099 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 11 18:06:40 2002
Date: Mon, 11 Nov 2002 15:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 11 Nov 2002 Volume: 10 Number: 4099
Today's topics:
Re: A vision for Parrot <goldbb2@earthlink.net>
Re: A vision for Parrot <dnew@san.rr.com>
Re: A vision for Parrot <goldbb2@earthlink.net>
Re: A vision for Parrot <dnew@san.rr.com>
Re: A vision for Parrot <goldbb2@earthlink.net>
Re: A vision for Parrot <dnew@san.rr.com>
Bug in utime? (HSwan)
Re: Bug in utime? <wksmith@optonline.net>
Re: Can you Simplify My Code #2? <goldbb2@earthlink.net>
Re: Filehandles within a sub, passed ot main <goldbb2@earthlink.net>
Global file search function? (Miguel)
Re: Global file search function? <tk@WINDOZEdigiserv.net>
Re: Global file search function? (Tad McClellan)
Re: help with arrays of arrays <goldbb2@earthlink.net>
Re: How to call C routines from perl? <bart.lateur@pandora.be>
Re: illegal use of comment ? <goldbb2@earthlink.net>
Re: illegal use of comment ? <bart.lateur@pandora.be>
Re: illegal use of comment ? <pkent77tea@yahoo.com.tea>
Re: illegal use of comment ? <john@imrie37.fsnet.co.uk>
Is python a good choice for this task? <ral@spongebob.corporate.com>
Re: Is python a good choice for this task? <fperez528@yahoo.com>
Re: Is python a good choice for this task? <tjreedy@udel.edu>
Re: module for child labour? <goldbb2@earthlink.net>
Re: ms word search regex <john@imrie37.fsnet.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 11 Nov 2002 14:31:33 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: A vision for Parrot
Message-Id: <3DD00595.B2905D8E@earthlink.net>
Darren New wrote:
>
> Benjamin Goldberg wrote:
> > In all cases that I can think of, your dynamic code is essentially a
> > string which gets eval()ed (with a language-dependent eval). The
> > solution is to make the eval() function/operator compile into a
> > sequence of operations along the lines of: Load the compiler for
> > this language, (if it's not already loaded), pass that string to the
> > compiler, run the generated bytecode.
>
> Seems like an awful lot of overhead for every keystroke, window event,
> and async file operation.
Why would any of these require that strings be eval()ed?
You compile the string to bytecode, *once*, and pass this compiled code
as the callback for your keystrokes, window events, and async file
operations. You wouldn't pass a string to be eval()ed -- that would be
silly.
Furthermore, even if one did do something that foolish, the compiler
needs to be loaded only once... So, (ignoring the first one, where the
compiler gets loaded) each keystroke, window event, or async file
operation would merely compile the string to bytecode, then run the
bytecode. This is no different from what Tcl does all the time, except
that it's a different kind of bytecode.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 11 Nov 2002 19:56:19 GMT
From: Darren New <dnew@san.rr.com>
Subject: Re: A vision for Parrot
Message-Id: <3DD00B63.EC604897@san.rr.com>
Benjamin Goldberg wrote:
> Why would any of these require that strings be eval()ed?
>
> You compile the string to bytecode, *once*, and pass this compiled code
> as the callback for your keystrokes, window events, and async file
> operations. You wouldn't pass a string to be eval()ed -- that would be
> silly.
Bindings substitute their values. File events get additional arguments.
Etc.
> Furthermore, even if one did do something that foolish, the compiler
> needs to be loaded only once...
I missed your parenthetical comment on first reading. Yes, sorry.
------------------------------
Date: Mon, 11 Nov 2002 15:21:17 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: A vision for Parrot
Message-Id: <3DD0113D.79EC23F6@earthlink.net>
Darren New wrote:
>
> Benjamin Goldberg wrote:
> > Why would any of these require that strings be eval()ed?
> >
> > You compile the string to bytecode, *once*, and pass this compiled
> > code as the callback for your keystrokes, window events, and async
> > file operations. You wouldn't pass a string to be eval()ed -- that
> > would be silly.
>
> Bindings substitute their values. File events get additional
> arguments. Etc.
So? Pass these in as arguments. There's no need to recompile a
procedure for each and every different set of arguments that might be
passed to it. That would defeat the point of having procedures in the
first place.
> > Furthermore, even if one did do something that foolish, the compiler
> > needs to be loaded only once...
>
> I missed your parenthetical comment on first reading. Yes, sorry.
Peculiar -- if I'd been reading someone else's description of it, and he
didn't say, "(if it's not already loaded)", I would have *assumed* that
it wouldn't be loaded if it already had been, *unless* he said something
to the contrary (like, "yes, I really do mean reload the compiler from
disk each and every time we eval() a string")
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 11 Nov 2002 20:39:50 GMT
From: Darren New <dnew@san.rr.com>
Subject: Re: A vision for Parrot
Message-Id: <3DD01596.A3420862@san.rr.com>
> So? Pass these in as arguments. There's no need to recompile a
> procedure for each and every different set of arguments that might be
> passed to it. That would defeat the point of having procedures in the
> first place.
A binding isn't a procedure. Indeed, I'm pretty sure that [eval] doesn't
cache bytecode in bindings because it's more inefficient than
regenerating the bytecodes each time. It's good style to invoke a
procedure, but hardly necessary. And indeed, putting something like
"break" or "continue" inside a procedure called by a binding doesn't
have the same effect as putting it in the binding.
------------------------------
Date: Mon, 11 Nov 2002 15:59:13 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: A vision for Parrot
Message-Id: <3DD01A21.2E4968D7@earthlink.net>
Darren New wrote:
>
> > So? Pass these in as arguments. There's no need to recompile a
> > procedure for each and every different set of arguments that might
> > be passed to it. That would defeat the point of having procedures
> > in the first place.
>
> A binding isn't a procedure.
That depends on your interface to Tk ... in perl, a binding *is* a
procedure. Well, actually it's either a procedure or a method name.
bind $b '<Button>', sub { print "Button pressed.\n" };
The 'sub' keyword creates an unnamed procedure.
> Indeed, I'm pretty sure that [eval] doesn't
> cache bytecode in bindings because it's more inefficient than
> regenerating the bytecodes each time. It's good style to invoke a
> procedure, but hardly necessary. And indeed, putting something like
> "break" or "continue" inside a procedure called by a binding doesn't
> have the same effect as putting it in the binding.
What are the semantics of "break" and "continue" in a procedure, when
they don't refer to a label or loop within that procedure?
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 11 Nov 2002 21:03:41 GMT
From: Darren New <dnew@san.rr.com>
Subject: Re: A vision for Parrot
Message-Id: <3DD01B2D.43C6456A@san.rr.com>
Benjamin Goldberg wrote:
> What are the semantics of "break" and "continue" in a procedure, when
> they don't refer to a label or loop within that procedure?
They return with a different exit code, I believe. In other words, it
depends on the caller.
------------------------------
Date: 11 Nov 2002 12:25:37 -0800
From: lanhws@expl.ak.ppco.com (HSwan)
Subject: Bug in utime?
Message-Id: <3aeb5d59.0211111225.3e8434df@posting.google.com>
utime does not seem to update the modification time of a file that I
do not own, but nonetheless have group write permission. My code is:
#
# "Touch" option:
#
if ($command eq "Touch") {
my $time = time();
my $status = utime $time, $time, $file;
if (! $status) {
$mf->BeepMessage("File $file cannot be touched!");
}
else {
$mf->SetMessage("File $file has been touched.");
}
return;
}
When this snipet of code is executed with $file =
'WDG-Kugrua.vpvs.pp',
I get the message, 'File WDG-Kugrua.vpvs.pp cannot be touched!'.
When I do an 'ls -l WDG-Kugrua.vpvs.pp' I get
-rw-rw-r-- 1 landps npra 315 Nov 8 14:56
WDG-Kugrua.vpvs.pp
Although my user id is not landps, I am in the npra group. The Unix
touch
command works fine. I'm very sure that the Perl program is working in
the
same directory as the file. I would hate to have to do a system call
just
to touch a file!
I am running Perl version 5.6.1 under Solaris 2.8.
------------------------------
Date: Mon, 11 Nov 2002 21:59:02 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Bug in utime?
Message-Id: <GKVz9.15098$wF2.3238@news4.srv.hcvlny.cv.net>
"HSwan" <lanhws@expl.ak.ppco.com> wrote in message
news:3aeb5d59.0211111225.3e8434df@posting.google.com...
> utime does not seem to update the modification time of a file that I
> do not own, but nonetheless have group write permission. My code is:
>
> #
> # "Touch" option:
> #
> if ($command eq "Touch") {
> my $time = time();
> my $status = utime $time, $time, $file;
> if (! $status) {
> $mf->BeepMessage("File $file cannot be touched!");
> }
> else {
> $mf->SetMessage("File $file has been touched.");
> }
> return;
> }
>
> When this snipet of code is executed with $file =
> 'WDG-Kugrua.vpvs.pp',
> I get the message, 'File WDG-Kugrua.vpvs.pp cannot be touched!'.
>
> When I do an 'ls -l WDG-Kugrua.vpvs.pp' I get
>
> -rw-rw-r-- 1 landps npra 315 Nov 8 14:56
> WDG-Kugrua.vpvs.pp
>
> Although my user id is not landps, I am in the npra group. The Unix
> touch
> command works fine. I'm very sure that the Perl program is working in
> the
> same directory as the file. I would hate to have to do a system call
> just
> to touch a file!
>
> I am running Perl version 5.6.1 under Solaris 2.8.
You probably do not have write permission for the directory which contains
the file. I am not clear why this is required, but it is a Unix issue, not
a Perl issue.
Bill
------------------------------
Date: Mon, 11 Nov 2002 14:37:19 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Can you Simplify My Code #2?
Message-Id: <3DD006EF.495E5EEE@earthlink.net>
Tassilo v. Parseval wrote:
[snip]
> As a side note: You seem to be very concerned with making your
> Perl-code as short as possible (see your other thread). Why is it that
> important to you? Choose the most readable solution, not the shortest
> one. In this case a short one happens to be readable, but this is not
> always the case.
Perl code with the fewest number of perl ops is generally going to be
fastest...
http://www.ccl4.org/~nick/P/Fast_Enough/#ops_are_bad,_m'kay
(Umm, there're two <A NAME> anchors in the file with the same label in
the file... Read from the first one.)
This doesn't always mean the fewest number of statements and
expressions, but it's pretty close.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 11 Nov 2002 16:53:01 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Filehandles within a sub, passed ot main
Message-Id: <3DD026BD.3414674C@earthlink.net>
Derek Thomson wrote:
[snip]
> Looking at perlfaq5 at http://perldoc.com (which is different from the
> perlfaq5 I have installed, for some reason), if you've got Perl 5.6
> you don't even need IO::File any more. "open" can deal with scalars
> directly.
Oh, it can do that even in perls before 5.6. The difference is in what
those scalars need to contain. In perl 5.6.1 and later, if you have a
scalar with nothing in it, perl will automatically put a reference to an
anonymous glob in it. Previously, you needed to have a glob or globref
in the scalar already.
> sub open_files
> {
> my @file_names = @_;
>
> my @files = ();
>
> for my $file_name (@file_names) {
> open my $file, $file_name;
> push @files, $file;
> }
>
> return @files;
> }
This can work on pre 5.6 by writing it as:
sub open_files {
require Symbol;
return map {
my $fh = Symbol::gensym();
open( $fh, $filename );
$fh;
} @_;
}
> You learn a new thing every day. And it's another way to make people
> *finally* trade up to 5.6 :)
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 11 Nov 2002 13:16:00 -0800
From: m_dv@hotmail.com (Miguel)
Subject: Global file search function?
Message-Id: <120db37b.0211111316.534140a9@posting.google.com>
Hello Everyone,
I'm wondering how will be possible to search for a specific
file format (example .zip) within the "entire" system, *every folder*.
I understand is possible to do it within perl's "current working
directory" but I'm really talking about doing a complete check trough
every folder within the system.
Any help will be appreciated. Thank You.
-Miguel Daniel <m_dv@hotmail.com>
------------------------------
Date: Mon, 11 Nov 2002 21:29:08 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: Global file search function?
Message-Id: <g480tu0q5dmk4okb8bmq58ffcu4jpgvbtq@4ax.com>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on 11 Nov 2002 13:16:00 -0800, m_dv@hotmail.com
(Miguel) managed to scribble:
| Hello Everyone,
|
| I'm wondering how will be possible to search for a specific
| file format (example .zip) within the "entire" system, *every
| folder*. I understand is possible to do it within perl's "current
| working
| directory" but I'm really talking about doing a complete check trough
| every folder within the system.
| Any help will be appreciated. Thank You.
|
| -Miguel Daniel <m_dv@hotmail.com>
perldoc file::find
SYNOPSIS
use File::Find;
find(\&wanted, '/foo', '/bar');
sub wanted { ... }
use File::Find;
finddepth(\&wanted, '/foo', '/bar');
sub wanted { ... }
use File::Find;
find({ wanted => \&process, follow => 1 }, '.');
It'll search every file/dir recursively.
HTH.
Regards,
tk
-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3
iQA/AwUBPdAhYyjNZg8h4REKEQJ83gCfQfYC6TJT7L4Y6+wjISvgw3RmE8AAnizz
kc9/+dVU8bwu55eC8ql8WCEF
=nkxo
-----END PGP SIGNATURE-----
--
+--------------------------+
| digiServ Network |
| Web solutions | Remove WINDOZE to reply.
| http://www.digiserv.net/ |
+--------------------------+
------------------------------
Date: Mon, 11 Nov 2002 16:01:53 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Global file search function?
Message-Id: <slrnat0a6h.261.tadmc@magna.augustmail.com>
Miguel <m_dv@hotmail.com> wrote:
> I'm wondering how will be possible to search for a specific
> file format (example .zip)
I guess you really meant file*name* rather than file format.
> within the "entire" system, *every folder*.
use File::Find;
my @found;
find sub { push @found, $File::Find::name if /\.zip$/ }, '.';
print "$_\n" for @found;
You can read the documentation for the module by typing:
perldoc File::Find
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Nov 2002 16:03:20 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: help with arrays of arrays
Message-Id: <3DD01B18.77862477@earthlink.net>
Vilmos Soti wrote:
[snip]
> foreach $user (keys %users) {
> next if "$users{$user}{safe}" eq "yes";
> # here comes your stuff
> }
Or, more memory-efficiently:
while( my ($user, $info) = each %users ) {
next if $$info{safe} eq "yes";
# put your stuff here.
}
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 11 Nov 2002 22:50:26 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How to call C routines from perl?
Message-Id: <loc0tusvmqdvtrpol85a9nsnmk2mvlr0m3@4ax.com>
robertbu wrote:
>DLL - I believe it is possible to create some perl wrapper subs and
> hand pack/unpack the parameters to the routines. I believe that
> is how Win32 routines are supported.
If the original C code is compiled to an ordinary DLL, then you can use
the WIN32::API module to declare the functions in Perl (as WIN32::API
objects), which you can then simply call with the "Call" method. It's
how one would call a routine from the API -- but it's not limited to the
original Windows DLL's. You can call functions in just about any normal
DLL this way.
It is all very reminescent on how one calls a function in a DLL from
within VB. It's all very easy.
--
Bart.
------------------------------
Date: Mon, 11 Nov 2002 14:22:54 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: illegal use of comment ?
Message-Id: <3DD0038E.B33E668C@earthlink.net>
Villy Kruse wrote:
>
> On Mon, 11 Nov 2002 17:10:20 GMT,
> tk <tk@WINDOZEdigiserv.net> wrote:
>
> >
> ># (being a hash, not £ pound) should work without spaces.
> >
> >
>
> That us a US thing. # is the pound sigh over there, that is, not
> pound sterling but the unit of weight.
Strangely, even though we USAans read "#" as "pound" or "pound sign", we
don't use it to denote weight -- we write pounds as "lbs" ... which
makes just as little sense, since the word "pound" has neither an "l"
nor a "b" in it.
Does anyone know the reasoning behind why, when reading punctuation
aloud, sometimes we speak the word "sign" or "mark", and sometimes we
don't add anything? Eg, reading across the top of my keyboard, I would
say tilde, exclamation point, at symbol, pound sign, dollar sign,
percent sign, caret, ampersand, times (only when used to multiply things
together, otherwise it's "asterix"), left parenthesis, right
parenthesis, underscore, plus (but it's only "plus" if it's being used
to add two things togeter, otherwise it's "plus sign").
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 11 Nov 2002 20:48:24 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: illegal use of comment ?
Message-Id: <cm50tusdb1ajv45n9iim9e1l2k23jltefv@4ax.com>
Benjamin Goldberg wrote:
>Strangely, even though we USAans read "#" as "pound" or "pound sign", we
>don't use it to denote weight -- we write pounds as "lbs" ... which
>makes just as little sense, since the word "pound" has neither an "l"
>nor a "b" in it.
It comes from the Latin "libra", meaning "pound". The French derivation
thereof is "Livre".
--
Bart.
------------------------------
Date: Mon, 11 Nov 2002 21:50:57 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: illegal use of comment ?
Message-Id: <pkent77tea-60BF37.21505711112002@news-text.blueyonder.co.uk>
In article <slrnasvs69.mu9.vek@station02.ohout.pharmapartners.nl>,
vek@station02.ohout.pharmapartners.nl (Villy Kruse) wrote:
> On Mon, 11 Nov 2002 17:10:20 GMT,
> tk <tk@WINDOZEdigiserv.net> wrote:
> ># (being a hash, not £ pound) should work without spaces.
> That us a US thing. # is the pound sigh over there, that is, not
> pound sterling but the unit of weight.
As other people from Leftpondia are also saying, "no it isn't". Or
rather, it's rare and possibly a corruption of the lb-bar symbol (you
can see how that could work if you write out 'lb' => '#' longhand).
[In .gb 'lb' is the usual abbreviation. There's the proper symbol(s) in
Unicode somewhere ISTR]
To reduce confusion it our Duty! to use, and encourage others to use,
unambiguous terms, especially in international areas like Usenet. In
this case the best thing to do, the thing with _zero_ ambiguity, is to
use the single plain ASCII (and supersets) character '#'. Calling it
hash, or octothorpe are also unambiguous in terms of fonts/glyphs/etc.
ObPerl:
And why yes I did have to deal with a load of data files proving that
people can get an email address 'wrong' in a variety of ways including:
adding newlines, or carriage returns
appending a final dot to the domain
typing the whole thing in upper case
etc. Hmm.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Mon, 11 Nov 2002 21:49:55 +0000
From: John Imrie <john@imrie37.fsnet.co.uk>
Subject: Re: illegal use of comment ?
Message-Id: <3DD02603.5090808@imrie37.fsnet.co.uk>
Bart Lateur wrote:
> Benjamin Goldberg wrote:
>
>
>>Strangely, even though we USAans read "#" as "pound" or "pound sign", we
>>don't use it to denote weight -- we write pounds as "lbs" ... which
>>makes just as little sense, since the word "pound" has neither an "l"
>>nor a "b" in it.
>>
>
> It comes from the Latin "libra", meaning "pound". The French derivation
> thereof is "Livre".
>
>
Which is why before decimalizeation in the UK LSD was pounds (libra)
Shillings and pence (denari) and not a drug
------------------------------
Date: Mon, 11 Nov 2002 14:29:21 -0600
From: Ron Lau <ral@spongebob.corporate.com>
Subject: Is python a good choice for this task?
Message-Id: <pan.2002.11.11.20.29.19.704887.2239@spongebob.corporate.com>
Hi,
This IS NOT a request for someone to write a program for me. (But I won't
turn it down :) ). The only programming I ever did was FORTRAN >:P , and short shell
scripts. I'm just looking for advice.
I have a CFD program that takes a text file as input (Q1.1). I run it on the
command line as:
phoe Q1.1
which outputs the binary file PH.1
I also have a program that gives me a number as the last line of its
output to the terminal with the command
pointquerey PH.1 TempK 1 1 1 | tail -1
What I do now is compare the output of the line above to the value I want
it to be, then change a parameter in the Q1.1 file, say T1=500.0
I would like to write something that would Goal Seek this for me.
(something simple like a newtonian method)
So I would need a program to..
--------------------------
run the command "phoe Q1.1"
then run the command "pointquery PH.1 TempK 1 1 1 | tail -1"
read the output of the above and compare to the desired value.
calculate a better value of T1.
replace T1=oldvalue in the file Q1.1 with the calculated value from
above.
loop back to the beginning...
-------------------------
My question is, What language is best suited for this? Perl, Python, or
shell scripts?
TIA!
ral
------------------------------
Date: Mon, 11 Nov 2002 13:51:25 -0700
From: Fernando =?ISO-8859-1?Q?P=E9rez?= <fperez528@yahoo.com>
Subject: Re: Is python a good choice for this task?
Message-Id: <aqp58f$8pm$1@peabody.colorado.edu>
Ron Lau wrote:
> My question is, What language is best suited for this? Perl, Python, or
> shell scripts?
Well, from each of the groups you posted to you'll get a different answer. But
of course, two of them will be wrong. You should use python :)
Kidding aside, such a simple task can be done in any of those without any
effort. I'd still suggest python because it's a better language than the
others for a number of things (yes, I've used all three extensively).
Especially if you have a scientific computing background: if you poke around
the web a bit, you'll find that python is becoming very popular in scientific
computing circles, and for good reason. See http://scipy.org/ or
http://mayavi.sourceforge.net/ for useful things in this direction.
The task you described will hardly illustrate the differences between these
languages. But when you decide you want to control your fortran CFD code
through a high-level language, load NetCDF or HDF5 data files, visualize them
with VTK, generate webpages out of the plot results, python will really begin
to shine. I recommend you read:
http://www.python.org/workshops/1997-10/proceedings/beazley.html before
making this decision. It's written from the viewpoint of a scientific
computing person, and while a bit old, it remains almost 100% true today. The
parts that have changed is simply that many of the tasks described in that
article are _far_ easier to do today than they were then.
Welcome!
f.
ps. Other useful links for python and scientific computing:
http://www.pfdubois.com/numpy/
http://starship.python.net/crew/hinsen/
http://w3.pppl.gov/~hammett/comp/python/python.html
------------------------------
Date: Mon, 11 Nov 2002 17:15:10 -0500
From: "Terry Reedy" <tjreedy@udel.edu>
Subject: Re: Is python a good choice for this task?
Message-Id: <eLSdnc-PiOEVtk2gXTWcpQ@comcast.com>
"Ron Lau" <ral@spongebob.corporate.com> wrote in message
news:pan.2002.11.11.20.29.19.704887.2239@spongebob.corporate.com...
> Hi,
>
> This IS NOT a request for someone to write a program for me. (But I
won't
> turn it down :) ). The only programming I ever did was FORTRAN >:P
, and short shell
> scripts. I'm just looking for advice.
>
>
> I have a CFD program that takes a text file as input (Q1.1). I run
it on the
> command line as:
>
> phoe Q1.1
>
> which outputs the binary file PH.1
>
>
> I also have a program that gives me a number as the last line of its
> output to the terminal with the command
>
> pointquerey PH.1 TempK 1 1 1 | tail -1
>
>
> What I do now is compare the output of the line above to the value I
want
> it to be, then change a parameter in the Q1.1 file, say T1=500.0
>
> I would like to write something that would Goal Seek this for me.
> (something simple like a newtonian method)
>
> So I would need a program to..
> --------------------------
>
> run the command "phoe Q1.1"
>
> then run the command "pointquery PH.1 TempK 1 1 1 | tail -1"
>
> read the output of the above and compare to the desired value.
>
> calculate a better value of T1.
>
> replace T1=oldvalue in the file Q1.1 with the calculated value from
> above.
>
> loop back to the beginning...
>
> -------------------------
>
>
> My question is, What language is best suited for this? Perl, Python,
or
> shell scripts?
You can run external programs from Python with os.system('command')
(check docs for details). You can easily read, modify, and write a
file (check out file() and file objects). The goal seeking logic can
be programmed in Python as well as anything else. If the other
programs take any sort of time at all, the interpreted speed of the
Python part will not matter. This type of glue job is one of the
things Python was invented for. Good luck.
Terry J. Reedy
------------------------------
Date: Mon, 11 Nov 2002 14:54:32 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: module for child labour?
Message-Id: <3DD00AF8.663BA099@earthlink.net>
edgue@web.de wrote:
[snip]
> What I really would like is a base class XYZ that
> handles all the necessary fork(), pipe(), stuff -
> and allows me to subcluss XYZ and implement only methods like
>
> react_to_command()
> provide_results()
> do_your_job()
>
> that would be called by the framework ... is there
> something like that available?
How about IPC::Run ?
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 11 Nov 2002 21:54:17 +0000
From: John Imrie <john@imrie37.fsnet.co.uk>
Subject: Re: ms word search regex
Message-Id: <3DD02709.1000701@imrie37.fsnet.co.uk>
Lance Hoffmeyer wrote:
> I am trying to pull some numbers from a ms word doc.
> Currently, I am using Win32::OLE to open the word doc
> then search the doc.
>
> The problem I am having is that I am not able to
> get the contents of test.doc into $file so that I
> can search $file.
>
> What step am I missing?
>
>
> my $Word = Win32::OLE->GetActiveObject('Word.Application')
> || Win32::OLE->new('Word.Application', 'Quit');
> $Word->{'Visible'} = 1;
> $Word->Documents->Add || die("Unable to create document ",
> Win32::OLE->LastError());
> my $MyRange = $Word->ActiveDocument->Content;
> my $Document = $Word->Documents->Open({FileName=>"p:\\docs\\perl\\test.doc"});
>
> {local $/=undef;my $file=$Document}
>
I think, IIRC you need to change $file=$Document to $file=$Document->Text
> my $file =~ /TABLE\s*167.*?MALE.*?(?:(\d\d\.\d)\D+){3}/s;
> my $num1 = $1;
> print "\n\n $num1 \n\n";
>
>
>
------------------------------
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.
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 4099
***************************************