[32717] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3981 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 4 09:09:17 2013

Date: Thu, 4 Jul 2013 06:09:04 -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, 4 Jul 2013     Volume: 11 Number: 3981

Today's topics:
        [OT] MIME adoption in Usenet <oneingray@gmail.com>
    Re: [OT] MIME adoption in Usenet <ben@morrow.me.uk>
        [XS] .h constants -> Perl subs (like POSIX' "errno_h")? <oneingray@gmail.com>
    Re: [XS] .h constants -> Perl subs (like POSIX' "errno_ <peter@makholm.net>
    Re: [XS] .h constants -> Perl subs (like POSIX' "errno_ <oneingray@gmail.com>
    Re: [XS] .h constants -> Perl subs (like POSIX' "errno_ <rweikusat@mssgmbh.com>
    Re: having trouble with hash of arrays... <oneingray@gmail.com>
    Re: having trouble with hash of arrays... <derykus@gmail.com>
    Re: having trouble with hash of arrays... <rweikusat@mssgmbh.com>
    Re: I'd like to try Perl... <ben@morrow.me.uk>
    Re: I'd like to try Perl... <papa.pearl@suomi24.fi>
    Re: I'd like to try Perl... <jurgenex@hotmail.com>
    Re: I'd like to try Perl... <ben@morrow.me.uk>
    Re: I'd like to try Perl... <papa.pearl@suomi24.fi>
    Re: perldoc and perl-doc <whynot@pozharski.name>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 03 Jul 2013 12:59:34 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: [OT] MIME adoption in Usenet
Message-Id: <877gh73ikp.fsf_-_@violet.siamics.net>

>>>>> Ben Morrow <ben@morrow.me.uk> writes:
>>>>> Quoth "Peter J. Holzer" <hjp-usenet3@hjp.at>:

 > Content-type: text/plain; charset=UTF-8

[...]

 >> :-) Push the right button and Ben sounds like Rainer.

 > Touch\351 :).

	As for the pedantry, I'm curious, since when has a lone \351
	acquired a defined meaning in UTF-8?  (As opposed to:
	ISO-8859-1.)

[...]

	Well, I have to admit that this message is more a response to
	news:51aec8bf$11$fuzhry+tra$mr2ice@news.patriot.net (posted in
	news:news.software.readers, where I hereby cross-post), which I
	haven't managed to answer back then, and do it now.

 > Newsgroups: soc.culture.russian, news.software.readers
 > From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
 > Date: Wed, 05 Jun 2013 01:12:31 -0400
 > Subject: Re: [OT] Russian language

 > In <87li6w1acp.fsf@violet.siamics.net>, Ivan Shmakov said:

[...]

 >> Unfortunately, an RFC isn't a magic spell scroll to prevent
 >> subscribers from using any of the non-compliant software, ever.

	(And the last time I've checked, which was perhaps a decade ago,
	though, trn had no MIME support whatsoever.)

 > That doesn't mean that the "American Usenet" (whatever that is) isn't
 > affected by the standards, or that there are a higher percentage of
 > nyekulturniy users in the USA than in Russia.  Both counties have
 > people who follow the rules and people who don't.

	My point is that it's not the /lack/ of culture, it's the people
	who still adhere to the considerably older culture of "Usenet
	without MIME."

PS.  Not to mention that the "American Usenet" has seen an extra decade
	of "MIME-less" operation as compared to the "Russian Usenet."

-- 
FSF associate member #7257


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

Date: Wed, 3 Jul 2013 17:49:43 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: [OT] MIME adoption in Usenet
Message-Id: <7a1eaa-c5h2.ln1@anubis.morrow.me.uk>

[news.software.readers removed, since I don't read it and don't believe
this response belongs there.]

Quoth Ivan Shmakov <oneingray@gmail.com>:
> >>>>> Ben Morrow <ben@morrow.me.uk> writes:
> >>>>> Quoth "Peter J. Holzer" <hjp-usenet3@hjp.at>:
> 
>  > Content-type: text/plain; charset=UTF-8
> 
>  >> :-) Push the right button and Ben sounds like Rainer.
> 
>  > Touch\351 :).
> 
> 	As for the pedantry, I'm curious, since when has a lone \351
> 	acquired a defined meaning in UTF-8?  (As opposed to:
> 	ISO-8859-1.)

Sorry, something-or-other made Vim decide to write the file out in
8859-1 rather than UTF-8. I considered posting an apology, but decided
it would just be unnecessary noise.

Ben



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

Date: Wed, 03 Jul 2013 06:05:23 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: [XS] .h constants -> Perl subs (like POSIX' "errno_h")?
Message-Id: <87ip0s2n6k.fsf@violet.siamics.net>

	Is there an easy way to make a bunch of C constants (as in:
	#define) available as Perl subroutines (just like, e. g., POSIX
	does for the errno.h constants)?

	I've looked at POSIX.xs, POSIX.pm [1, 2], but don't seem to get
	it.  (Somehow, there do not seem to be any references to, say,
	ENOENT, other than that in the export list.)

	Surely, I can follow the example at SQLite.xs [3]:

static int
OK()
    CODE:
        RETVAL = SQLITE_OK;
    OUTPUT:
        RETVAL

	But that seems overly repetitive and error-prone.  (Given that I
	need to handle some 156 such constants, anyway.)

	TIA.

[1] http://cpansearch.perl.org/src/RJBS/perl-5.18.0/ext/POSIX/POSIX.xs
[2] http://cpansearch.perl.org/src/RJBS/perl-5.18.0/ext/POSIX/lib/POSIX.pm
[3] http://cpansearch.perl.org/src/ISHIGAKI/DBD-SQLite-1.39/SQLite.xs

-- 
FSF associate member #7257


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

Date: Wed, 03 Jul 2013 08:34:30 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: [XS] .h constants -> Perl subs (like POSIX' "errno_h")?
Message-Id: <87obak6tjd.fsf@vps1.hacking.dk>

Ivan Shmakov <oneingray@gmail.com> writes:

> 	Is there an easy way to make a bunch of C constants (as in:
> 	#define) available as Perl subroutines (just like, e. g., POSIX
> 	does for the errno.h constants)?

In the past I have used the h2ph tools for this. It requires some post
processing to make it look like a modern perl module with sane exports.

//Makholm


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

Date: Wed, 03 Jul 2013 07:50:01 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Re: [XS] .h constants -> Perl subs (like POSIX' "errno_h")?
Message-Id: <87ehbg2ic6.fsf@violet.siamics.net>

	... Well, I've got it: it's in Makefile.PL:

--cut: http://cpansearch.perl.org/src/RJBS/perl-5.18.0/ext/POSIX/Makefile.PL --
WriteConstants(
    PROXYSUBS => {croak_on_error => 1},
    NAME => 'POSIX',
    NAMES => \@names,
);
--cut: http://cpansearch.perl.org/src/RJBS/perl-5.18.0/ext/POSIX/Makefile.PL --

	Appears to work for me, though I've placed the call to
	WriteConstants () before the one to WriteMakefile () (while
	POSIX' Makefile.PL does it the other way around.)

-- 
FSF associate member #7257


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

Date: Wed, 03 Jul 2013 10:38:29 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: [XS] .h constants -> Perl subs (like POSIX' "errno_h")?
Message-Id: <8761wskmp6.fsf@sapphire.mobileactivedefense.com>

Ivan Shmakov <oneingray@gmail.com> writes:
> 	Is there an easy way to make a bunch of C constants (as in:
> 	#define) available as Perl subroutines (just like, e. g., POSIX
> 	does for the errno.h constants)?

In case of a new module, this is part of what h2xs does. I'm also
using C::Scan::Constants when more 'dynamic'(ically changing) headers
are involved.



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

Date: Wed, 03 Jul 2013 05:10:50 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Re: having trouble with hash of arrays...
Message-Id: <87mwq42pph.fsf@violet.siamics.net>

>>>>> bjobrien62  <bjobrien62@gmail.com> writes:

 > This is confusing me...

	What specifically?

[...]

 > if (exists($hash{$pid})) {
 >     $pnames = $hash{$pid};
 >     @found = grep(/$pname/, @pnames);

	The problem with grep () is that it will scan through /all/ the
	list, instead of stopping on the first match.

 >     $size = @found;
 >     if ($size == 0) {
 >         push(@$names, $pname);
 >         $hash{$pid} = [ @foo ];
 >     }
 > } else {
 >     $hash{$pid} = [ $pname ];
 > }

	... Overall, I'd just use a (second) hash instead, as in:

   $hash{$pid}->{$pname} = 1
       unless (exists ($hash{$pid})
               && exists ($hash{$pid}->{$pname}));

 > Then I want to print out the list...

 > my $patid = "";

	What is the above statement for?

 > foreach my $patid (keys %hash) {
 >     print "The spellings for $patid are\n";
 >     foreach (@{$hash{$patid}}) {
 >         print "\t$_\n";
 >     }
 > }

	The inner foreach () loop seems a bit superfluous here.
	Consider, e. g.:

   foreach my $patid (keys %hash) {
       print "The spellings for $patid are\n";
       local ($,, $\)
           = ("\t", "\n");
       print ("", keys (%{$hash{$patid}}));
   }

	Naturally, join () may be used instead of setting $,, like:

   print ("The spellings for ", $patid, " are\n",
          "\t", join ("\t", keys (%{$hash{$_}})), "\n");
       foreach (keys (%hash));

	Consider also applying sort () to the keys () of the hashes.

-- 
FSF associate member #7257


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

Date: Tue, 02 Jul 2013 23:44:59 -0700
From: Charles DeRykus <derykus@gmail.com>
Subject: Re: having trouble with hash of arrays...
Message-Id: <kr0h9c$amc$1@speranza.aioe.org>

On 7/2/2013 5:11 PM, bjobrien62@gmail.com wrote:
> This is confusing me...
> I have a patient id and that patient id can have a list of patient names (each with different spelling, but the same person)
>
> my %hash = ();
> my $pid = "Patient ID";
> my $pname = "Patient Name";
>
> I check to see if there is an entry in the hash for patient ID.
> If there is then I want the array of Patient Names for the Patient ID.
> Then I want to see if this spelling is found in the Array.
> If it is do nothing, if it isn't then I add the new spelling to the array then set that array as the value for the hash pid.
>
>
>          if (exists($hash{$pid})) {
>
>              $pnames = $hash{$pid};
>              @found = grep(/$pname/, @pnames);
                                        ^^^^^^^
                                        @{$pnames}
>              $size = @found;
>
>              if ($size == 0) {
>                 push(@$names, $pname);
>                 $hash{$pid} = [ @foo ];
>              }
>           } else {
>              $hash{$pid} = [ $pname ];
>           }

@$names and  @foo look wrong...  old code fragments perhaps?


Since you only want to add new spellings, you could shorten it all down 
to a line or two, eg,

             unless ( grep( /^$pname$/, @$pnames ) {
                 push( @{ $hash{$pid} }, $pname );
             }



>
> Then I want to print out the list...
>
> my $patid = "";
^^^^^^^^^^^^^^^
unneeded

>
> foreach my $patid (keys %hash) {
>      print "The spellings for $patid are\n";
>      foreach (@{$hash{$patid}}) {
>          print "\t$_\n";
>      }
> }
>

Other than the unneeded line, this looks ok though.

-- 
Charles DeRykus




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

Date: Wed, 03 Jul 2013 10:34:19 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: having trouble with hash of arrays...
Message-Id: <87a9m4kmw4.fsf@sapphire.mobileactivedefense.com>

bjobrien62@gmail.com writes:
>         if (exists($hash{$pid})) {
>
>             $pnames = $hash{$pid};
>             @found = grep(/$pname/, @pnames);

@pnames is not the same as the anonymous array $pnames refers to. That
would be @$pnames.

/$pname/ is a regex match which will return true if one of the input
elements matches the regex $pname somewhere. Eg, if $pname was 'Henry
I.', that would match 'John Henry Ibsen'. This should be something
like

/^\Q$pname\E$/

This anchors the match at the beginning and end of the string, eg,
'Henry' will match 'Henry' and not 'John Henry' and quotes any
regex-metacharacters in $pname.

>             $size = @found;

You can as well use $size = grep(...) as grep returns the number of
elements it found in scalar context.

            
>             if ($size == 0) {
>                push(@$names, $pname);

@$names is not the same as @$pnames. The strict module/ pragma is very
helpful for catching these kind of mistakes.


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

Date: Wed, 3 Jul 2013 11:48:23 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: I'd like to try Perl...
Message-Id: <n4cdaa-jjs1.ln1@anubis.morrow.me.uk>

This is completely OT, but...

Quoth dkcombs@panix.com (David Combs):
> 
> Sorry, I use cygwin (via *shell* in emacs), but I don't know
> what this "cygwin terminal" is.  I probably would benefit
> from it!

I believe it's just a cmd window running a Cygwin shell.

> One problem I have is getting the *cygwin* shell stuff to work:
> (this is from some time ago, so I might have forgotten
> a bit of what I did):
> 
>   I (thought I) found that if I wanted to use pipes, variables,
>   etc within a cygwin shell (sh, tcsh (I believe), etc), then
>   I was required to use that horrible windows "cmd" black-and-white
>   window, which was really, really gross.

This is expected on Windows. Because Windows doesn't have ptys, and
makes some distinction between 'console' and 'gui' applications, and for
other reasons I can't remember, it's never worth using any sort of
terminal emulator other than cmd.exe. They just never work properly.

(And cmd isn't *that* bad, at least if you make the font a bit bigger.
It's not what I'd call pleasant, but it's not unusable.)

>   One problem I had was that I could not prepare IN EMACS a command
>   to execute there, and paste that command into that
>   horrible cmd window.  Could only type it in there by hand,
>   character by character. 
> 
>   Likewise, I think I recall, it was difficult or impossible
>   to "copy" text from within that window (for pasting elsewhere);
>   copying and pasting simply didn't work in cmd windows.

Copy and paste in cmd.exe are found on the right-click menu on the icon
in the top-left of the window. (Yes, this is weird.) Copying is a
two-step process: first choose right-click/Edit/Mark, then select the
text you want to copy, then right-click/Edit/Copy. IIRC you can't copy
more than one (visible) screenful at a time.

> And, generally, how do people run the cygwin shells?
>   In what environment?

I stay as far away from Cygwin as possible. IME it has all the bugs of
Windows plus a whole lot more of its own.

> Question: how do they get the full features of one
>   of those shells to work, within emacs?  Within, say,
>   *shell* or *eshell*?

They don't. It can't be done on Windows, since there aren't any ptys.

Ben



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

Date: Wed, 03 Jul 2013 18:10:27 +0300
From: pepa <papa.pearl@suomi24.fi>
Subject: Re: I'd like to try Perl...
Message-Id: <B9XAt.22078$8w.16459@uutiset.elisa.fi>

3.7.2013 13:48, Ben Morrow kirjoitti:
> This is completely OT, but...
> 
> Quoth dkcombs@panix.com (David Combs):
>>
>> Sorry, I use cygwin (via *shell* in emacs), but I don't know
>> what this "cygwin terminal" is.  I probably would benefit
>> from it!
> 
> I believe it's just a cmd window running a Cygwin shell.

You seem to be trying to guess, Ben, in a way that is not very helpful.
Not this this time anyway.

There are multiple issues at hand here. For one, the "cygwin terminal"
that I would recommend is mintty.exe, which comes with cygwin by
default or bash.exe or any other shell executable, but mintty nowadays
is the recommended one. Next, my guess is that David either has not
found a way to configure Emacs to use a cygwin shell inside Emacs
– or David is using NTEmacs, not the emacs that comes with cygwin,
and therefore has the problem described in
http://www.emacswiki.org/emacs/NTEmacsWithCygwin#toc1. Since this
problem appeared, it has
been a pain to use any of the cygwin shells inside Emacs.
It is easier to open a separate window for command line stuff,
and for that purpose, I'd recommend mintty. But that's a matter
of taste.

In any case, the David's guestion doesn't belong here.



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

Date: Wed, 03 Jul 2013 08:16:17 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: I'd like to try Perl...
Message-Id: <0cf8t89kk5jh7r79p7rdiff23o2jnvdlcd@4ax.com>

>Quoth dkcombs@panix.com (David Combs):Ben Morrow <ben@morrow.me.uk> wrote:
>>   I was required to use that horrible windows "cmd" black-and-white
>>   window, which was really, really gross.

Right-click on title bar, "Properties" -> tab "Colors".

>>   Likewise, I think I recall, it was difficult or impossible
>>   to "copy" text from within that window (for pasting elsewhere);
>>   copying and pasting simply didn't work in cmd windows.

Change settings once by right-click, "Properties", tab "Options", "Quick
Edit Mode".
Then highlight text by dragging the cursor over the text, copy
highlighted text by hitting "Enter", pasting from clipboard by mouse
right-click. 

A typical case of know how to use your tools. CMD/BAT is certainly a
poor command language, but you shouldn't blame the tool for the problem
that is between chair and keyboard.

jue


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

Date: Wed, 3 Jul 2013 17:45:02 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: I'd like to try Perl...
Message-Id: <e11eaa-c5h2.ln1@anubis.morrow.me.uk>


Quoth pepa <papa.pearl@suomi24.fi>:
> 3.7.2013 13:48, Ben Morrow kirjoitti:
> > This is completely OT, but...
> > 
> > Quoth dkcombs@panix.com (David Combs):
> >>
> >> Sorry, I use cygwin (via *shell* in emacs), but I don't know
> >> what this "cygwin terminal" is.  I probably would benefit
> >> from it!
> > 
> > I believe it's just a cmd window running a Cygwin shell.
> 
> You seem to be trying to guess, Ben, in a way that is not very helpful.
> Not this this time anyway.

Last time I used Cygwin (quite a while ago now) the 'Cygwin shell' link
installed on the Start Menu just opened a cmd window running Cygwin
bash. IIRC there were other options available--some sort of rxvt
port?--but they didn't work right. Pipes, in particular, tended to
misbehave.

> There are multiple issues at hand here. For one, the "cygwin terminal"
> that I would recommend is mintty.exe, which comes with cygwin by
> default or bash.exe or any other shell executable, but mintty nowadays
> is the recommended one.

Am I to assume from this that the 'no ptys' issue has been solved, or
worked around, and that mintty is a terminal emulator that works? Or is
it just a shell?

This is actually vaguely on-topic, since I've had problems running
things from Perl on Windows in the past that could have been solved with
ptys. Of course, if only Cygwin processes understand the pty emulation
that wouldn't be much use to me.

> Next, my guess is that David either has not
> found a way to configure Emacs to use a cygwin shell inside Emacs
> – or David is using NTEmacs, not the emacs that comes with cygwin,
> and therefore has the problem described in
> http://www.emacswiki.org/emacs/NTEmacsWithCygwin#toc1.

Hmm, glancing at that just confirms my opinion: mixing native Win32
facilities with ported-from-Unix facilities with Cygwin facilities just
leads to worlds of pain. Since, IME, native Win32 facilities cannot be
avoided entirely, this makes using Cygwin an exercise in hacking around
compatibility problems.

Ben



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

Date: Wed, 03 Jul 2013 23:30:35 +0300
From: pepa <papa.pearl@suomi24.fi>
Subject: Re: I'd like to try Perl...
Message-Id: <JR%At.22104$8w.16023@uutiset.elisa.fi>

Seconf attempt. Sorry Ben for sending privately. Meant to usenet.

3.7.2013 19:45, Ben Morrow kirjoitti:
>
> Last time I used Cygwin (quite a while ago now) the 'Cygwin shell' link
> installed on the Start Menu just opened a cmd window running Cygwin
> bash. IIRC there were other options available--some sort of rxvt
> port?--but they didn't work right. Pipes, in particular, tended to
> misbehave.

Must e very very long ago, because I've never seen Cygwin providing cmd
by default. When I began with cygwin, the main interface was a bat that
invokes bash. It's still there but now the entry that the installer adds
to start menu invokes mintty.

>> There are multiple issues at hand here. For one, the "cygwin terminal"
>> that I would recommend is mintty.exe, which comes with cygwin by
>> default or bash.exe or any other shell executable, but mintty nowadays
>> is the recommended one.
>
> Am I to assume from this that the 'no ptys' issue has been solved, or
> worked around, and that mintty is a terminal emulator that works? Or is
> it just a shell?

Now there is mintty, which provides better window management, but mintty
is not a shell (and you would not want to use it inside emacs, which I
should have already pointed out, but then, this is not an emacs forum).
I have never had pipe problems with cygwin, and I have no idea of what
you refer to when you talk about "the 'no ptys' issue". Which probably
just means you are more skillful than I am.

My best guess is still that David has not told Emacs which shell to run
when he wants shell. How to do that belogns to an emacs forum, not here,
however.


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

Date: Wed, 03 Jul 2013 09:41:23 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: perldoc and perl-doc
Message-Id: <slrnkt7hsj.gbj.whynot@orphan.zombinet>

with <87vc4t2dfp.fsf@violet.siamics.net> Ivan Shmakov wrote:
*SKIP*
> 	OTOH, the documentation packaged with the version of Perl used
> 	may still have bugs already resolved in the newer version served
> 	from http://perldoc.perl.org/.

See how I resist urge to post a troll-o-meter.

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


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

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


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