[15826] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3239 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 2 18:10:39 2000

Date: Fri, 2 Jun 2000 15:10:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959983815-v9-i3239@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 2 Jun 2000     Volume: 9 Number: 3239

Today's topics:
    Re: Perl unusable as a programming language <kaleja@estarcion.com>
    Re: Perl unusable as a programming language (Ilya Zakharevich)
    Re: Perl unusable as a programming language (Greg Bacon)
    Re: Perl vs Python for Numerical Analysis zenin@bawdycaste.org
    Re: Perl vs Python for Numerical Analysis <dan@tuatha.sidhe.org>
    Re: Please Help!!! Writing data file on Two Unix Server <jdeboer@scsinternet.com>
    Re: REGEXP newbie question <methos495@earthlink.net>
    Re: seeking method to encode email addresses in web pag <nospam@devnull.com>
    Re: Speed <abe@ztreet.demon.nl>
    Re: Speed (Bart Lateur)
    Re: Will flock(...) wait? (Tad McClellan)
    Re: XS wrapper for (int argc, char *argv[]) style C fun <rjs@blue-cove.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 02 Jun 2000 10:38:53 -0700
From: Russell Bornschlegel <kaleja@estarcion.com>
Subject: Re: Perl unusable as a programming language
Message-Id: <3937F12D.E1B7C255@estarcion.com>



Ilya Zakharevich wrote:
> 
> [A complimentary Cc of this posting was sent to Russell Bornschlegel
> <kaleja@estarcion.com>],
> who wrote in article <3936E884.F50B51A0@estarcion.com>:
> > > Programming:          "If it does not work in next version of Perl, I will
> > >                        report it as a bug."
> 
> > Programming in Perl:
> > "If it does not work in the next version of Perl, I will check on c.l.p.m(s)
> > and see if I'm misunderstanding something. Failing that, I will report it
> > as a bug."
> 
> When programming, they make sure they understand *first*, not when
> things start to fail.

Ah, I see. I've never programmed, then, nor been in a situation where the 
documentation was sufficient to allow programming. 

-Russell B


------------------------------

Date: 2 Jun 2000 18:38:28 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl unusable as a programming language
Message-Id: <8h8uv4$dla$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Russell Bornschlegel 
<kaleja@estarcion.com>],
who wrote in article <3937F12D.E1B7C255@estarcion.com>:
> Ah, I see. I've never programmed, then, nor been in a situation where the 
> documentation was sufficient to allow programming. 

I suspect a lot of people are in the same situation as you are.  Not
many people being their carrier with writing a C compiler starting
from the standard...  ;-)

I think the Knuth's books are a must in such situations as yours...

Ilya


------------------------------

Date: Fri, 02 Jun 2000 16:03:36 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Perl unusable as a programming language
Message-Id: <sjfmmopu5ri131@corp.supernews.com>

In article <xn966rtuap2.fsf@pinga.doc.ic.ac.uk>,
    Edward Avis  <epa98@doc.ic.ac.uk> wrote:

: simon@brecon.co.uk (Simon Cozens) writes:
: 
: >what undocumented things?
: >Perl doesn't have them. If things are undocumented it's because the
: >documenters haven't found them yet. Or that we have found them, and they
: >were too ugly to easily comprehend and be useful. So if you start
: >programming "outside the box" why do you feel you should be protected?
: 
: How do you know what is inside and outside the box?  I've never seen
: any definitive list.  Is there a warning flag that tells you when
: something is undocumented?  Or do you have to cross-check every line
: of code against the perl on-line docs?

This sort of worry would be legitimate if your programming methodology
involves placing monkeys before keyboards and letting them bang away
until you have software that behaves as expected.  Here in the real
world where people learn a language from documentation, manuals, books,
tutorials, etc., the box is implicitly defined.  If a programmer is
tinkering with some code and comes up with something cool and unusual,
i.e., outside that implicit box of his experience, his first thought
should be, 'Cool!  I wonder whether that's documented.'  C, for example,
isn't all that different; consider Duff's Device.  The advantage of
Perl, however, is that you can communicate directly with the language's
developers and users through many different channels and reasonably
expect to receive a good response.

Greg
-- 
A lawyer is an expert on justice in the same way that a whore is an expert on
love.


------------------------------

Date: 02 Jun 2000 17:55:45 GMT
From: zenin@bawdycaste.org
Subject: Re: Perl vs Python for Numerical Analysis
Message-Id: <959968773.341202@thrush.omix.com>

Larry Rosler <lr@hpl.hp.com> wrote:
: I have been considering joining a team that is heavily into numerical
: analysis, specifically image processing.  The leader of the team (who
: considers himself a physicist, not a programmer) vigorously advocates
: Python, for the following reasons:
: 
:     Easier than Perl to integrate with C or C++.

	It is?

:     Better numerical-analysis support.

	Hmm, has he compared it to PDL (Perl Data Language)?

:     Inherently object-oriented (multiple inheritance, operator
:        overloading).

	Perl's object model is lifted from Python, actually.  Multiple
	inheritance and operator overloading are supported.  Perl's object
	model is far more relaxed then most, and even includes things like
	dynamic inheritance (dynamically redefining a class's inheritance
	tree at run time).

: I would appreciate help in understanding these issues.  The 'Perl vs. 
: Python' article <URL:http://www.perl.com/pub/language/versus/python.html>
: was posted by Tom Christiansen on June 2, 1995 (Happy Fifth Birthday!),
: and can hardly be presumed to reflect current reality.

	Probably not.

: I searched CPAN for numerical analysis modules, and couldn't find
: fundamental stuff, such as the FFT (Fast Fourier Transform), the BLAs
: (Basic Linear Algorithms) or LNPACK. The home page at
: <URL:http://search.cpan.org> doesn't even have a category for math or
: numerical analysis, nor does the category list at
: <URL:http://www.perl.com/CPAN-local/modules/by-category/>.

	Probably because it's big enough to demand its own home page:

		http://pdl.perl.org/

	>snip<
: I would appreciate comments and advice on this issue, because a career
: decision is involved.  I imagine that learning Python would be easy, and
: brushing up on my dormant numerical-analysis skills would be necessary
: regardless of the interface language.  Similarly, Tk would be the basis
: for the GUI, which is available in either language.

	I'd give a strong look at PDL.  Some pretty slick and powerful stuff
	in there.

: But if I can persuade the leader that Perl is an adequate vehicle for this
: type of program, ...  If, if, if...

	Convincing Python advocates that Perl is anything beyond the spawn
	of Satin is typically a lost cause...they typically just won't
	listen. :-(

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


------------------------------

Date: Fri, 02 Jun 2000 18:25:00 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl vs Python for Numerical Analysis
Message-Id: <0_SZ4.100075$hT2.407734@news1.rdc1.ct.home.com>

In comp.lang.perl.modules Larry Rosler <lr@hpl.hp.com> wrote:
> I have been considering joining a team that is heavily into numerical 
> analysis, specifically image processing.  The leader of the team (who 
> considers himself a physicist, not a programmer) vigorously advocates 
> Python, for the following reasons:

>     Easier than Perl to integrate with C or C++.

Dunno about that--Xs is pretty simple, and with SWIG it's even easier in
some ways to integrate existing C/C++ libraries.

>     Better numerical-analysis support.
>     Inherently object-oriented (multiple inheritance, operator
>        overloading).

So? Doing most of the work in either Python or perl is silly, as they're
relatively slow, so the OO properties of either language (which are of
questionable use in many cases anyway) are reasonably irrelevant.

Check out the PDL module on CPAN, or PDL's website at http://pdl.perl.org.
I think you may find it does exactly what you need, and is probably more
robust and mature than what you can get from Python. 

				Dan


------------------------------

Date: Fri, 02 Jun 2000 17:10:07 -0400
From: James deBoer <jdeboer@scsinternet.com>
Subject: Re: Please Help!!! Writing data file on Two Unix Servers...
Message-Id: <393822AF.5724EE45@scsinternet.com>


Why don't you have a cron job on the internal server fetch the data from
the external server? If the data is not the sensitive, you could make a
small perl script on the external server which sends the data to another
perl script on the internal server through a http server. eg the internal
server requests http://myweb.com/cgi-bin/fetchrawdata.pl or even simplier
do http://myweb.com/data/rawdata.txt ...

    James deBoer
        (jdeboer@scsinternet.com)

>
> 2. I can have a cron job on the external server that FTPs the data file
> into the internal unix server. But for this I will have to hard code
> the username/password in the perl script. Because this script
> resides in external server this is not acceptable for security reasons.
>
> Any help would be greatly appreciated.
>
> Thanks.
> -A
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



------------------------------

Date: Fri, 02 Jun 2000 19:33:37 GMT
From: methos <methos495@earthlink.net>
Subject: Re: REGEXP newbie question
Message-Id: <39380CDD.E81C836B@earthlink.net>

This is the sledge hammer approach, but it shoudl give you wnat you want:
-------------
foreach $zeile (@inhalt) {
  chomp($zeile);
  my ($field1, $field2, $field3, $field4, $field5, $field6) = split (m%\s+%,
$zeile);
  $field4 =~ s:"::g;
  $field6 =~ s:"::g;
}
------------

--
- Methos -
"What a Wicked Game you play, That you don't feel this way
What a Wicked thing to do, make me dream of you"
      - Chris Isaak -

Oliver Vecernik wrote:

> Hi,
> can anyone give me a hint? I'd like to split following data:
>
>   field1 field2   field3 "another field" field5 "another field 2"
>
> The fields are separated by one or more blanks. I used following:
>
> foreach $zeile (@inhalt) {
>   chomp($zeile);
>   ($field1, $field2, $field3, $field4, $field5, $field6) = split (/\s+/,
> $zeile);
> }
>
> But unfortunately fields 4 and 6 are delmited by quotes and should be
> stored without them. How do I have to modify my regexp?
>
> Thanks a lot,
> Oliver






------------------------------

Date: 2 Jun 2000 20:24:31 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <8h955v$7u3$0@216.155.33.21>

In article <39343CF9.48CB6CC9@stomp.stomp.tokyo>, "Godzilla!" 
<godzilla@stomp.stomp.tokyo> wrote:

 | The WebDragon wrote:
 | > "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
 | >  | The WebDragon wrote:
 | 
 | > tactless, and more than exceptionally insulting 
 | > considering you don't even know what RACE of HUMAN I am
 | 
 | 
 | Give it a break will you? How many years
 | have we known each other? As if I don't
 | know you and your background.
 | 
 | jeeeshhh...
 | 
 | If these people only knew what I know.
 | 
 | Now lighten up and stop trying to boss 
 | me around. You know well you cannot.

I've been on this group a little over a month.

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


------------------------------

Date: Fri, 02 Jun 2000 21:11:14 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Speed
Message-Id: <s7ufjskjpib453tfh14ot6gf9iklm0c1bs@4ax.com>

On Fri, 02 Jun 2000 14:07:40 GMT, newbie@db-networks.com wrote:

> I have a real fast computer and it takes 2.5hrs to process a file with
> 7 million lines.
It would  have helped if you would have given *us* some (as you seem to
plenty :-)

> 
> How can I speed it up? Help will be appreciated.
> 
> while(<INFILE>) {
>     chomp;
>     undef @data;
use lexicaly scoped vars (don't know about speed though):
	my @data;

>     push(@data, defined($1) ? $1:$3)
>         while m/([^,]+)/g;
I don't understand what you are trying to do here,
there is only *one* pair of capturing parens, so why would you expect $3
to hold *anything*?
$1 can only be undef if $_ eq '' or consists of commas, in either case
it doesn't seem useful. Skip to the next line?
Or do you want to split on ',' and use the third field instead of the
first if the first is empty?
	my @data =  split /,/;
	$data[0] = $data[2] unless $data[0];

>     $asked = substr($data[0],5,6);
>     $original = $data[1];
There is no need to make an extra copy of $data[1], you're not changing
it during it's lifetime.

>     $string1 = uc($data[1]);
>     $string1 =~ s/\%([1-F][A-F])+/ /g;
>     $string1 =~ s/_/ /g;
Not necessary, see next tr///
>     $string1 =~ s/\W/ /g;
	$string =~ tr/A-Za-z0-9/ /c;
>     $string1 =~ s/\s+/ /g;
	$string1 =~ tr/ / /s;
>     $string1 =~ s/^\s+//;
>     $string1 =~ s/\s+$//;
> 
>     undef %seen;
>     @tosave = ();
>     @words = ();
>     @words = split(/ /, uc($string1));
                          ^^
You've done that already.

> 
>     foreach $item (@noisewords) {
>         $seen{$item} = 1
>     }
This loop should be outside the while since there is no mention of
@noisewords within it. You could write that as:
	my %seen;
	@seen{ @noisewords } = (1) x @noisewords;

> 
>     foreach $item (@words) {
To save indentation you could:
	next if ...;
	push @tosave, $item;
>         unless (($seen{$item}) or ($item =~ m/\d/) or length($item) <
> 3){
>             push(@tosave, $item)
>         }
>     }
Or grep could be your friend.
	my @tosave = grep { !$seen{$_} && !/\d/ && length > 2} @words;

>     $toprint = join(" ",@tosave);
>     if (length($toprint) > 2){
Better still (don't bother joining something that's isn't there), save
indentation:
	next unless @tosave;
	my $toprint = join ' ', @tosave;

>        $firstchar = substr($toprint,0,1);
The next block looks too regular to be repeated :-)

>        if ($firstchar lt 'D') {
>            print OUTFILE1 $toprint, "," , $original, "," ,$asked ,
> "\n";
>        } elsif ($firstchar lt 'G') {
>            print OUTFILE2 $toprint, "," , $original, "," ,$asked ,
> "\n";
>        } elsif ($firstchar lt 'K') {
>            print OUTFILE3 $toprint, "," , $original, "," ,$asked ,
> "\n";
>        } elsif ($firstchar lt 'Q') {
>            print OUTFILE4 $toprint, "," , $original, "," ,$asked ,
> "\n";
>        } elsif ($firstchar lt 'T') {
>            print OUTFILE5 $toprint, "," , $original, "," ,$asked ,
> "\n";
>        } else {
>            print OUTFILE6 $toprint, "," , $original, "," ,$asked ,
> "\n";
>        }
>     }
> }
> 
> Thanks

-- 
Good luck,
Abe


------------------------------

Date: Fri, 02 Jun 2000 19:57:18 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Speed
Message-Id: <393910e1.16089180@news.skynet.be>

newbie@db-networks.com wrote:

>How can I speed it up? Help will be appreciated.

>    $string1 =~ s/\%([1-F][A-F])+/ /g;
>    $string1 =~ s/_/ /g;
>    $string1 =~ s/\W/ /g;
>    $string1 =~ s/\s+/ /g;
>    $string1 =~ s/^\s+//;
>    $string1 =~ s/\s+$//;

For one thing: you're replacing a lot with (preferabley) one space. You
could combine some stuff in the regexes, into  one pattern.

	s/(\%[0-9a-f]{2}|[\W_])+/ /g;

Remove any leading or trailing space (one, because of the above
reduction):

	s/^ //;
	s/ $//;

-- 
	Bart.


------------------------------

Date: Fri, 2 Jun 2000 11:23:24 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Will flock(...) wait?
Message-Id: <slrn8jfnrs.qb.tadmc@maxim.metronet.com>

On Fri, 2 Jun 2000 13:38:46 +0200, Thomas Plehn <thommy-p@bigfoot.com> wrote:

>I wondered what will happen if LOCK_EX is called while another script is
>reading from the file without any lock.


If *any* program uses the file without locking, then you do not
*have* locking.

File locking only works for cooperating programs.
(you really should have told us what OS you are using...)

Opening for read without getting a lock is not "cooperating".


>It is important that my list_read()-routines don't use any flock()-call,


Why is that important?


>however my list_update()-routine _must_ use LOCK_EX.


Then flock()-style file locking will *not* prevent corrupted data.

So, you either back off on the "no locks for reading" restriction,
or you use something besides flock() for avoiding file corruption.



-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 2 Jun 2000 14:52:30 -0700
From: "R J S" <rjs@blue-cove.com>
Subject: Re: XS wrapper for (int argc, char *argv[]) style C function?
Message-Id: <sjgag1495ri169@corp.supernews.com>

Someone wrote elsewhere:
---
> I'm trying to create an C XS extension for perl that takes a refrence to
> an array as an argument. Does anybody know the proper "type casting"
> typemap that can turn the perl-style reference to an array into C
> pointer to an array (of type double)?

You can't do this that easily. You're better off taking a reference in
and having your code iterate through the array and explicitly snag the
double values (well, NV values) out of the array with
SvNV.
---

I'm having a similar problem, but I have a refernce to an array in a C
function that I want converted via a typemap for Perl.
Ex:
Error: invalid argument declaration 'int *      weights[]' in iRACE.xs, line
181
was the error when make found the refernce.

BTW: I'm using:
h2xs -OPdx -n iRACE /home/rays/iRACE/c_libs/c_code.c
the -x option takes a lot of work out of coding .xs's, but you need the Scan
module.

Ray

Forrest Cahoon <fcahoon@my-deja.com> wrote in message
news:8gmul8$t8o$1@nnrp1.deja.com...
> Hello, everyone!
>
> I'm trying to write an XS wrapper for Ghostscript.
> (Has anyone done that already?  It could save me some work ...)
>
> I'm on a VMS system, and for some reason, h2xs doesn't seem to work
> properly -- it will set up all my files, but just ignores the
> prototypes in my .h file.  That's a weirdness I'd like to solve one
> day, but I've been able to write some simple XS hooks into my company's
> internal C functions in any case, and I was hoping to just write the XS
> code to hook into Ghostscript myself.
>
> What I'm hoping to get is routine I can call like so:
> Ghost::invoke(qw(-sDEVICE=jpeg -sOutputFile=foo.jpg foo.ps));
>
> in other words, just pass the parameters I would pass to Ghostscript on
> the command line.  I'm using the "system" call in my current perl code,
> of course.  The reason why I would like to write an XS wrapper is
> because I thought that I would get a performance advantage if I don't
> have to spawn a subprocess. (Is that accurate? I have heard that on
> VMS, spawning a subprocess has a high overhead.)
>
> The arguments to main() are argc and argv. I want to pass in a list
> from perl, and convert this into argc and argv at the top of my XS code.
>
> I bet that would actually come in handy a lot.
>
> Can anyone give me some pointers?
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3239
**************************************


home help back first fref pref prev next nref lref last post