[28412] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9776 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 27 14:05:47 2006

Date: Wed, 27 Sep 2006 11:05:06 -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           Wed, 27 Sep 2006     Volume: 10 Number: 9776

Today's topics:
    Re: Battlefield Weapon Popularity Trend (was: Computer  (Chris Mattern)
    Re: Computer Language Popularity Trend <sherm@Sherm-Pendleys-Computer.local>
    Re: Computer Language Popularity Trend <eval.apply@gmail.com>
    Re: Computer Language Popularity Trend <sjdevnull@yahoo.com>
    Re: Computer Language Popularity Trend <stesch@no-spoon.de>
    Re: Computer Language Popularity Trend <jabailo@texeme.com>
    Re: drive externally a tcl interpreter <benmorrow@tiscali.co.uk>
    Re: embedding the 'perl' (newbie) <benmorrow@tiscali.co.uk>
        Free ODBC driver for UNIX neil.shadrach@corryn.com
    Re: glob problem: escaped space seems to be significant (reading news)
    Re: glob problem: escaped space seems to be significant <David.Squire@no.spam.from.here.au>
    Re: How to dynamically generate function name and call  (reading news)
    Re: How to dynamically generate function name and call  <nobull67@gmail.com>
    Re: How to dynamically generate function name and call  <nobull67@gmail.com>
    Re: How to dynamically generate function name and call  <shah@typhoon.xnet.com>
    Re: How to dynamically generate function name and call  <shah@typhoon.xnet.com>
    Re: How to initialize class data? <nobull67@gmail.com>
    Re: list vs. array <benmorrow@tiscali.co.uk>
    Re: Passing object from subroutine problem <mritty@gmail.com>
        Perl Asyn <toddenglish@gmail.com>
    Re: Problem with glob and filenames containing '[' and  anno4000@radom.zrz.tu-berlin.de
    Re: Problem with glob and filenames containing '[' and  <David.Squire@no.spam.from.here.au>
    Re: Spreadsheet::ParseExcel on Windows with out Win32:: <pamelapdh@aol.com>
        using http::recorder <nospam@home.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 27 Sep 2006 17:09:05 -0000
From: syscjm@sumire.eng.sun.com (Chris Mattern)
Subject: Re: Battlefield Weapon Popularity Trend (was: Computer Language Popularity Trend)
Message-Id: <12hlc1hf2amom31@corp.supernews.com>

In article <efd9g0$sn5$1@mlucom4.urz.uni-halle.de>, Mirco Wahab wrote:
>
>When the Samurai of medieval Japan were confronted
>with new 'battlefield language', e.g. early Shotguns,

"early Shotguns" :D.  Your mastery of the history of
firearms overwhelms me.

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: Wed, 27 Sep 2006 12:01:09 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: Computer Language Popularity Trend
Message-Id: <m2lko5wb7e.fsf@Sherm-Pendleys-Computer.local>

"mark.hoemmen@gmail.com" <mark.hoemmen@gmail.com> writes:

> Xah Lee wrote:
>> Computer Language Popularity Trend
>>
>
> Careful there with the sweeping generalizations and quick judgments

Such things are all Xah does. Look at the distribution list for this
message - of what possible use is cross-posting something like this to
five different language groups, unless you're trying to start a cross-
group argument?

In short - Please don't feed the trolls.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: 27 Sep 2006 09:26:45 -0700
From: "Joe Marshall" <eval.apply@gmail.com>
Subject: Re: Computer Language Popularity Trend
Message-Id: <1159374405.239644.192750@m7g2000cwm.googlegroups.com>


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. This is not a
> comprehensive or fair survey, but does give some indications of
> popularity trends.

Suggestions:
  Provide a log-scale plot.  You can clearly see that there are
exponential trends in the data, these will turn into lines in
log-scale.  You can also see that the plots get more widely distributed
as the number of posts increase.  This too will be minimized in
log-scale.

  Make the horizontal scale for the `scripting' languages the same as
the others.  I know there isn't data out on the left of the graph, but
it surprised me to see points out there until I noticed the scale
change.

  For the Google trends, try looking for `java programming' or `written
in python' to avoid picking up the island and the popular comedy troupe.



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

Date: 27 Sep 2006 09:51:16 -0700
From: "sjdevnull@yahoo.com" <sjdevnull@yahoo.com>
Subject: Re: Computer Language Popularity Trend
Message-Id: <1159375876.352551.22600@m7g2000cwm.googlegroups.com>

cartercc@gmail.com wrote:
> You can also get a rough measure ot the popularity of web scripting
> languages from an analysis of the URLs. The last time I did this was in
> 2003, and as I recall, these were the results:
> PHP 30% and increasing
> Perl 28% and falling
> ASP 25% and falling fast
> ColdFusion 6% and steady
> Java and JSP 5% and increasing
> others, Python, Ruby, ...

At the site I'm working on, you'd see a URL like
http://www.whatever.com/login or http://www.whatever.com/boards?id=131
-- how would you count them?  Such (extensionless) URLs are far more
common in the Python, Ruby, and Java world in my experience than the
PHP, Perl, and ASP world, so my first instinct looking at your numbers
is to believe they're just biased toward languages that more often put
the extension in the URL.



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

Date: Wed, 27 Sep 2006 19:18:35 +0200
From: Stefan Scholl <stesch@no-spoon.de>
Subject: Re: Computer Language Popularity Trend
Message-Id: <0T3gh0itI5f2Nv8%stesch@parsec.no-spoon.de>

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! :-)


-- 
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/


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

Date: Wed, 27 Sep 2006 10:54:24 -0700
From: John Bailo <jabailo@texeme.com>
Subject: Re: Computer Language Popularity Trend
Message-Id: <L_KdncN7ErRSJ4fYnZ2dnUVZ_sadnZ2d@speakeasy.net>

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.




-- 
Texeme Construct


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

Date: Tue, 26 Sep 2006 22:33:36 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: drive externally a tcl interpreter
Message-Id: <guiou3-6bd.ln1@osiris.mauzo.dyndns.org>


Quoth "Filippo" <filippo2991@virgilio.it>:
> 
> I have a simulation tool (cadence) with TCL interpreter embedded to
> control the simulation. Is it possible to write a Perl script that
> control the TCL interpreter? I want to write commands to tcl
> interpreter in order to be able to control the simulation with an
> external Perl program.

I don't entirely understand what you want, but you may find the Expect
module on CPAN helpful. If not, you will have to tell us a little more
about how commands get fed to the TCL interpreter, and how any output
gets back out.

Ben

-- 
For far more marvellous is the truth than any artists of the past imagined!
Why do the poets of the present not speak of it? What men are poets who can
speak of Jupiter if he were like a man, but if he is an immense spinning
sphere of methane and ammonia must be silent?~Feynmann~benmorrow@tiscali.co.uk


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

Date: Tue, 26 Sep 2006 22:30:44 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: embedding the 'perl' (newbie)
Message-Id: <4piou3-6bd.ln1@osiris.mauzo.dyndns.org>


Quoth Mirco Wahab <peace.is.our.profession@gmx.de>:
> Hi folks,
> 
> after fiddling around with some C++-to-perl
> calls and evals (perldoc perlembed), I'm
> not sure what to do now.
> 
> Maybe I'm linking the app w/perl by the options
> provided by `perl -MExtUtils::Embed -e perl_inc`
> and `perl -MExtUtils::Embed -e ldopts -- -std`.

That would be the correct answer.

> The default Perl-Build creates libperl.so as a
> "default", would it then be sufficient(?), to
> pull the libperl.a by simply stating:
> 
>   /usr/lib/perl/5.8.8/arch/CORE #  ar r libperl.a `ls *.so`
> 
> out of the installed local Perl system to get
> a functional static library?

Did you try it? As a general rule, you can't convert a shared into a
static library.

However, my system has a /usr/lib/perl5/5.8.8/i686-linux/CORE/libperl.a,
which is a library for linking statically. Whether 
    gcc foo.o -L/.../CORE -lperl
links libperl.a or libperl.so is controlled by the -static option; if
you are using some other compiler I'm sure it supports the same
functionality.

If you don't have a libperl.a you can get one by compiling perl
yourself.

> What "standard" modules would then be available
> to the app when linking  with "ldopts -- -std"?

Do you mean

    Perl modules?
        None. You would need to install them on the target system in
        some place the embedded perl could find them. You can change
        where it looks e.g. by providing a -I arg to perl_run.

    Dynamic extensions?
        None. See above. Note that you will need to install *all* of the
        extension: the .so, the .pm, and the .bs, in the appropriate
        places; maybe other stuff as well. The safest way is to have a
        real Perl install on the target (of the correct version) and
        install the extension properly using that; if that is
        undesirable, you can look at what the extension creates when you
        install it by hand and package that up in some way.

    Statically linked extensions?
        Typically just Dynaloader. If you want to link other extensions
        statically, you can, but you will need to rebuild perl: see the
        perl installation instructions for what to do. Note that you
        will *still* need the appropriate .pm files installed.

You may be able to use PAR to work around some of these problems; or you
may be able to find some custom workaround. An obvious evil hack would
be to 

    a. Link all the extensions you need statically.
    b. Convert all the .pms into C source files which define a string
       constant containing the contents of the .pm.
    c. Write a little C function to feed these through perl at the
       appropriate time.
    d. Compile it all up and link it statically.

A less evil hack would be to implement some form of custom loader,
probably starting by gutting PAR.

Ben

-- 
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
                                                        benmorrow@tiscali.co.uk


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

Date: 27 Sep 2006 08:18:09 -0700
From: neil.shadrach@corryn.com
Subject: Free ODBC driver for UNIX
Message-Id: <1159370288.978470.254750@d34g2000cwd.googlegroups.com>

Can anyone recommend a free ODBC driver for use with DBI::ODBC?
I have a trial licence from one of the recommended sources on the CPAN
page but I'd like to try a completely free alternative.



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

Date: Wed, 27 Sep 2006 15:52:20 GMT
From: "Mumia W. (reading news)" <paduille.4058.mumia.w@earthlink.net>
Subject: Re: glob problem: escaped space seems to be significant too (was Re: Problem with glob and filenames containing '[' and ']')
Message-Id: <U6xSg.3174$o71.351@newsread3.news.pas.earthlink.net>

On 09/27/2006 08:43 AM, David Squire wrote:
> David Squire wrote:
>> Hi folks,
>>
>> I'm having trouble using glob to find filenames that contain '[' and
>> ']', even though I am escaping those meta-characters. Here is an example
>> script and output:
> 
> Hi again,
> 
> I have reduced this further, getting rid of de-url and a bunch of other
> stuff related to my original context. Please see the reduced script and
> output below. It seems that having an escaped space as well as an escape
> '[' causes the failure to match. See the third last test case.
> 
> I hesitate to say it, but this begins to feel like a bug... (covers head).
> 
> ----
> 
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> print "Directory contents:\n", `ls -1 f*`, "\n";
> for my $GlobPattern (
>     'fred*',
>     'fred[1]*',
>     'fred\[1\]*',
>     'fred\[1]*',
>     'fred[1\]*',
>     'fre\ d*',
>     'fre\ d\[*',
>     'fre\ d\[1*',
>     'fre\ d\[1\]*',
>     'fre?d\[1\]*',
>     'fre\ d?1\]*',
> ) {
>     my @CandidateOrigFiles = glob ($GlobPattern);
>     print "\n######################################\n";
>     print "$GlobPattern: \@CandidateOrigFiles:\n", join "\n",
> @CandidateOrigFiles;
> }
> 
> ----
> 
> Output:
> 
> Directory contents:
> fred]
> fred[1]
> fre d[1].doc
> fred[[1].doc
> fred[1].doc
> 
> 
> ######################################
> fred*: @CandidateOrigFiles:
> fred[1]
> fred[1].doc
> fred[[1].doc
> fred]

Correct

> ######################################
> fred[1]*: @CandidateOrigFiles:
> 

Correct. This would match "fred1" or "fred19" because the unescaped [] 
pair creates a character class (globbing-style).


> ######################################
> fred\[1\]*: @CandidateOrigFiles:
> fred[1]
> fred[1].doc

Correct

> ######################################
> fred\[1]*: @CandidateOrigFiles:
> fred[1]
> fred[1].doc

I think this is correct, but I'm not sure.

> ######################################
> fred[1\]*: @CandidateOrigFiles:
> fred[1]
> fred[1].doc

What? That doesn't look right to me. The "[" should start a character class.


> ######################################
> fre\ d*: @CandidateOrigFiles:
> fre d[1].doc

Correct

> ######################################
> fre\ d\[*: @CandidateOrigFiles:
> fre d[1].doc

Correct

> ######################################
> fre\ d\[1*: @CandidateOrigFiles:
> fre d[1].doc

Correct

> ######################################
> fre\ d\[1\]*: @CandidateOrigFiles:
> 

Hmm, "fre d[1].doc" should appear.

> ######################################
> fre?d\[1\]*: @CandidateOrigFiles:
> fre d[1].doc

Correct

> ######################################
> fre\ d?1\]*: @CandidateOrigFiles:
> fre d[1].doc
> 

Correct

> ----
> 
> DS

Clearly, an escaped space does not cause the problem. It has something 
to do with both an escaped space and an escaped bracket.

-- 
paduille.4058.mumia.w@earthlink.net


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

Date: Wed, 27 Sep 2006 17:12:45 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: glob problem: escaped space seems to be significant too (was Re: Problem with glob and filenames containing '[' and ']')
Message-Id: <efe7tt$loe$1@gemini.csx.cam.ac.uk>

Mumia W. (reading news) wrote:

> 
> Clearly, an escaped space does not cause the problem. It has something
> to do with both an escaped space and an escaped bracket.

Yes, that's what "too" means in the subject line :) It is the
combination that is the problem.

DS


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

Date: Wed, 27 Sep 2006 15:52:18 GMT
From: "Mumia W. (reading news)" <paduille.4058.mumia.w@earthlink.net>
Subject: Re: How to dynamically generate function name and call it?
Message-Id: <S6xSg.3171$o71.396@newsread3.news.pas.earthlink.net>

On 09/27/2006 08:31 AM, 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.
> 

Use a hash, e.g.:
my %tabledispatch = (
	TRAC => \CreateTRACTable,
	TRCO => \CreateTRCOTable,
);

 ...
$tabledispatch{$Action}->();


UNTESTED CODE

-- 
paduille.4058.mumia.w@earthlink.net


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

Date: 27 Sep 2006 09:52:41 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: How to dynamically generate function name and call it?
Message-Id: <1159375961.389664.259370@m73g2000cwd.googlegroups.com>

Tad McClellan wrote:

>    my %actions = (    # a "dispatch table", untested
>       TRAC => \&CreateTRACTable,
>       TRCO => \&CreateTRCOTable
>    );

There are two entries in that hash. A soon as you add another one
you'll hit the rule-of-3. You'll be manually doing the same thing three
times in succession. In programming this is generally a sign that you
are doing it wrong.  This is no exception.  You probably should be
going down the symbolic references path. There are a lot of reasons not
to use symbolic references in a lot of contexts. This leads some
people, most vocally Tad, to say they are always a bad thing.  And
indeed I'll admit that in some purist sense they are always a bad
thing. But in this case they are not as bad as breaking the rule-of-3
(IMNSHO).



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

Date: 27 Sep 2006 09:58:41 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: How to dynamically generate function name and call it?
Message-Id: <1159376321.628890.299260@e3g2000cwe.googlegroups.com>


Robert 'phaylon' Sedlacek wrote:

>     *{'Create' . $TableName . 'Table'}->(@arguments);

Or, more simply:

     "Create${TableName}Table"->(@arguments);

Note: If you were creating a module, say My::FreakyModule, then I'd
suggest separating all your subroutines that are accessed by symref
into separate namespaces:

     "My::FreakyModule::Tables::${TableName}::Create"->(@arguments);



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

Date: Wed, 27 Sep 2006 18:02:45 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: How to dynamically generate function name and call it?
Message-Id: <efeec5$chj$1@new7.xnet.com>

While stranded on information super highway Tad McClellan wrote:
> Hemant Shah <shah@typhoon.xnet.com> wrote:
> 
>>   How do I dynamically generate function and then execute the function?
> 
> 
> By implementing a "dispatch table", usually a hash where the values
> are all CODE references.

 Thanks. That's what I was looking for.

> 
> 
>>   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. 
> 
> 
>>   How do I do this?
> 
> 
>    my %actions = (    # a "dispatch table", untested
>       TRAC => \&CreateTRACTable,
>       TRCO => \&CreateTRCOTable
>    );
> 
>    ...
> 
>    die "don't know what action to take for '$TableName'\n"
>       unless exists $actions{ $TableName };
> 
>    $actions{ $TableName }->();  # call the appropriate function
> 
> 
> -- 
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas

-- 
Hemant Shah                           /"\  ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
                                       X     against HTML mail
TO REPLY, REMOVE NoJunkMail           / \      and postings      
FROM MY E-MAIL ADDRESS.           
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind,                Above opinions are mine only.
it's backed up on tape somewhere.      Others can have their own.


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

Date: Wed, 27 Sep 2006 18:05:00 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: How to dynamically generate function name and call it?
Message-Id: <efeegc$chj$2@new7.xnet.com>

While stranded on information super highway Brian McCauley wrote:
> 
> Robert 'phaylon' Sedlacek wrote:
> 
>>     *{'Create' . $TableName . 'Table'}->(@arguments);
> 
> Or, more simply:
> 
>      "Create${TableName}Table"->(@arguments);

 Thanks.

> 
> Note: If you were creating a module, say My::FreakyModule, then I'd
> suggest separating all your subroutines that are accessed by symref
> into separate namespaces:
> 
>      "My::FreakyModule::Tables::${TableName}::Create"->(@arguments);
> 

-- 
Hemant Shah                           /"\  ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
                                       X     against HTML mail
TO REPLY, REMOVE NoJunkMail           / \      and postings      
FROM MY E-MAIL ADDRESS.           
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind,                Above opinions are mine only.
it's backed up on tape somewhere.      Others can have their own.


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

Date: 27 Sep 2006 09:41:58 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: How to initialize class data?
Message-Id: <1159375318.783065.323050@i42g2000cwa.googlegroups.com>


Ralph Moritz wrote:
> Hi,
>
> I've got some class data which I want to initialize once.
> I was thinking of doing it like this:
>
> { package Foo;
>
>   my $FirstTime = 1;
>
>   sub new {
>     my $class = shift;
>     my $self = {};
>     bless $self, $class;
>     $class->init() if ($FirstTime);
>   }
>
>   sub init {
>     # Initialize class data...
>     $FirstTime = 0;
>   }
> }
>
> Is this okay, or is there a generally accepted way
> to do this?

The canonical way would be an INIT block.

Or sometimes you'll see people just not put the code in a subroutine at
all.

But both of these will make the initialization code be called even if
Foo is never instanciated.

If you really want to defer until the first object is instanciated then
what you are doing is approximately correct. However you should not be
calling $class->init() you should call Foo->init() or simply init().
With your code if the first Foo object that's instanciated happens to
be a of a subclass you'll call init() in that subclass.

Oh and it's probably more ideomatic to reverse the sense of your flag.

my $initialized;

sub init {
       $initialized++; # Slower than =1 but the more common idiom
       # etc...
}

sub new {
       init unless $initialized;
       my $class = shift;
       my $self = bless {}, $class;
       # etc...
}



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

Date: Tue, 26 Sep 2006 21:58:43 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: list vs. array
Message-Id: <3tgou3-cg3.ln1@osiris.mauzo.dyndns.org>


Quoth "robb@acm.org" <robb@acm.org>:
> 
> Tad McClellan wrote:
> >
> > An array is on the heap, and a list is on the stack. (that sounds familiar...)
> >
> 
> Thanks - I hadn't seen it expressed this concisely up till now.
> 
> Is it advisable to think about these issues and consider them when
> actually doing programming?
> 
> For example, when I work with lists and arrays, I usually focus on
> issues such as do I want to be manipulating arrays or arrayrefs...
> Which do I want to be using in my APIs, etc.

However, it is important to realize that you cannot pass an array to a
function, in Perl. You can expand the array into a list of its elements,
and pass that, or you can take a ref to the array and pass that: which
you choose makes quite a difference.

Ben

-- 
I have two words that are going to make all your troubles go away.
"Miniature". "Golf".
                                                  [benmorrow@tiscali.co.uk]


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

Date: 27 Sep 2006 10:15:39 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Passing object from subroutine problem
Message-Id: <1159377339.697683.90720@m73g2000cwd.googlegroups.com>

Tad McClellan wrote:
> Paul Lalli <mritty@gmail.com> wrote:
> > tim wrote:
>
> >> #takes an active db handle, returns a new session object.
> >> sub newSession {
> >>     my $dbh = @_[1];
> >
> > Always always always use warnings when devleoping Perl code.  This
> > should have told you:
> > Scalar value @_[1] better written as $_[1]
>
>
> And that accesses the 2nd argument. What about the 1st argument?
>
>    my $dbh = $_[0];

newSession is a class method, so the first argument is the name of the
class.  The argument that the user passed into the method is indeed the
2nd argument within the method.

Paul Lalli



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

Date: 27 Sep 2006 08:41:01 -0700
From: "Todd  English" <toddenglish@gmail.com>
Subject: Perl Asyn
Message-Id: <1159371661.107183.102230@m73g2000cwd.googlegroups.com>

<cross posting to these two groups as posting to comp.lang.perl.modules
has failed to result in a response>

Group,

I work for a company as security developer and have recently been asked
to streamline our build process. The build process is driven by a
single machine which connects to all the build hosts and builds our
products.

The driver was written in Perl and does all of this sequentially. I
found the Async Perl package from Google (perl+async) and tried to use
it to optimize our process so that building would only take as long as
the slowest platform.

Here is where things get interesting. I implemented everything, and
started seeing that the proc result was blank for allot of our build
results. I'm very new to Perl (as in this is my 4th day using it) so I
broke out a simple program to reproduce the results. Originally, for
the long computation, I was sleeping (as per the example) and the
example worked just fine. I figured it must be my problem and spent a
couple more days learning Perl. I just happened to run the test program
once more today and noticed that one platform didn't respond. So,
instead of sleeping I did something a little more random (as far as
when the function will return) and boom, it happens all the time now.

I would be very willing to help explore this problem, test patches or
even the async fix code (which I tried, unsuccessfully), but I will
need a little direction to do this. Perhaps I am using the package
incorrectly and someone could point out my mistake?

Any help would be appreciated. Thank you for taking the time to read
this,

Todd English

-----------Sample Code------------

#!/usr/bin/perl -w

use Async;

sub long_running_computation {
     # This function simulates a computation that takes a long time to
run
     my ($name, $host) = @_;
     system qq{find ./ -type f 2>&1 >/dev/null};
# if we sleep instead of do something more unpredictable, then works
most of the time
#     sleep 10;
     return "$name $host has Failed";
  }

my %host =
(
    'rhel3-ia32' =>     'gray',
    'rhel4-ia32' =>	'x.x.x.x',
    'sles9-ia32' =>	'y.y.y.y',
    'sles10-ia32' =>	'maroon',
    'rhel3-x64' =>	'white',
    'rhel4-x64' =>	'ivory',
    'sles9-x64' =>	'skyblue',
    'sles10-x64' =>	'orange',
    'rhel3-ia64' =>	'chartreuse',
    'rhel4-ia64' =>	'cyan',
    'sles9-ia64' =>	'goldenrod',
    'rhel4-s390' => 	'rh4as',
    'sles9-s390' =>  	'mambo',
    'sol10-x64' =>	'brown',
    'sol10-sparc' =>	'green',
    'sol8-sparc'  =>    'blue',
    'sol7-sparc' =>	'red',
    'sol9-sparc' =>	'black',
    'hpux-parisc' =>	'purple',
    'hpux11-ia64' =>    'yellow'
);

my %proc_result;
my %build_result;

while (my ($name, $host) = each %host)
{
    $proc_result{$name} = Async->new(sub{ long_running_computation
($name, $host) } );
}

# This doesn't work
#while ( (my $name, $proc) = each %proc_result)
#{
#    $build_result{$name} = $proc->result('1');
#}

#neither does this
while( 0 < scalar(keys %proc_result) )
{
    my @host_list_to_delete;
    while( ($name) = each %proc_result)
    {
        print "checking if $name is ready\n";
        if($proc_result{$name}->ready)
        {
            my $error;
            if($error = $proc_result{$name}->error)
            {
#$build_result{$name} = $error;
                $build_result{$name} = "Async indicates a failure error
occured: $error !";
            }
            else
            {
                $build_result{$name} = $proc_result{$name}->result;
            }
            push(@host_list_to_delete, $name);

            undef $proc_result{$name}; #not sure why this is here, but
is was in the sample docs
        }
    }

    foreach my $item (@host_list_to_delete)
    {
        delete ( $proc_result{$item} );
    }

    sleep 10;
}

print "done with long running computation\n";
while (my($host_name, $result) = each %build_result)
{
    printf "%s\t%s\n", $host{$host_name}, $result;
}



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

Date: 27 Sep 2006 17:33:12 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Problem with glob and filenames containing '[' and ']'
Message-Id: <4nvqunFccl6aU1@news.dfncis.de>

David Squire  <David.Squire@no.spam.from.here.au> wrote in comp.lang.perl.misc:
> anno4000@radom.zrz.tu-berlin.de wrote:
> > David Squire  <David.Squire@no.spam.from.here.au> wrote in
> comp.lang.perl.misc:
> >> Hi folks,
> >>
> >> I'm having trouble using glob to find filenames that contain '[' and
> >> ']', even though I am escaping those meta-characters. Here is an example
> >> script and output:
> > 
> > I don't know what goes wrong for you.  It works for me as expected
> > (after replacing /damocles/documents/ENH1260/2006/2/Short assignment/
> > with something that exists on my box).
> 
> Thanks. Would you be able to try my second, simpler, example too? That
> seems to narrow down the oddness.

Well yes, it's the blank in the path name that does it.  Here is the
relevant bit from File::Glob, which implements CORE::glob():

       Since v5.6.0, Perl's CORE::glob() is implemented in terms of
       bsd_glob().  Note that they don't share the same proto-
       type--CORE::glob() only accepts a single argument.  Due to historical
       reasons, CORE::glob() will also split its argument on whitespace,
       treating it as multiple patterns, whereas bsd_glob() considers them as
       one pattern.

So it's not a bug.  The solution would be to use File::Glob::bsd_glob()
directly.

Anno


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

Date: Wed, 27 Sep 2006 19:02:58 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Problem with glob and filenames containing '[' and ']'
Message-Id: <efeeci$5d0$1@gemini.csx.cam.ac.uk>

anno4000@radom.zrz.tu-berlin.de wrote:
> David Squire  <David.Squire@no.spam.from.here.au> wrote in comp.lang.perl.misc:
>> anno4000@radom.zrz.tu-berlin.de wrote:
>>> David Squire  <David.Squire@no.spam.from.here.au> wrote in
>> comp.lang.perl.misc:
>>>> Hi folks,
>>>>
>>>> I'm having trouble using glob to find filenames that contain '[' and
>>>> ']', even though I am escaping those meta-characters. Here is an example
>>>> script and output:
>>> I don't know what goes wrong for you.  It works for me as expected
>>> (after replacing /damocles/documents/ENH1260/2006/2/Short assignment/
>>> with something that exists on my box).
>> Thanks. Would you be able to try my second, simpler, example too? That
>> seems to narrow down the oddness.
> 
> Well yes, it's the blank in the path name that does it.  Here is the
> relevant bit from File::Glob, which implements CORE::glob():
> 
>        Since v5.6.0, Perl's CORE::glob() is implemented in terms of
>        bsd_glob().  Note that they don't share the same proto-
>        type--CORE::glob() only accepts a single argument.  Due to historical
>        reasons, CORE::glob() will also split its argument on whitespace,
>        treating it as multiple patterns, whereas bsd_glob() considers them as
>        one pattern.
> 
> So it's not a bug.  The solution would be to use File::Glob::bsd_glob()
> directly.

Thanks for drawing my attention to this. Very non-intuitive and 
non-shell-like, despite what perldoc -f glob says.

I am also puzzled that quite a few of my test cases (in my second post 
with example code) including escaped blanks worked exactly as I would 
have expected. For example (from that post), with files present:

fred]
fred[1]
fre d[1].doc
fred[[1].doc
fred[1].doc

I get, in one case:

######################################
fre\ d*: @CandidateOrigFiles:
fre d[1].doc

I can't see how that would happen if the parts of the pattern on each 
side of the blank were treated as separately - but would be glad to be 
enlightened.

The much larger script from which this is distilled, also worked as I 
expected in almost all cases. I have thousands of cases, all with a 
blank in the path, where there is no problem. It only arises in 
combination with \[ and \] (and some of those files have other escaped 
characters).

I have now written a work-around using opendir/readdir, but still find 
this odd.



DS


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

Date: 27 Sep 2006 09:56:22 -0700
From: "Pam" <pamelapdh@aol.com>
Subject: Re: Spreadsheet::ParseExcel on Windows with out Win32::OLE
Message-Id: <1159376182.338656.90660@i42g2000cwa.googlegroups.com>



Mumia W. (reading news) wrote:
> On 09/26/2006 06:11 PM, Pam wrote:
> > Mumia W. (reading news) wrote:
> >> On 09/26/2006 04:34 PM, Pam wrote:
> >>> Hello:
> >>>
> >>> I was wondering if anyone knew if it was possible to Parse a file in
> >>> the Windows
> >>> enviroment without using the Win32::OLE?  Most of the sample code I see
> >>> is either
> >>> writen for UNIX/Linux or Win32:OLE.  Currently I have a Perl script
> >>> running on Unix
> >>> on a cron job that works fine and I wrote it in the Windows enviroment
> >>> but used the
> >>> Spreadsheet:WriteExcel module and other modules which also works in the
> >>> UNIX enviroment.  Now I am trying to add more code that will parse the
> >>> file for a value. But I am having the hardest time I work in the
> >>> Windows enviroment and the code is put on UNIX by another group so
> >>> right now I don't have access to UNIX so my code must be written in
> >>> Windows.  Since previous code was writen using Spreadsheet::WriteExcel,
> >>> OLE dosen't seem to work with existing code because one writes to a
> >>> sheet and Win32::OLE uses Workbook at least that is my conclusion from
> >>> all of my efforts in trying to get my code working.  I am trying to
> >>> parse an existing spreadsheet with
> >>>
> >>> $oBook = Spreadsheet::ParseExcel::Workbook->Parse($original_file)
> >>>
> >>> Am I correct in my conclusions? If anyone can answer this I would
> >>> greatly appreciate it.
> >>>
> >>>
> >>> Pam
> >>>
> >> You are correct. Win32::OLE most probably won't work with code written
> >> for Spreadsheet::{Parse,Write}Excel.
> >>
> >> --
> >> paduille.4058.mumia.w@earthlink.net
> >
> >
> > Hi
> >
> > Do you know if Spreadsheet::ParseExcel can work on Windows without
> > using
> > Win32::OLE?
> >
> >
> > Pam
> >
>
> I've had no experience with Spreadsheet::ParseExcel outside of Linux.
> However, there is a 99% + 1% chance that Spreadsheet::ParseExcel has no
> dependency upon Win32::OLE since Win32::OLE only works under Windows,
> and Spreadsheet::ParseExcel doesn't only work under Windows.
>
> Try it for yourself. See if you can write a perl script that uses
> Spreadsheet::ParseExcel and not Win32::OLE to parse an Excel file.
>
>
> --
> paduille.4058.mumia.w@earthlink.net


Hello:

My original question stated the I was trying to parse an existing Excel
file and all of the exmples I have seem to  specify using on Win32:OLE
for Windows or  Spreadsheet_ParseExcel on UNIX/Linux.

I'm not saying that SpreadSheet::ParseExcel has to be used with
Win32::OLE.
I'm saying that when I have looked for sample code it points me to
Win32:OLE for parsing  in Windows enviorment.

But I want to use code that will work on Windows or UNIX because the
script will be put on UNIX for the cron job.

I have tried and tried and I can't get the Spreadsheet::ParseExcel to
work in my Windows enviroment.  My original script gets its nformation
from a database, that coma seperated data is parsed using Text:CSV  I
create a workbook using  Spreadsheet::WriteExcel to  put that data into
a sheet  and also to do other formating to that spreadsheet.  So now I
want to parse that same spreadsheet to see  if a cell is defined or
undef.


I can't get Spreadsheet::ParseExcel to work in my Windows enviroment.
Can someone/anyone point me to some sample code that uses
Spreadsheet:Parse excel in Windows enviroment.



Thank You All,
Pamela



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

Date: Wed, 27 Sep 2006 15:29:55 GMT
From: "Nospam" <nospam@home.com>
Subject: using http::recorder
Message-Id: <TNwSg.14004$2g5.3559@newsfe7-win.ntli.net>

My apologies for my newbie question, but I am looking at http::recorder, and
the readme guide says this:

my $proxy = HTTP::Proxy->new;
    # set HTTP::Recorder as the agent
    my $agent = HTTP::Recorder->new( file => "/tmp/tmpfile" );
    $proxy->agent( $agent );
    $proxy->start();

I am wondering if I place the proxy in:
$proxy->start('proxy:port');
?

I am also looking at using selenium with javascript to follow a link that is
a javascript link where the text regex is:

follow_link( text_regex => qr/Articles/i );

Anyhelp will be greatly appreciated




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

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


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