[28414] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9778 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 28 06:05:52 2006

Date: Thu, 28 Sep 2006 03:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 28 Sep 2006     Volume: 10 Number: 9778

Today's topics:
    Re: Computer Language Popularity Trend semiopen@hotmail.com
    Re: Computer Language Popularity Trend <tagore@tagoresmith.com>
    Re: Deleting characters from the end of each line <keith.willis@aah.co.uk>
    Re: FA: Llama book (UK) <someone@example.com>
    Re: FAQ 3.1 How do I do (anything)? <bik.mido@tiscalinet.it>
        FTP from Perl script on Windows <ilackic@yahoo.com>
    Re: FTP from Perl script on Windows <sisyphus1@nomail.afraid.org>
    Re: FTP from Perl script on Windows <ilackic@yahoo.com>
    Re: How to dynamically generate function name and call  <DJStunks@gmail.com>
    Re: list vs. array <robb@acm.org>
    Re: list vs. array <bik.mido@tiscalinet.it>
        new CPAN modules on Thu Sep 28 2006 (Randal Schwartz)
        problems with Time::HiRes on some SLES systems <Mark.Seger@hp.com>
        Questions about Inline::C <january.weiner@gmail.com>
    Re: Questions about Inline::C <peace.is.our.profession@gmx.de>
    Re: Questions about Inline::C <sisyphus1@nomail.afraid.org>
    Re: Reading from standard input <someone@example.com>
    Re: Reference to hash value schwarzenschafe@gmail.com
        threads not executing @ same time <mem.namefix@gmail.com>
    Re: threads not executing @ same time <rmoritz@quantm.invalid.co.za>
        Uncommon misspelling! [was: "Re: Is LaTeX the tool I'm  <bik.mido@tiscalinet.it>
        What does Perl/C++/Pornography have in common? robic0
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 27 Sep 2006 19:20:40 -0700
From: semiopen@hotmail.com
Subject: Re: Computer Language Popularity Trend
Message-Id: <1159410040.644081.143260@e3g2000cwe.googlegroups.com>


John Bailo wrote:
> Xah Lee wrote:
> > Computer Language Popularity Trend
> >
> > This page gives a visual report of computer languages's popularity, as
> > indicated by their traffic level in newsgroups.
>
> The only problem being that in the last five years, there are now a
> multiplicity of options for discussing any of these languages, in places
> that are not Usenet.
>
> For example, Sun hosts a variety of bulletin boards on its java.net
> site.   Likewise Microsoft has it's "communities".
>
> My guess is that if you included all the new avenues the other languages
> would have growth curves about the same shape as for LISP.
>
Good point - especially given the sheer volume of the microsoft groups.
For example, I follow microsoft.public.excel.programming (and thus have
been quite interested in the discussion in fa.haskell recently about
finding a way for VBA to call Haskell functions) regularly and it
almost always has hundreds of posts a day - most of them business-like
discussions of code. Few of the traditional comp groups can boast of
such volume - so any attempt to measure an ill-defined popularity by
focusing on them will be skewed.

-semiopen



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

Date: 27 Sep 2006 22:14:05 -0700
From: "Tagore Smith" <tagore@tagoresmith.com>
Subject: Re: Computer Language Popularity Trend
Message-Id: <1159420445.679988.116760@i3g2000cwc.googlegroups.com>

Stefan Scholl wrote:
> In comp.lang.lisp Jon Ribbens <jon+usenet@unequivocal.co.uk> wrote:
> > In article <1159349867.827187.270390@h48g2000cwc.googlegroups.com>, mark.hoemmen@gmail.com wrote:
> >>> http://xahlee.org/lang_traf/index.html
> >>
> >> Careful there with the sweeping generalizations and quick judgments
> >> about languages :)
> >
> > I just read "PHP as a language is rather dry and business-like",
> > and fell off my chair.
>
> Well, business really is that crazy! :-)

Of the three people with whom I've worked who have sat on boards in the
Fortune 100, at least two of them have screwy reference semantics ;).



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

Date: 28 Sep 2006 01:33:51 -0700
From: "bytebro" <keith.willis@aah.co.uk>
Subject: Re: Deleting characters from the end of each line
Message-Id: <1159432431.688515.74050@i42g2000cwa.googlegroups.com>


Uri Guttman wrote:
> >>>>> "PL" == Paul Lalli <mritty@gmail.com> writes:
>
>   PL> I knew *someone* would bring this up. :-)   While I know about the
>   PL> 4-arg substr, I've just never gotten the hang of reading it correctly,
>   PL> and it always causes me to do a doubletake.  Even though the concept of
>
> i will give you a big help on grokking 4 arg substr. it has the SAME API

I thought this looked odd. I just checked in my copy of the Camel book
(2nd Ed), and AFAICT, there's no such beast as a 4 argument substr.
Shows how out of touch I am, I guess.  Would I be correct in assuming
this is a relatively recent addition?



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

Date: Thu, 28 Sep 2006 02:43:01 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: FA: Llama book (UK)
Message-Id: <VEGSg.31699$Lb5.18499@edtnps89>

Tad McClellan wrote:
> mark@tranchant.co.uk <mark@tranchant.co.uk> wrote:
> 
>>Randall Schwartz
> 
> 
> His name is "Randal".

Oh well, even Larry got it wrong occasionally:
http://groups.google.com/group/comp.lang.perl/msg/5580e6f384b33c44?hl=en&


John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: 28 Sep 2006 11:20:45 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FAQ 3.1 How do I do (anything)?
Message-Id: <hu4nh2p9hqgem5n17um4rpmnboe19tm282@4ax.com>

On Wed, 27 Sep 2006 18:03:03 -0700, PerlFAQ Server
<brian@stonehenge.com> wrote:

>3.1: How do I do (anything)?

How 'bout an ironic answer in terms of the Everything bundle?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 28 Sep 2006 08:31:53 +0000 (UTC)
From: Ivan L <ilackic@yahoo.com>
Subject: FTP from Perl script on Windows
Message-Id: <Xns984C6A9E0F938ivanlac@213.191.133.136>


I have tried to use FTP from Perl (not using System() but directly from perl script), and 
found out that all the sample programs found on the Internet don't work. Further investigation showed 
that there is following error

"Cannot connect to host: Net::FTP: Bad protocol 'tcp' at ftptest1.pl line 3."

The part of the perl script that caused this error is:
 
1.#!/usr/bin/perl -w
2. use Net::FTP;
3.    $ftp = Net::FTP->new("Host", Debug => 0) or die "Cannot connect to host: $@";

I use Windows XP SP2 and ActiveState Perl 5.8.7. Also, I have tried to use Windows 2003 
server, with the same result.
 Can anybody help with this? The FTP server on machine "host" is up and running, using command 
line I can FTP without problem.


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

Date: Thu, 28 Sep 2006 19:03:18 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: FTP from Perl script on Windows
Message-Id: <451b90ea$0$11972$afc38c87@news.optusnet.com.au>


"Ivan L" <ilackic@yahoo.com> wrote in message
news:Xns984C6A9E0F938ivanlac@213.191.133.136...
>
> I have tried to use FTP from Perl (not using System() but directly from
perl script), and
> found out that all the sample programs found on the Internet don't work.
Further investigation showed
> that there is following error
>
> "Cannot connect to host: Net::FTP: Bad protocol 'tcp' at ftptest1.pl line
3."
>
> The part of the perl script that caused this error is:
>
> 1.#!/usr/bin/perl -w
> 2. use Net::FTP;
> 3.    $ftp = Net::FTP->new("Host", Debug => 0) or die "Cannot connect to
host: $@";
>

Can't see anything that should pose a problem (assuming "Host" is replaced
by the valid string for whatever your host really is).

The following works fine for me on Win32:

use warnings;
use Net::FTP;
$ftp = Net::FTP->new("rtfm.mit.edu", Debug => 1)
  or die "Cannot connect to host: $@";
$ftp->login('anonymous','anonymous');
$ftp->cwd("/pub/usenet-by-group/");
$ftp->quit;

What does that script produce for you ?

Cheers,
Rob




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

Date: Thu, 28 Sep 2006 09:26:56 +0000 (UTC)
From: Ivan L <ilackic@yahoo.com>
Subject: Re: FTP from Perl script on Windows
Message-Id: <Xns984C73F311E2Bivanlac@213.191.133.136>

Hi Sisyphus,
Unfortunately the result is the same - the message is :
Cannot connect to host: Net::FTP: Bad protocol 'tcp' at C:\PROGRA~1\PERLEX~1\Scripts
\FTPPER~1.PL line 4.
I copied your script and put my host name...

I have all firewalls down and tried to connect to my localhost FTP server to exclude 
networking troubles, but it didn't change anything...


"Sisyphus" <sisyphus1@nomail.afraid.org> wrote in news:451b90ea$0$11972$afc38c87
@news.optusnet.com.au:

> use warnings;
> use Net::FTP;
> $ftp = Net::FTP->new("rtfm.mit.edu", Debug => 1)
>   or die "Cannot connect to host: $@";
> $ftp->login('anonymous','anonymous');
> $ftp->cwd("/pub/usenet-by-group/");
> $ftp->quit;
> 



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

Date: 27 Sep 2006 16:33:59 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: How to dynamically generate function name and call it?
Message-Id: <1159400039.152022.96770@i3g2000cwc.googlegroups.com>

Hemant Shah wrote:
> Folks,
>
>   How do I dynamically generate function and then execute the function?
>
>   I have a perl script that is used to drop/create/update database tables.
>   The script has drop/create/update functions for each table, and I
>   have if statements to call appropriate functions:
>
>   Example:
>
>   if ($TableName eq "TRAC")
>   {
>      CreateTRACTable();
>   }
>   elsif ($TableName eq "TRCO")
>   {
>      CreateTRCOTable();
>   }
>
>   and so on. I have similar if statements for drop and update.
>   Instead of having bunch of if statements, I can put the table
>   names in a hash and call:
>
>   if ($Action eq "Create")
>   {
>      Create${TableName}Table():
>   }
>   elsif ($Action eq "Drop")
>   {
>      Drop${TableName}Table():
>   }
>
>   and so on.
>
>
>   How do I do this?
>
>   Thanks.

Are your Create{ xxxx }Table and Drop{ xxxx }Table routines so
different for various xxxx's that you have to have completely different
subs for each distinct create, drop and xxx combination?

I'm sure you could simplify to

sub create_table {
  my ($xxxx) = shift
  # create as necessary
}

or even

sub alter_table {
  my ($action, $xxxx) = @_;
  # create as necessary if $action eq 'create'
  # drop as necessary if $action eq 'drop'
}

-jp



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

Date: 27 Sep 2006 18:17:11 -0700
From: "robb@acm.org" <robb@acm.org>
Subject: Re: list vs. array
Message-Id: <1159406231.414271.116430@k70g2000cwa.googlegroups.com>

Ben Morrow wrote:
> ...it is important to realize that you cannot pass an array to a
> function, in Perl...

I seem to remember this, and so long ago I adopted a coding style of
only passing scalars - actual scalars and refs - in my functions.

I've that if that's the coding style, then everything "just works", and
also there's a consistency of what to expect, and how to use the code.



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

Date: 28 Sep 2006 11:20:46 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: list vs. array
Message-Id: <vh4nh2p2r8rfesp55il5co9qua6u48agjr@4ax.com>

On 27 Sep 2006 18:17:11 -0700, "robb@acm.org" <robb@acm.org> wrote:

>> ...it is important to realize that you cannot pass an array to a
>> function, in Perl...
>
>I seem to remember this, and so long ago I adopted a coding style of
>only passing scalars - actual scalars and refs - in my functions.

Quite limitative and inefficiency-prone. But if you're feeling fine
with it...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 28 Sep 2006 04:42:08 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Sep 28 2006
Message-Id: <J6AD28.J27@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

CGI-ContactForm-1.31
http://search.cpan.org/~gunnar/CGI-ContactForm-1.31/
Generate a web contact form
----
CGI-Wiki-0.63
http://search.cpan.org/~dom/CGI-Wiki-0.63/
A toolkit for building Wikis.
----
Compress-LZF-1.7
http://search.cpan.org/~mlehmann/Compress-LZF-1.7/
extremely light-weight Lempel-Ziv-Free compression
----
Config-Format-Ini-0.02
http://search.cpan.org/~ioannis/Config-Format-Ini-0.02/
Reads INI configuration files
----
Date-Holidays-USFederal-0.01
http://search.cpan.org/~morrisnih/Date-Holidays-USFederal-0.01/
Determine US Federal Public Holidays
----
Gtk2-CV-1.3
http://search.cpan.org/~mlehmann/Gtk2-CV-1.3/
----
HTML-Mail-0.02_05
http://search.cpan.org/~plank/HTML-Mail-0.02_05/
Perl extension for sending emails with embedded HTML and media
----
HTML-Perlinfo-1.46
http://search.cpan.org/~accardo/HTML-Perlinfo-1.46/
Display a lot of Perl information in HTML format
----
HTML-ResolveLink-0.03
http://search.cpan.org/~miyagawa/HTML-ResolveLink-0.03/
Resolve relative links in (X)HTML into absolute URI
----
HTTP-Async-0.03
http://search.cpan.org/~evdb/HTTP-Async-0.03/
process multiple HTTP requests in parallel without blocking.
----
InSilicoSpectro-Databanks-0.0.8
http://search.cpan.org/~alexmass/InSilicoSpectro-Databanks-0.0.8/
parsing protein/nucleotides sequence databanks (fasta, uniprot...)
----
InSilicoSpectro-Databanks-0.0.9
http://search.cpan.org/~alexmass/InSilicoSpectro-Databanks-0.0.9/
parsing protein/nucleotides sequence databanks (fasta, uniprot...)
----
Konstrukt-0.5-beta3
http://search.cpan.org/~twittek/Konstrukt-0.5-beta3/
Web application/design framework
----
Lemonldap-NG-Handler-0.07
http://search.cpan.org/~guimard/Lemonldap-NG-Handler-0.07/
Perl extension for building a Lemonldap compatible handler
----
MIME-AltWords-0.11
http://search.cpan.org/~pts/MIME-AltWords-0.11/
properly deal with RFC-1522 encoded words
----
MP4-Info-1.11
http://search.cpan.org/~jhar/MP4-Info-1.11/
Fetch info from MPEG-4 files (.mp4, .m4a, .m4p, .3gp)
----
Mail-Toaster-5.01
http://search.cpan.org/~msimerson/Mail-Toaster-5.01/
turns a computer into a secure, full-featured, high-performance mail server.
----
Math-Symbolic-Custom-Contains-1.00
http://search.cpan.org/~smueller/Math-Symbolic-Custom-Contains-1.00/
Find subtrees in Math::Symbolic expressions
----
Math-SymbolicX-Inline-1.01
http://search.cpan.org/~smueller/Math-SymbolicX-Inline-1.01/
Inlined Math::Symbolic functions
----
Module-Build-Convert-0.38
http://search.cpan.org/~schubiger/Module-Build-Convert-0.38/
Makefile.PL to Build.PL converter
----
Nagios-Object-0.11
http://search.cpan.org/~tobeya/Nagios-Object-0.11/
----
Net-FTP-RetrHandle-0.2
http://search.cpan.org/~giff/Net-FTP-RetrHandle-0.2/
Tied or IO::Handle-compatible interface to a file retrieved by FTP
----
Net-Packet-3.00_01
http://search.cpan.org/~gomor/Net-Packet-3.00_01/
a framework to easily send and receive frames from layer 2 to layer 7
----
Net-Packet-Target-1.00
http://search.cpan.org/~gomor/Net-Packet-Target-1.00/
Target object for all Net::Packet related stuff
----
Net-SinFP-2.02
http://search.cpan.org/~gomor/Net-SinFP-2.02/
a full operating system stack fingerprinting suite
----
POE-Component-SNMP-1.07
http://search.cpan.org/~rdb/POE-Component-SNMP-1.07/
POE interface to Net::SNMP
----
POE-Component-Server-IRC-1.01
http://search.cpan.org/~bingos/POE-Component-Server-IRC-1.01/
a fully event-driven networkable IRC server daemon module.
----
POE-Filter-Bzip2-1.4
http://search.cpan.org/~bingos/POE-Filter-Bzip2-1.4/
A POE filter wrapped around Compress::Bzip2
----
Pod-Perldoc-ToToc-1.05
http://search.cpan.org/~bdfoy/Pod-Perldoc-ToToc-1.05/
Translate Pod to a Table of Contents
----
Proc-Pidfile-1.005
http://search.cpan.org/~awrigley/Proc-Pidfile-1.005/
a simple OO Perl module for maintaining a process id file for the curent process
----
Pugs-Compiler-Rule-0.19
http://search.cpan.org/~fglock/Pugs-Compiler-Rule-0.19/
Compiler for Perl 6 Rules
----
Regexp-Common-net-CIDR-0.01
http://search.cpan.org/~ruz/Regexp-Common-net-CIDR-0.01/
provide patterns for CDIR blocks.
----
SAP-Rfc-1.52
http://search.cpan.org/~piers/SAP-Rfc-1.52/
SAP RFC - RFC Function calls against an SAP R/3 System
----
SQL-Interpolate-0.40_03
http://search.cpan.org/~markstos/SQL-Interpolate-0.40_03/
Interpolate Perl variables into SQL statements
----
TAMeb-Admin-0.06
http://search.cpan.org/~mikfire/TAMeb-Admin-0.06/
----
Task-Catalyst-Tutorial-0.01
http://search.cpan.org/~jrockway/Task-Catalyst-Tutorial-0.01/
Installs everything you need to learn Catalyst
----
Test-Trap-v0.0.19
http://search.cpan.org/~ebhanssen/Test-Trap-v0.0.19/
Trap exit codes, exceptions, output, etc.
----
Test-WWW-Selenium-Catalyst-0.00_01
http://search.cpan.org/~jrockway/Test-WWW-Selenium-Catalyst-0.00_01/
Test your Catalyst application with Selenium
----
Text-MediawikiFormat-0.03
http://search.cpan.org/~dprice/Text-MediawikiFormat-0.03/
Translate Wiki markup into other text formats
----
WWW-AA-0.01
http://search.cpan.org/~aruteido/WWW-AA-0.01/
Perl extension for blah blah blah
----
WWW-IndexParser-0.6
http://search.cpan.org/~jeb/WWW-IndexParser-0.6/
Fetch and parse the directory index from a web server
----
WebService-MusicBrainz-0.03
http://search.cpan.org/~bfaist/WebService-MusicBrainz-0.03/
----
WordPress-V0.1
http://search.cpan.org/~senger/WordPress-V0.1/
----
subatom-0.11
http://search.cpan.org/~hdm/subatom-0.11/
produce an atom feed from subversion commits
----
subatom-0.12
http://search.cpan.org/~hdm/subatom-0.12/
produce an atom feed from subversion commits


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 28 Sep 2006 01:08:37 -0400
From: Mark Seger <Mark.Seger@hp.com>
Subject: problems with Time::HiRes on some SLES systems
Message-Id: <451b58d9@usenet01.boi.hp.com>

I've been using this module for doing highly accurate sleeping.  I would 
essentially set an alarm for n-seconds and then so a sleep for time time 
greater then n.  When the signal is delivered and I act on it (or simply 
just return), my app simply continues after the sleep.

I'm now trying this on several freshly installed sles10 systems and it 
wakes up early when the time is 5 or greater and I have no clue why.  It 
runs just fine on every other system/architecture I've tried.  Could 
something be missing from the installation?  Is there some easy way to 
tell??

Here's what the script looks like:

#!/usr/bin/perl -w

use Time::HiRes;

$SIG{ALRM}=\&sigAlrm;

for ($i=1; $i<60; $i++)
{
   $time0=time;
   Time::HiRes::ualarm($i*1000000);
   sleep 100;
   printf "Alarm: $i Awake!  %d secs\n", time-$time0;
}

# usleep wakeup
sub sigAlrm
{
}

and here's what it's producing on 3 systems:

linux:/mjs # /usr/bin/perl sht.pl
Alarm: 1 Awake!  1 secs
Alarm: 2 Awake!  2 secs
Alarm: 3 Awake!  3 secs
Alarm: 4 Awake!  4 secs
Alarm: 5 Awake!  0 secs
Alarm: 6 Awake!  2 secs
Alarm: 7 Awake!  3 secs
Alarm: 8 Awake!  3 secs
Alarm: 9 Awake!  1 secs
Alarm: 10 Awake!  1 secs
Alarm: 11 Awake!  3 secs
Alarm: 12 Awake!  3 secs
Alarm: 13 Awake!  0 secs
Alarm: 14 Awake!  1 secs
Alarm: 15 Awake!  2 secs

I'm stumped...
-mark


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

Date: Thu, 28 Sep 2006 09:58:04 +0200 (CEST)
From: January Weiner <january.weiner@gmail.com>
Subject: Questions about Inline::C
Message-Id: <effvac$cd7$1@sagnix.uni-muenster.de>

Dear all,

I had to revert to C again. Since the thought of parsing all my files in C
was dreadful, I decided to use Inline::C to only do the job that was really
computationally intensive.  Currently, my program seems to run quite well,
I am very happy with Inline::C, and a little coding in C made me bless
Larry again and again.

There are, however, few questions that remain open.

1. In the Inline::C cookbook, it says 

   > I would urge you to stay away from "malloc"ing your own buffer. Just
   > use Perl's built in memory management.  In other words, just create a
   > new Perl string scalar. The function "newSVpv" does just that. And
   > "newSVpvf" includes "sprintf" functionality.

   Why? I mean, is there is any danger with malloc() from within Inline::C
   that is not present in regular C programs, or is it because using malloc
   is just generally tricky?   I much prefer to do the allocation myself,
   as I know exactly how large my matrix is and as I want to allocate the
   whole matrix ( say, double 2000 x 2000 ) in one go myself. The reason is
   that I fear that using perl guts for my calculations (accessing the
   matrix, calculating values in it etc.) will be not much slower than a
   simple C implementation. Maybe I am wrong, I haven't tested it.

   Furthermore, I feel more comfortable using things that I know well, even
   thought they might turn dangerous.

2. When using Inline_Stack to return a list to Perl code, I found that the
   following throws a segfault:

    Inline_Stack_Reset ;
    Inline_Stack_Push( sv2_mortal( newSVpv( 'score' ) ) ) ;
    Inline_Stack_Done ;

  ...while the following does not:

    Inline_Stack_Reset ;
    Inline_Stack_Push( sv2_mortal( newSVpv( "score" ) ) ) ;
    Inline_Stack_Done ;

  Should I be worried, or is it normal behaviour? (I tried to look up the
  definition of Inline_Stack_Push, but I have trouble finding it).

  Cheers,

  January

-- 


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

Date: Thu, 28 Sep 2006 10:57:40 +0200
From: Mirco Wahab <peace.is.our.profession@gmx.de>
Subject: Re: Questions about Inline::C
Message-Id: <efg31q$p69$1@mlucom4.urz.uni-halle.de>

Thus spoke January Weiner (on 2006-09-28 09:58):

> I had to revert to C again. Since the thought of parsing all my files in C
> was dreadful, I decided to use Inline::C to only do the job that was really
> computationally intensive.  Currently, my program seems to run quite well,
> I am very happy with Inline::C, and a little coding in C made me bless
> Larry again and again.

One question in advance: Why use Inline::C if
your C-Program is what counts. Why don't you
simply link the 'perl' to your program and
call it with the stuff you need. This is,
in large projects (imho) *much* simpler than
vice versa.

Use a _static_ PerlInterpreter*, so your
perl will keep state during whole program run.

>    I much prefer to do the allocation myself,
>    as I know exactly how large my matrix is and as I want to allocate the
>    whole matrix ( say, double 2000 x 2000 ) in one go myself. The reason is
>    that I fear that using perl guts for my calculations (accessing the
>    matrix, calculating values in it etc.) will be not much slower than a
>    simple C implementation. Maybe I am wrong, I haven't tested it.

Perl will be much slower if used trivially so (I can tell
you this). Just use your matrix in C as usual and make
some Into-Perl-Calls if necessary, eg. by pack(...)-ing
your variables into Perl-scalars and unpacking
them again in the perl.

Regards

Mirco


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

Date: Thu, 28 Sep 2006 19:33:41 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Questions about Inline::C
Message-Id: <451b9808$0$22938$afc38c87@news.optusnet.com.au>


"January Weiner" <january.weiner@gmail.com> wrote in message
 .
 .
>    I mean, is there is any danger with malloc() from within Inline::C
>    that is not present in regular C programs

Yes, I believe so - not sure of the details but I think it has something to
do with the possibility that perl has been compiled with its own malloc()
function.
Instead of malloc(), use New(). (See 'perldoc perlapi'.)

There are some *other* C functions that it's best to avoid, too - in favour
of their perl API equivalents. See 'perldoc perlclib'

> 2. When using Inline_Stack to return a list to Perl code, I found that the
>    following throws a segfault:
>
>     Inline_Stack_Reset ;
>     Inline_Stack_Push( sv2_mortal( newSVpv( 'score' ) ) ) ;
>     Inline_Stack_Done ;
>
>   ...while the following does not:
>
>     Inline_Stack_Reset ;
>     Inline_Stack_Push( sv2_mortal( newSVpv( "score" ) ) ) ;
>     Inline_Stack_Done ;
>
>   Should I be worried, or is it normal behaviour? (I tried to look up the
>   definition of Inline_Stack_Push, but I have trouble finding it).
>

In perl you can quote string literals inside either single or double
quotes - but in C you have to use double quotes. Using single quotes will
inevitably result in some sort of error. (I get a segfault, too.)

newSVpv() has to take 2 arguments - see (again) 'perldoc perlapi'.

Cheers,
Rob




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

Date: Thu, 28 Sep 2006 02:44:37 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Reading from standard input
Message-Id: <pGGSg.31700$Lb5.8250@edtnps89>

Michele Dondi wrote:
> (I don't have John's post so I'm replying to you)

That is because I cancelled it when I realised that I was wrong.  :-)


John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: 27 Sep 2006 23:53:02 -0700
From: schwarzenschafe@gmail.com
Subject: Re: Reference to hash value
Message-Id: <1159426382.624049.239990@i42g2000cwa.googlegroups.com>

usenet@DavidFilmer.com wrote:
> I'm not sure I understand your question, but I THINK you are asking how
> you can copy an entire hash structure (ie, "deep" copy), and not just a
> copy of the reference itself (ie, "shallow copy"). If this is your

Yep, that's exactly it, thanks. Funny, I remember reading about deep vs
shallow years ago, but I haven't programmed for so long I'm now
fumbling around like newborn! It's just as much fun to learn the second
time around :)

SS



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

Date: 27 Sep 2006 23:13:35 -0700
From: "mem" <mem.namefix@gmail.com>
Subject: threads not executing @ same time
Message-Id: <1159424015.651397.196860@d34g2000cwd.googlegroups.com>

Hi,

Im new to threading with perl. Im writing an irc bot to fetch rss
headers and post new releases from sites like thepiratebay.org

What happens is when some1 types one of the triggers !help,
!list_filters, !info it creates the thread no probs, but it seems to
work just like a sub.
Ie if another person types another trigger they wont see any info until
the 1st thread finishes.

What I would like to happen is for each thread to start when its
called, any information will be greatly appreciated.

Code below;

# create irc connection in thread

my $thread = threads->create('irc_connect');
$thread->join();

sub irc_connect
{
	print "\n### Connecting to irc server: $server\n\n";

	our $sock = new IO::Socket::INET
	(
		PeerAddr => $server,
		PeerPort => 6667,
	        Proto => 'tcp'
	) or die "!!! Error Couldnt connect to $server\n";

	# Send login informatio

	print $sock "NICK $nick\r\n";
	print $sock "USER $login 8 * :argghhh\r\n";


	# wait for login to be confirmed

	while ($main::input = <$sock>)
	{
		if ($main::input =~ /004/)
		{
			# 004 = login confirmed
			last;
		}
		elsif ($main::input =~ /433/)
		{
			die "Nickname is already in use.";
		}
		elsif ($main::input =~ /^PING \:(.*)$/i)
		{
			# We must respond to PINGs to avoid being disconnected.
			print $sock "PONG $1\r\n";
			print "*** PONG :$1\r\n";
		}
	}

	print "### Connected to $server\n\n";

	# Join the channel.

	#print $sock "JOIN #glug\r\n";

	$i = 0;
	for (@channels)
	{
		$i++;
		print "\n### JOIN $_\r\n";
		print $sock "JOIN $_\r\n";
		$speak_mode{$_} = 1;
		$sum_mode{$_} = 1;
		$rel_mode{$_} = 1;
		$chan_filter{$_} = "$i.filter.txt";
	}


	if(-f $settings_file)
	{
		do $settings_file;
	}

	while ($main::input = <$sock>)
	{	# check irc input and reply as needed
		chop $main::input;

		&main::check_input($main::input);
	}
	exit;
}

# checks irc input and preforms replys

sub check_input {
	my $input = shift;
	chomp $input;

	# show info

	# :JohnSilver!mem@vw-11889.amnet.net.au PRIVMSG #glug :!info

	elsif($input =~ /^\:(.*?)\!.*? PRIVMSG (\#.*?)\s+\:\!info/)
	{
		@arr = ();
		$user = lc $1;

		for $chan(@channels)
		{
			push @arr, "$chan :";
			push @arr, "speak mode = ".$speak_mode{$chan};
			push @arr, "sum mode = ".$sum_mode{$chan};
			push @arr, "rel mode = ".$rel_mode{$chan};
		}

		&speak_arr_thr($user, @arr);
	}
	elsif($input =~ /^\:(.*?)\!.*? PRIVMSG (\#.*?)\s+\:\!help/)
	{
		$user = lc $1;
		&speak_arr_thr($user, @main::help);
	}

	# List filters

	# :JohnSilver!mem@vw-11889.amnet.net.au PRIVMSG #glug :!list_filters

	elsif($input =~ /^\:(.*?)\!.*? PRIVMSG (\#.*?)\s+\:\!list_filters/)
	{
		$i 		= 0;
		@arr 		= ();
		$user		= lc $1;
		$chan 		= lc $2;
		@filters 	= &readf($main::chan_filter{$chan});
		for(@filters)
		{
			$i++;
			push @arr, "$i - $_";
		}
		&speak_arr_thr($user, @arr);
	}
}


# speak arr thr

sub speak_arr_thr
{
	my ($u, @arr) = @_;

	$thread = threads->create(\&speak_arr, $u, @arr);
	$thread->join();
#	yield();
	return;
}

sub speak_arr
{
	my ($chan, @arr) = @_;

	for my $line(@arr)
	{
		print $main::sock "PRIVMSG $chan :$line\r\n";
		print ">>> $nick \@ $chan | $line\n";
	}
}



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

Date: Thu, 28 Sep 2006 08:12:39 +0100
From: Ralph Moritz <rmoritz@quantm.invalid.co.za>
Subject: Re: threads not executing @ same time
Message-Id: <u1wpwxy54.fsf@quantm.invalid.co.za>

"mem" <mem.namefix@gmail.com> writes:

[snip]
> What happens is when some1 types one of the triggers !help,
> !list_filters, !info it creates the thread no probs, but it seems to
> work just like a sub.
> Ie if another person types another trigger they wont see any info until
> the 1st thread finishes.
>
> What I would like to happen is for each thread to start when its
> called, any information will be greatly appreciated.
[snipped code]

I haven't read your code in great detail or even tried to run it. What
caught my eye immediately was that you're joining your threads. When
you call join() on a thread, it causes the current thread to wait for
that thread to finish executing before continuing. If you want them to
run in "parallel" you'll want to use detatch() instead, as in:

  $thread = threads->create(\&speak_arr, $u, @arr);
  $thread->detach();

HTH,
Ralph

-- 
Ralph Moritz
Quantum Solutions       Ph: +27 315 629 557
GPG Public Key: http://ralphm.info/public.gpg


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

Date: 28 Sep 2006 11:41:11 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Uncommon misspelling! [was: "Re: Is LaTeX the tool I'm looking for?"]
Message-Id: <106nh2ptb4eh2gvvokoh981qrsmbtjkf0q@4ax.com>

On 28 Sep 2006 01:22:41 -0700, "Menschenfresser"
<menschenfresser@gmx.net> wrote:

>As you can write Pearl, step 2) should be a piece of cake.

Nooo! "Pearl"... at least one language that does exist, and actually
the one that motivated $larry to drop the "a". Whatever, a rarity
nowadays, since people seem to be so keen on "PERL"...
;-)


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel in sci.math, thread "Why numbers?"


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

Date: Wed, 27 Sep 2006 19:13:32 -0700
From: robic0
Subject: What does Perl/C++/Pornography have in common?
Message-Id: <aa9mh215hskpo6mmldg8v4gcsgurt5q083@4ax.com>

Hi friends,

This may have relavence here as I have seen it recently.

I once watched a porno clip that had a few camera folks filming the same event
but from different directions. Its so sloppily done that the other camera men
get in each others shots (depending on what short your looking at).

This one camera guy in this shot was not filming, his camera (he still had one hand on)
was resting on the ground. He knew the other camera was filming him, he didn't seem to 
care about that, he made no attempt to hide his identity. He made an explicit attempt
to not watch the porn scene, he covered his eyes from the porn not the camera.

At the time, this impressed me more than the blazie porn (just shit porn). It impressed
me he appeared to make a distinct effort to not watch the porn.

My last 3 years dealt with Perl, previously it was c++. I recently started a contract to hire
job ($70/hr) doing heavy Ansi c++ (no sdk, well a little). My original impression of the 
assignment was of course Perl oriented, I was looking at it as if done from Perl. They never
heard of Perl. I kept my mouth shut. When I first started the work I wanted to press the "$"
key all the time. I wanted to use easy concantenation constructs. Nope, didn't work.

I was looking at C++ through the Perl sunglasses. After a week, the multiple years of
c/c++ bubbled back up and I was right as rain Neo. I was doing member functions, ctors/dtors
in structures. The planets were back in alignment.

Conclusion:

I can't look at Perl code now (except for what I've done) in my current job. I turn my eyes away.
It corrupts my current mental code framework. I'm sure I could switch back (maybe) in a few weeks.
Perl is insidous in that it offers a base of C. I'm sure it didn't have to and could have been in
a different syntactic context and still have been as powerfull.

There is no notion of a pointer in Perl, yet the syntax of Perl is so C like. If anything, Perl
is more akin to languages that use typeless VARIANT like constructs, sprinkled with C like
control items. Passing pointers/references(aliases) in C makes the language close to the machine.
Perl is a camelian, neither close to the machine, nor as elegant.

I don't think I could do fairly heavy Perl after a prolonged period of C/C++ and visa versa.
I would have to look away, depending on which mode I were in, and for how long.

Just my observation folks.
Cheers!

robic0

PS> how ya'll been ??



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

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 9778
***************************************


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