[31452] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2704 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 3 11:09:43 2009

Date: Thu, 3 Dec 2009 08:09:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 3 Dec 2009     Volume: 11 Number: 2704

Today's topics:
    Re: DLL unload question for embedded Perl on Windows <u8526505@gmail.com>
    Re: DLL unload question for embedded Perl on Windows <ben@morrow.me.uk>
    Re: FAQ 3.4 How do I find which modules are installed o <jimsgibson@gmail.com>
    Re: FAQ 3.4 How do I find which modules are installed o <justin.0911@purestblue.com>
    Re: FAQ 6.20 What good is "\G" in a regular expression? <marc.girod@gmail.com>
    Re: FAQ 6.20 What good is "\G" in a regular expression? <marc.girod@gmail.com>
    Re: FAQ 6.20 What good is "\G" in a regular expression? <brian.d.foy@gmail.com>
    Re: Good Golly Miss Molly Perl. Been so long. <cwilbur@chromatico.net>
    Re: i18n? <ams@sister.ludd.ltu.se>
    Re: i18n? <ams@sister.ludd.ltu.se>
        Join every two lines of a file <nickli2000@gmail.com>
    Re: Join every two lines of a file <josef.moellers@ts.fujitsu.com>
        perl compilers <robin1@cnsp.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 3 Dec 2009 03:07:31 -0800 (PST)
From: cyl <u8526505@gmail.com>
Subject: Re: DLL unload question for embedded Perl on Windows
Message-Id: <b39f9796-0c2b-4476-be7b-5cd388d84b80@15g2000prz.googlegroups.com>

I got my problems fixed by building my own Perl even though I prefer
to use ActivePerl. Anyway it works for now. Since I need to use a DLL
to run the Perl interpreter, I don't have the arg/argv/env arguments.
However it still works with NULL passed. Not sure if there's any
potential risks. It works fine so far. As for unloading DLL problem, I
add a compiler flag DL_UNLOAD_ALL_AT_EXIT and Perl interpreter will
unload all DLLs after perl_destruct or perl_free (sorry I forgot it).
Thanks for all the valuable information. For a layman of Perl guts,
all the information mentioned help me a lot.


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

Date: Thu, 3 Dec 2009 13:51:50 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: DLL unload question for embedded Perl on Windows
Message-Id: <mcsku6-ik11.ln1@osiris.mauzo.dyndns.org>


Quoth cyl <u8526505@gmail.com>:
> I got my problems fixed by building my own Perl even though I prefer
> to use ActivePerl. Anyway it works for now. Since I need to use a DLL
> to run the Perl interpreter, I don't have the arg/argv/env arguments.
> However it still works with NULL passed. Not sure if there's any
> potential risks. It works fine so far. As for unloading DLL problem, I
> add a compiler flag DL_UNLOAD_ALL_AT_EXIT and Perl interpreter will
> unload all DLLs after perl_destruct or perl_free (sorry I forgot it).
> Thanks for all the valuable information. For a layman of Perl guts,
> all the information mentioned help me a lot.

Ilya is right, though, that perl extensions are not designed to be
unloaded (since DL_UNLOAD_ALL isn't normally defined). You are likely to
get memory and other resource leaks from unloading and reloading
extensions that statically allocate resources.

Ben



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

Date: Wed, 02 Dec 2009 16:14:40 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: FAQ 3.4 How do I find which modules are installed on my system?
Message-Id: <021220091614404670%jimsgibson@gmail.com>

In article <021220091558221403%brian.d.foy@gmail.com>, brian d foy
<brian.d.foy@gmail.com> wrote:

> [[ This message was both posted and mailed: see
>    the "To," "Cc," and "Newsgroups" headers for details. ]]
> 
> In article <011220090949292601%jimsgibson@gmail.com>, Jim Gibson
> <jimsgibson@gmail.com> wrote:
> 
> > In article <011220091115380337%brian.d.foy@gmail.com>, brian d foy
> > <brian.d.foy@gmail.com> wrote:
> 
> 
> > > > >     From the command line, you can use the "cpan" command's "-l"
> > > > >     switch:
> > > > >
> > > > >             $ cpan -l
> 
> 
> > > Use the latest version of cpan. :)
> > 
> > I get the same thing using CPAN 1.9402 with Perl 5.10.1 under Mac OS
> > 10.6.2 :(
> 
> That's a pretty old version of cpan(1). Get the latest one. It's either
> the cpan-script distro, or the new App::Cpan packaging.

Huh? CPAN.pm 1.9402 is the latest version on search.cpan.org. Does a
new version of the cpan script get installed when CPAN.pm is installed?
I always thought the cpan script was equivalent to 'perl -MCPAN -e
shell' but easier to type. Is that not the case?

My current cpan script couldn't install App::Cpan:

  cpan[1]> install App::Cpan
  ...
  Warning: Cannot install App::Cpan, don't know what it is.

However, I was able to download App-Cpan-1.56_15.tar.gz from cpan and
install it manually.

Now, 'sudo cpan -l' generates 9057 lines of output on my Mac, with
numerous lines of errors:

Useless use of a constant in void context at (eval 586) line 6, <FILE>
line 75.
Useless use of a variable in void context at (eval 586) line 6, <FILE>
line 75.
Use of uninitialized value $Tk::Pod::VERSION in numeric ge (>=) at (eval
586) line 6, <FILE> line 75.

etc.

-- 
Jim Gibson


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

Date: Thu, 03 Dec 2009 11:56:49 -0000
From: Justin C <justin.0911@purestblue.com>
Subject: Re: FAQ 3.4 How do I find which modules are installed on my system?
Message-Id: <690d.4b17a781.9cb4b@zem>

On 2009-12-02, brian d foy <brian.d.foy@gmail.com> wrote:
> In article <481a.4b1630e9.bf119@zem>, Justin C
><justin.0911@purestblue.com> wrote:
>
>
>> zem:~# cpan -v
>> /usr/local/bin/cpan script version 1.9, CPAN.pm version 1.9402
>> 
>> Is the mirror I'm using out of date? What is the latest version number?
>
> It's the cpan-script or App::Cpan module.  The one that comes with
> CPAN.pm is old.

OK, thanks, I'll look into that.

	Justin.

-- 
Justin C, by the sea.


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

Date: Thu, 3 Dec 2009 01:47:12 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: FAQ 6.20 What good is "\G" in a regular expression?
Message-Id: <939df6b5-0c45-4adf-bf8b-9566c1cc5ef9@o10g2000yqa.googlegroups.com>

On Dec 2, 11:00=A0am, PerlFAQ Server <br...@theperlreview.com> wrote:

> =A0 =A0 If you use the "\G" anchor, you force the match after 22 to start=
 with
> =A0 =A0 the "a". The regular expression cannot match there since it does =
not
> =A0 =A0 find a digit, so the next match fails and the match operator retu=
rns the
> =A0 =A0 pairs it already found.
>
> =A0 =A0 =A0 =A0 =A0 =A0 $_ =3D "1122a44";
> =A0 =A0 =A0 =A0 =A0 =A0 my @pairs =3D m/\G(\d\d)/g; # qw( 11 22 )

Er... but didn't you want to get also qw(44 55) in:

             $_ =3D "1122a4455";
             my @pairs =3D m/\G(\d\d)/g; # qw( 11 22 )

?
Because afaict, you don't...

Marc


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

Date: Thu, 3 Dec 2009 01:59:37 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: FAQ 6.20 What good is "\G" in a regular expression?
Message-Id: <ee82e71a-c256-4fdf-8d88-32ff9c69059c@g26g2000yqe.googlegroups.com>

On Dec 3, 9:47=A0am, Marc Girod <marc.gi...@gmail.com> wrote:

> Er... but didn't you want to get also qw(44 55) in:

Sorry. You didn't.
Marc


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

Date: Thu, 03 Dec 2009 06:33:17 -0600
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 6.20 What good is "\G" in a regular expression?
Message-Id: <031220090633170658%brian.d.foy@gmail.com>

In article
<939df6b5-0c45-4adf-bf8b-9566c1cc5ef9@o10g2000yqa.googlegroups.com>,
Marc Girod <marc.girod@gmail.com> wrote:

> On Dec 2, 11:00 am, PerlFAQ Server <br...@theperlreview.com> wrote:
> 
> >     If you use the "\G" anchor, you force the match after 22 to start with
> >     the "a". The regular expression cannot match there since it does not
> >     find a digit, so the next match fails and the match operator returns the
> >     pairs it already found.
> >
> >             $_ = "1122a44";
> >             my @pairs = m/\G(\d\d)/g; # qw( 11 22 )
> 
> Er... but didn't you want to get also qw(44 55) in:
> 
>              $_ = "1122a4455";

No, the point is that you're matching on two character boundaries. The
next two characters are 'a4', which don't match.


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

Date: Wed, 02 Dec 2009 18:52:51 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Good Golly Miss Molly Perl. Been so long.
Message-Id: <86r5rdhr1o.fsf@mithril.chromatico.net>

>>>>> "DF" == David Formosa (aka ? the Platypus) <dformosa@usyd.edu.au> writes:

    DF> On Thu, 26 Nov 2009 10:08:43 -0500, Shmuel Metz <spamtrap@library.lspace.org.invalid> wrote:

    >> There's nothing wrong with goto when used properly. Like any
    >> tool, it can be and often is misused, but it's useful in its
    >> place.

    DF> Can you give an example of perl code where it would be better to
    DF> use a goto (excluding magic goto).

I can't give an example of Perl code where goto is the best solution,
because Perl has last LABEL, next LABEL, and redo LABEL.  In C, break
and continue have much simpler semantics, and so goto is more necessary.

The canonical place I've seen goto used in C is to jump to cleanup code
in a function to do something that is conceptually simple but which
requires a lot of setup and teardown.  So you have 100 lines of setup,
20-30 lines of actually doing something, and 100 lines of teardown and
cleanup -- if you fail at something partially through setup, you goto
the beginning of the cleanup.  You can do much the same thing by nesting
if-then-else structures, but then you wind up repeating the same code,
once to deal with failure in the if-then-else nest, and once to deal
with cleanup outside the if-then-else nest.  The goto can make things
considerably easier to read and the logic simpler to follow.

Thus:

  int do_something (int a, int b, char *fn)
  {
    FILE *fp = NULL;
    char *foo = NULL;

    fp = fopen (....);
    if (!fp)
      goto CLEANUP;

    foo = malloc(25);
    if (!foo)
      goto CLEANUP;
  
    /* ... */

    CLEANUP:
    if (fp) 
      fclose(fp);
  
    if (foo)
      free (foo);
  }

In Perl, first off, such a thing would not be as necessary because a lot
of cleanup can be triggered automatically when a thing goes out of
scope.  But if you did need such a thing, you could do something like
this:

  SETUP for (1)  
  {
    open my $fh, '<', ...
      or last SETUP;

    my $dbh = DBI->connect (...)
      or last SETUP;
  }

$fh && close $fn;
$dbh && $dbh->disconnect;

There's no goto in the Perlish version, but that's because the flow
control in Perl is richer.  

The assertion was that there is nothing wrong with goto when used
properly, and that goto is useful in its place; the fact that there are
likely no places in Perl code that are a proper place for goto does not
make that assertion invalid.

Charlton



-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Thu, 3 Dec 2009 14:43:04 +0000 (UTC)
From: Martin Str|mberg <ams@sister.ludd.ltu.se>
Subject: Re: i18n?
Message-Id: <hf8ipo$dch$1@aioe.org>

Ben Morrow <ben@morrow.me.uk> wrote:

> Quoth Martin Str|mberg <ams@sister.ludd.luth.se>:
>> I've been looking for i18n for perl so that I can't get error messages
>> in Swedish. I haven't found anything, not _any_ other language.

> Which messages are you talking about? Those generated by perl itself
> cannot be localised. There has been some discussion of the possibility
> in the past, but (among other things) there's just too much code out
> there that does regex matching on $@ for this to be very practical
> (start with diagnostics.pm, for instance). Most modules don't provide
> localized error messages either.

Yes I mean those generated by perl itself. I would help my son, whom
I'm trying to teach perl, understand what's wrong.


-- 
MartinS


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

Date: Thu, 3 Dec 2009 14:50:09 +0000 (UTC)
From: Martin Str|mberg <ams@sister.ludd.ltu.se>
Subject: Re: i18n?
Message-Id: <hf8j71$dse$1@aioe.org>

Klaus <klaus03@gmail.com> wrote:
> On 2 déc, 11:52, Martin Str|mberg <a...@sister.ludd.luth.se> wrote:
>> I've been looking for i18n for perl so that I can't get error messages
>> in Swedish. I haven't found anything, not _any_ other language.
>>
>> Is there no such thing? Or have I just searched the wrong places or
>> for the wrong things?

> Have you looked on CPAN ?

> http://search.cpan.org/~audreyt/i18n-0.10/lib/i18n.pm

Hmm, I think so. I don't remember what I searched for, but either I
got 0 results or too many and the top ones wasn't anything I looked
for. I think I looked at that one but dismissed it (then).

Anyway, that is almost what I was looking for. Now all we need is
those ~~ in all perl and the .po files...


Thank you.


-- 
MartinS


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

Date: Thu, 3 Dec 2009 07:26:03 -0800 (PST)
From: Ninja Li <nickli2000@gmail.com>
Subject: Join every two lines of a file
Message-Id: <a6a3d4f2-2f62-4dcf-888b-020f50807e91@p30g2000vbt.googlegroups.com>

Hi,

   I am trying to join every two lines of the following using perl:
<td align="center" width="50"><nobr>AWR
&#160;</nobr></td>
<td align="center" width="50"><nobr>ANH
&#160;</nobr></td>
<td align="center" width="50"><nobr>ACAP
&#160;</nobr></td>

  The output should be as follows:
  <td align="center" width="50"><nobr>AWR</nobr></td>
  <td align="center" width="50"><nobr>ANH</nobr></td>
  <td align="center" width="50"><nobr>ACAP</nobr></td>

  Is there an easy way to join every two lines while at the same time
remove the "&#160;" characters in the line?

  Thanks.

  Nick



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

Date: Thu, 03 Dec 2009 16:53:27 +0100
From: Josef Moellers <josef.moellers@ts.fujitsu.com>
Subject: Re: Join every two lines of a file
Message-Id: <hf8mtn$qs7$1@nntp.fujitsu-siemens.com>

Ninja Li wrote:
> Hi,
> 
>    I am trying to join every two lines of the following using perl:
> <td align="center" width="50"><nobr>AWR
> &#160;</nobr></td>
> <td align="center" width="50"><nobr>ANH
> &#160;</nobr></td>
> <td align="center" width="50"><nobr>ACAP
> &#160;</nobr></td>
> 
>   The output should be as follows:
>   <td align="center" width="50"><nobr>AWR</nobr></td>
>   <td align="center" width="50"><nobr>ANH</nobr></td>
>   <td align="center" width="50"><nobr>ACAP</nobr></td>
> 
>   Is there an easy way to join every two lines while at the same time
> remove the "&#160;" characters in the line?

Yes. What have you tried so far? Where did it not meet your expectations.
You're supposed to try first and *then* come here for help.

But then ... it's pretty simple:

while (my $line = <$src>) {
     chomp $line;
     $line .= <$src>;
     $line =~ s/&#160;//;
     print $dst $line;
}


-- 
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html


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

Date: Wed, 2 Dec 2009 20:06:26 -0800 (PST)
From: Robin <robin1@cnsp.com>
Subject: perl compilers
Message-Id: <c1c81352-4e0a-4553-a842-56dabb74c70e@k19g2000yqc.googlegroups.com>

Anyone know of any good perl compilers for windows. I have searched
and found no good ones.
robin


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 2704
***************************************


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