[31112] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2357 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 21 06:09:42 2009

Date: Tue, 21 Apr 2009 03:09: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           Tue, 21 Apr 2009     Volume: 11 Number: 2357

Today's topics:
    Re: Hash refs and printing to FD <january.weiner@gmail.com>
    Re: How can I backreference a ?: group in perl regular  <haoniukun@gmail.com>
    Re: Is there a better way to convert foreign characters <nospam-abuse@ilyaz.org>
    Re: Is there a better way to convert foreign characters <bugbear@trim_papermule.co.uk_trim>
    Re: Is there a better way to convert foreign characters <january.weiner@gmail.com>
        new CPAN modules on Tue Apr 21 2009 (Randal Schwartz)
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@seesig.invalid
        Problem in parsing from a pipe <january.weiner@gmail.com>
    Re: Problem in parsing from a pipe <ben@morrow.me.uk>
    Re: What does `my' do?! <devnull4711@web.de>
    Re: What does `my' do?! <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 21 Apr 2009 09:17:24 +0200 (CEST)
From: January Weiner <january.weiner@gmail.com>
Subject: Re: Hash refs and printing to FD
Message-Id: <gsjru4$mnv$1@sagnix.uni-muenster.de>

On 2009-04-16, Tim McDaniel <tmcd@panix.com> wrote:
> For anyone else who was puzzled about what the regular expressions
> manual (perlre) had to do with it, he meant "perlref".

:-))))

j.



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

Date: Tue, 21 Apr 2009 00:02:52 -0700 (PDT)
From: kun niu <haoniukun@gmail.com>
Subject: Re: How can I backreference a ?: group in perl regular expression?
Message-Id: <79919533-87e3-45a6-8c82-9c8d521458de@b6g2000pre.googlegroups.com>

On 4=D4=C221=C8=D5, =C9=CF=CE=E73=CA=B111=B7=D6, "John W. Krahn" <some...@e=
xample.com> wrote:
> kun niu wrote:
> > On 4?21?, ??12?50?, Ben Morrow <b...@morrow.me.uk> wrote:
> >> Quoth kun niu <haoniu...@gmail.com>:
>
> >>> Dear all,
> >>> My question is listed as title.
> >>> I want to use strings like \1,\2 etc to represent the group matched
> >>> last time.
> >>> But the group is not captured, as signed by ?:.
> >>> Can I implement this in perl?
> >> No. That, in fact, is the whole point of (?:) groups.
>
> >> Why do you think you need to do this?
>
> > Thank you for your attention to my question and your precious time.
> > In my application, I'll have reformat the telephone number in my
> > company.
> > Since they came from all over the world, we have various telephone
> > format.
> > Here's some examples:
> > 000-000-000
> > (00)00-000-0000
> > !00!00-000-0000
> > 0000000
> > 0000-0000
> > 0000 0000 000
> > you dont care
> > What my job is to check the valid telephone number and to give them
> > out.
> > In case that I meet a ')' character, I'll have to check if there's a
> > '(' in the front.
> > '!' is also valid here.
> > But all these characters should not be captured.
> > So I'll have to backreference a previous group
> > Expression like "((?:[!|]*)\d+\1\d+)" gives a bad result.
> > Any further hints or advice here?
>
> "(([!|]*)\d+\2\d+)"
>
> John
> --
> Those people who think they know everything are a great
> annoyance to those of us who do.        -- Isaac Asimov- =D2=FE=B2=D8=B1=
=BB=D2=FD=D3=C3=CE=C4=D7=D6 -
>
> - =CF=D4=CA=BE=D2=FD=D3=C3=B5=C4=CE=C4=D7=D6 -

Thank you for your attention.
It's true that this is a way out.
But in this case, ! or ! are captured. I don't want these characters
captured.
So only !00!-000-0000 are captured instead of ! and !00!-000-0000.


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

Date: Tue, 21 Apr 2009 05:19:10 GMT
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Is there a better way to convert foreign characters?
Message-Id: <slrnguqle5.j5c.nospam-abuse@chorin.math.berkeley.edu>

On 2009-04-20, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Dr.Ruud wrote:
>> 
>> perl -Mstrict -Mutf8 -MText::Unidecode -wle '
>>   my $s = "àâÀéèëêÉÊçÇîïôÔùû";
>>   print Text::Unidecode::unidecode( $s );
>> '
>> aaAeeeeEEcCiioOuu
>
> The purpose of that module is to handle non-Roman characters. What makes 
> you believe those characters are Unicode?

Since this code is not in scope of `use locale', the characters are,
by Perl semantic, in Unicode...

Hope this helps,
Ilya


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

Date: Tue, 21 Apr 2009 09:31:33 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: Is there a better way to convert foreign characters?
Message-Id: <7Y2dnb5yO4b4GXDUnZ2dnUVZ8gli4p2d@posted.plusnet>

Jürgen Exner wrote:
> "Guy" <someone@somewhere.nb.ca> wrote:
>> I'm sure there are many ways to do this, but is there a much better way?
>>
>> $value=~tr/àâÀéèëêÉÊçÇîïôÔùû/aaaeeeeeecciioouu/;
>> $word=lc($value);
>>
>> I want $word to equal the english version of $value.  So if 
>> $value="Théodore", I want $word="theodore".  
> 
> This is A Very Bad Idea(TM). We had those discussions 10 years ago and I
> am suprised that people still want to make the same mistakes.
> 
> First of all how would you react, if someone is mangling your name?
> There is no "English version" of my first name.

But an English speaker might well search for "Jurgen Exner"
and hope to find you.

Accent folding is a key component of "loose" matching.

   BugBear


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

Date: Tue, 21 Apr 2009 11:58:00 +0200 (CEST)
From: January Weiner <january.weiner@gmail.com>
Subject: Re: Is there a better way to convert foreign characters?
Message-Id: <gsk5b8$oqn$1@sagnix.uni-muenster.de>

On 2009-04-19, Jürgen Exner <jurgenex@hotmail.com> wrote:
> This is A Very Bad Idea(TM). We had those discussions 10 years ago and I
> am suprised that people still want to make the same mistakes.

Right. 

You have read a great book by an author called Żmiwór Ściepełkowski. You
want to look up in your favorite library database what else he has written.
What do you do?

  a) you enter "Zmiwor Sciepelkowski"
  b) you figure out what these characters are, from what set, and in the
  end you spend half an hour trying to locate "Åš" and other characters (and
  not Ŝ, Š, Ṥ, Ṧ or Ṩ or one of a dozen of other variants, which are, in
  fact, all very different, although they might look very similar). 

You guys from the former Latin 1 set have it easy talking. Latin 1
characters (e.g. umlauts) can be found and easily inserted almost anywhere
and on any system.

Having a clever module that can uniquly assign various weird characters to
the basic ASCII set would be a really great thing, and I would be really
grateful to anyone who could offer a better solution than that of the OP.

> And last UTF-8 is such a nice character set, there is really, really no
> excuse any more to not use it. 10 years ago the story was somewhat
> different, because many programs didn't support it yet at that time.

Only from a (former) Latin-1 perspective.

j.


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

Date: Tue, 21 Apr 2009 04:42:27 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Apr 21 2009
Message-Id: <KIFp2r.1q2u@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.

Acme-CPANAuthors-Norwegian-0.1
http://search.cpan.org/~sharifuln/Acme-CPANAuthors-Norwegian-0.1/
We are Norwegian CPAN authors 
----
Acme-CPANAuthors-Russian-0.11
http://search.cpan.org/~sharifuln/Acme-CPANAuthors-Russian-0.11/
We are Russian CPAN authors 
----
Acme-CPANAuthors-Ukrainian-0.1
http://search.cpan.org/~sharifuln/Acme-CPANAuthors-Ukrainian-0.1/
We are Ukrainian CPAN authors 
----
Acme-POE-Acronym-Generator-1.16
http://search.cpan.org/~bingos/Acme-POE-Acronym-Generator-1.16/
Generate random POE acronyms. 
----
AnyEvent-4.352
http://search.cpan.org/~mlehmann/AnyEvent-4.352/
provide framework for multiple event loops 
----
App-GitHub-0.05
http://search.cpan.org/~fayland/App-GitHub-0.05/
GitHub Command Tools 
----
Archive-Tar-1.48
http://search.cpan.org/~kane/Archive-Tar-1.48/
module for manipulations of tar archives 
----
Asterisk-config-syntax-0.1
http://search.cpan.org/~nsnake/Asterisk-config-syntax-0.1/
highlight Asterisk config syntax 
----
Asterisk-config-syntax-highlight-0.2
http://search.cpan.org/~nsnake/Asterisk-config-syntax-highlight-0.2/
highlight Asterisk config syntax 
----
Asterisk-config-syntax-highlight-0.3
http://search.cpan.org/~nsnake/Asterisk-config-syntax-highlight-0.3/
highlight Asterisk config syntax 
----
CGI-Capture-1.12
http://search.cpan.org/~adamk/CGI-Capture-1.12/
Meticulously thorough capture and replaying of CGI calls 
----
CGI-Carp-Fatals-0.02
http://search.cpan.org/~accardo/CGI-Carp-Fatals-0.02/
fatalsToBrowser on steroids 
----
CPAN-FindDependencies-2.3
http://search.cpan.org/~dcantrell/CPAN-FindDependencies-2.3/
find dependencies for modules on the CPAN 
----
CPANPLUS-0.85_08
http://search.cpan.org/~kane/CPANPLUS-0.85_08/
API & CLI access to the CPAN mirrors 
----
Cache-Memcached-Tags-0.02
http://search.cpan.org/~ebragin/Cache-Memcached-Tags-0.02/
Cache::Memcached based client library for memcached-tags: http://code.google.com/p/memcached-tags/ 
----
Cache-Memcached-Tie-0.07
http://search.cpan.org/~gugu/Cache-Memcached-Tie-0.07/
Use Cache::Memcached::Fast like hash. 
----
Cairo-CuttingLine-0.01
http://search.cpan.org/~cornelius/Cairo-CuttingLine-0.01/
draw cutting line to cairo surface 
----
Cairo-CuttingLine-0.02
http://search.cpan.org/~cornelius/Cairo-CuttingLine-0.02/
draw cutting line to cairo surface 
----
Cairo-CuttingLine-0.03
http://search.cpan.org/~cornelius/Cairo-CuttingLine-0.03/
draw cutting line to cairo surface 
----
Catalyst-Controller-DBIC-API-1.002001
http://search.cpan.org/~lsaunders/Catalyst-Controller-DBIC-API-1.002001/
----
Catalyst-Controller-HTML-FormFu-0.04002
http://search.cpan.org/~cfranks/Catalyst-Controller-HTML-FormFu-0.04002/
Catalyst integration for HTML::FormFu 
----
Catalyst-Controller-HTML-FormFu-0.04003
http://search.cpan.org/~cfranks/Catalyst-Controller-HTML-FormFu-0.04003/
Catalyst integration for HTML::FormFu 
----
Catalyst-Plugin-AuthenCookie-0.04
http://search.cpan.org/~drolsky/Catalyst-Plugin-AuthenCookie-0.04/
Plugin for cookie-based authentication 
----
Catalyst-Plugin-Authorization-Abilities-0.01
http://search.cpan.org/~idoperel/Catalyst-Plugin-Authorization-Abilities-0.01/
Ability based authorization for Catalyst based on Catalyst::Plugin::Authentication and Catalyst::Plugin::Authorization::Roles 
----
Catalyst-Plugin-Compress-0.002
http://search.cpan.org/~xinming/Catalyst-Plugin-Compress-0.002/
Compress response 
----
Catalyst-Plugin-StackTrace-0.10
http://search.cpan.org/~mramberg/Catalyst-Plugin-StackTrace-0.10/
Display a stack trace on the debug screen 
----
Catalyst-Request-REST-ForBrowsers-0.02
http://search.cpan.org/~drolsky/Catalyst-Request-REST-ForBrowsers-0.02/
A Catalyst::Request::REST subclass for dealing with browsers 
----
Class-Entangle-0.06
http://search.cpan.org/~exodist/Class-Entangle-0.06/
Functions to entangle an object. 
----
Class-Inspector-1.24
http://search.cpan.org/~adamk/Class-Inspector-1.24/
Get information about a class and its structure 
----
Class-MOP-0.82
http://search.cpan.org/~drolsky/Class-MOP-0.82/
A Meta Object Protocol for Perl 5 
----
Config-Model-0.635
http://search.cpan.org/~ddumont/Config-Model-0.635/
Framework to create configuration validation tools and editors 
----
Config-Model-Itself-1.210
http://search.cpan.org/~ddumont/Config-Model-Itself-1.210/
Model editor for Config::Model 
----
Config-Model-TkUI-1.208
http://search.cpan.org/~ddumont/Config-Model-TkUI-1.208/
Tk GUI to edit config data through Config::Model 
----
Crypt-Eksblowfish-0.006
http://search.cpan.org/~zefram/Crypt-Eksblowfish-0.006/
the Eksblowfish block cipher 
----
DBD-ODBC-1.20
http://search.cpan.org/~mjevans/DBD-ODBC-1.20/
ODBC Driver for DBI 
----
DBIx-Class-CompressColumns-0.01001
http://search.cpan.org/~jessestay/DBIx-Class-CompressColumns-0.01001/
Automatic Compression/Decompression of columns 
----
DBIx-DataModel-1.14
http://search.cpan.org/~dami/DBIx-DataModel-1.14/
Classes and UML-style Associations on top of DBI 
----
Data-JavaScript-Anon-1.03
http://search.cpan.org/~adamk/Data-JavaScript-Anon-1.03/
Dump big dumb Perl structs to anonymous JavaScript structs 
----
Data-Pareto-0.02
http://search.cpan.org/~pwes/Data-Pareto-0.02/
Computing Pareto sets in Perl 
----
Date-Darian-Mars-0.002
http://search.cpan.org/~zefram/Date-Darian-Mars-0.002/
the Darian calendar for Mars 
----
Date-ISO8601-0.003
http://search.cpan.org/~zefram/Date-ISO8601-0.003/
the three ISO 8601 numerical calendars 
----
Date-Tiny-1.04
http://search.cpan.org/~adamk/Date-Tiny-1.04/
A date object with as little code as possible 
----
DateTime-Format-Flexible-0.06
http://search.cpan.org/~thinc/DateTime-Format-Flexible-0.06/
DateTime::Format::Flexible - Flexibly parse strings and turn them into DateTime objects. 
----
DateTime-Tiny-1.04
http://search.cpan.org/~adamk/DateTime-Tiny-1.04/
A date object, with as little code as possible 
----
Devel-RemoteTrace-0.3
http://search.cpan.org/~pmakholm/Devel-RemoteTrace-0.3/
Attachable call trace of perl scripts (a.k.a) perldebguts by example 
----
Dist-Zilla-Plugin-MetaResources-0.01
http://search.cpan.org/~fayland/Dist-Zilla-Plugin-MetaResources-0.01/
Dist::Zilla with meta resources 
----
Dist-Zilla-Plugin-MetaResources-0.02
http://search.cpan.org/~fayland/Dist-Zilla-Plugin-MetaResources-0.02/
Dist::Zilla with meta resources 
----
Dist-Zilla-Plugin-Repository-0.01
http://search.cpan.org/~fayland/Dist-Zilla-Plugin-Repository-0.01/
Automatically sets repository URL from svn/svk/Git checkout for Dist::Zilla 
----
Dist-Zilla-Plugin-Repository-0.02
http://search.cpan.org/~fayland/Dist-Zilla-Plugin-Repository-0.02/
Automatically sets repository URL from svn/svk/Git checkout for Dist::Zilla 
----
Dist-Zilla-Plugin-Repository-0.03
http://search.cpan.org/~fayland/Dist-Zilla-Plugin-Repository-0.03/
Automatically sets repository URL from svn/svk/Git checkout for Dist::Zilla 
----
Encode-IMAPUTF7-1.02
http://search.cpan.org/~pmakholm/Encode-IMAPUTF7-1.02/
modification of UTF-7 encoding for IMAP 
----
Fey-ORM-0.24
http://search.cpan.org/~drolsky/Fey-ORM-0.24/
A Fey-based ORM 
----
Ganglia-Gmetric-XS-1.01
http://search.cpan.org/~hirose/Ganglia-Gmetric-XS-1.01/
send a metric value to gmond with libganglia C library 
----
Gtk2-ImageView-Browser-0.0.0
http://search.cpan.org/~vvelox/Gtk2-ImageView-Browser-0.0.0/
A image browser and widget based off of 'Gtk2::ImageView' 
----
IO-AIO-3.18
http://search.cpan.org/~mlehmann/IO-AIO-3.18/
Asynchronous Input/Output 
----
Internals-DumpArenas-0.08
http://search.cpan.org/~jjore/Internals-DumpArenas-0.08/
Dump perl memory 
----
KiokuDB-0.27
http://search.cpan.org/~nuffin/KiokuDB-0.27/
Object Graph storage engine 
----
Math-Cartesian-Product-1.006
http://search.cpan.org/~prbrenan/Math-Cartesian-Product-1.006/
Generate the cartesian product of zero or more lists. 
----
Moose-0.75
http://search.cpan.org/~drolsky/Moose-0.75/
A postmodern object system for Perl 5 
----
MooseX-Clone-0.04
http://search.cpan.org/~nuffin/MooseX-Clone-0.04/
Fine grained cloning support for Moose objects. 
----
Net-GitHub-0.09
http://search.cpan.org/~fayland/Net-GitHub-0.09/
Perl Interface for github.com 
----
Net-Hiveminder-0.07
http://search.cpan.org/~jesse/Net-Hiveminder-0.07/
Perl interface to hiveminder.com 
----
Net-Trac-0.12
http://search.cpan.org/~jesse/Net-Trac-0.12/
Interact with a remote Trac instance 
----
OP_0.20_02
http://search.cpan.org/~aayars/OP_0.20_02/
Objective Perl 5 (Overpowered) 
----
PDF-Burst-1.14
http://search.cpan.org/~leocharre/PDF-Burst-1.14/
create one pdf doc for each page in existing pdf document 
----
PDF-Burst-1.15
http://search.cpan.org/~leocharre/PDF-Burst-1.15/
create one pdf doc for each page in existing pdf document 
----
PDF-OCR-1.11
http://search.cpan.org/~leocharre/PDF-OCR-1.11/
DEPRECATED get ocr and images out of a pdf file 
----
PDF-OCR2-1.10
http://search.cpan.org/~leocharre/PDF-OCR2-1.10/
extract all text and all image ocr from pdf 
----
PDF-OCR2-1.11
http://search.cpan.org/~leocharre/PDF-OCR2-1.11/
extract all text and all image ocr from pdf 
----
PDF-OCR2-1.12
http://search.cpan.org/~leocharre/PDF-OCR2-1.12/
extract all text and all image ocr from pdf 
----
POE-Filter-LOLCAT-1.06
http://search.cpan.org/~bingos/POE-Filter-LOLCAT-1.06/
POE FILTR T SPEKK LIEK LOLCATZ. KTHNX! 
----
Package-Subroutine-0.16_2
http://search.cpan.org/~sknpp/Package-Subroutine-0.16_2/
minimalistic import/export and other util methods 
----
Padre-Plugin-Perl6-0.28
http://search.cpan.org/~azawawi/Padre-Plugin-Perl6-0.28/
Padre plugin for Perl6 
----
Pod-L10N-0.01
http://search.cpan.org/~argrath/Pod-L10N-0.01/
----
SSH-Batch-0.001
http://search.cpan.org/~agent/SSH-Batch-0.001/
Cluster operations based on parallel SSH, set and interval arithmetic 
----
SVG-Sparkline-0.2.6
http://search.cpan.org/~gwadej/SVG-Sparkline-0.2.6/
Create Sparklines in SVG 
----
Socialtext-Resting-Utils-0.19
http://search.cpan.org/~lukec/Socialtext-Resting-Utils-0.19/
Utilities for Socialtext REST APIs 
----
Syntax-Highlight-Perl6-0.041
http://search.cpan.org/~azawawi/Syntax-Highlight-Perl6-0.041/
Perl 6 Syntax Highlighter 
----
TAP-DOM-0.03
http://search.cpan.org/~schwigon/TAP-DOM-0.03/
TAP as document data structure. 
----
Test-Builder-Mock-Class-0.02
http://search.cpan.org/~dexter/Test-Builder-Mock-Class-0.02/
Simulating other classes for Test::Builder 
----
Test-Mock-Class-0.02
http://search.cpan.org/~dexter/Test-Mock-Class-0.02/
Simulating other classes 
----
Text-RecordParser-1.3.0
http://search.cpan.org/~kclark/Text-RecordParser-1.3.0/
read record-oriented files 
----
Text-SimpleTable-AutoWidth-0.01
http://search.cpan.org/~cub/Text-SimpleTable-AutoWidth-0.01/
Simple Eyecandy ASCII Tables with auto-width selection 
----
Text-SimpleTable-AutoWidth-0.02
http://search.cpan.org/~cub/Text-SimpleTable-AutoWidth-0.02/
Simple Eyecandy ASCII Tables with auto-width selection 
----
Time-Tiny-1.04
http://search.cpan.org/~adamk/Time-Tiny-1.04/
A time object, with as little code as possible 
----
Vim-Snippet-Converter-0.08
http://search.cpan.org/~cornelius/Vim-Snippet-Converter-0.08/
A Template Converter for Slippery Snippet Vim Plugin 
----
WWW-Curl-Simple-0.03
http://search.cpan.org/~andremar/WWW-Curl-Simple-0.03/
A simpler interface to WWW::Curl 
----
ex-lib-0.06
http://search.cpan.org/~mons/ex-lib-0.06/
The same as lib, but makes relative path absolute. 
----
prefork-1.03
http://search.cpan.org/~adamk/prefork-1.03/
Optimized module loading for forking or non-forking processes 


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/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Tue, 21 Apr 2009 07:12:27 GMT
From: tadmc@seesig.invalid
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <vleHl.8571$im1.3891@nlpi061.nbdc.sbc.com>

Outline
   Before posting to comp.lang.perl.misc
      Must
       - Check the Perl Frequently Asked Questions (FAQ)
       - Check the other standard Perl docs (*.pod)
      Really Really Should
       - Lurk for a while before posting
       - Search a Usenet archive
      If You Like
       - Check Other Resources
   Posting to comp.lang.perl.misc
      Is there a better place to ask your question?
       - Question should be about Perl, not about the application area
      How to participate (post) in the clpmisc community
       - Carefully choose the contents of your Subject header
       - Use an effective followup style
       - Speak Perl rather than English, when possible
       - Ask perl to help you
       - Do not re-type Perl code
       - Provide enough information
       - Do not provide too much information
       - Do not post binaries, HTML, or MIME
      Social faux pas to avoid
       - Asking a Frequently Asked Question
       - Asking a question easily answered by a cursory doc search
       - Asking for emailed answers
       - Beware of saying "doesn't work"
       - Sending a "stealth" Cc copy
      Be extra cautious when you get upset
       - Count to ten before composing a followup when you are upset
       - Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------

Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
    This newsgroup, commonly called clpmisc, is a technical newsgroup
    intended to be used for discussion of Perl related issues (except job
    postings), whether it be comments or questions.

    As you would expect, clpmisc discussions are usually very technical in
    nature and there are conventions for conduct in technical newsgroups
    going somewhat beyond those in non-technical newsgroups.

    The article at:

        http://www.catb.org/~esr/faqs/smart-questions.html

    describes how to get answers from technical people in general.

    This article describes things that you should, and should not, do to
    increase your chances of getting an answer to your Perl question. It is
    available in POD, HTML and plain text formats at:

     http://www.rehabitation.com/clpmisc.shtml

    For more information about netiquette in general, see the "Netiquette
    Guidelines" at:

     http://andrew2.andrew.cmu.edu/rfc/rfc1855.html

    A note to newsgroup "regulars":

       Do not use these guidelines as a "license to flame" or other
       meanness. It is possible that a poster is unaware of things
       discussed here.  Give them the benefit of the doubt, and just
       help them learn how to post, rather than assume that they do 
       know and are being the "bad kind" of Lazy.

    A note about technical terms used here:

       In this document, we use words like "must" and "should" as
       they're used in technical conversation (such as you will
       encounter in this newsgroup). When we say that you *must* do
       something, we mean that if you don't do that something, then
       it's unlikely that you will benefit much from this group.
       We're not bossing you around; we're making the point without
       lots of words.

    Do *NOT* send email to the maintainer of these guidelines. It will be
    discarded unread. The guidelines belong to the newsgroup so all
    discussion should appear in the newsgroup. I am just the secretary that
    writes down the consensus of the group.

Before posting to comp.lang.perl.misc
  Must
    This section describes things that you *must* do before posting to
    clpmisc, in order to maximize your chances of getting meaningful replies
    to your inquiry and to avoid getting flamed for being lazy and trying to
    have others do your work.

    The perl distribution includes documentation that is copied to your hard
    drive when you install perl. Also installed is a program for looking
    things up in that (and other) documentation named 'perldoc'.

    You should either find out where the docs got installed on your system,
    or use perldoc to find them for you. Type "perldoc perldoc" to learn how
    to use perldoc itself. Type "perldoc perl" to start reading Perl's
    standard documentation.

    Check the Perl Frequently Asked Questions (FAQ)
        Checking the FAQ before posting is required in Big 8 newsgroups in
        general, there is nothing clpmisc-specific about this requirement.
        You are expected to do this in nearly all newsgroups.

        You can use the "-q" switch with perldoc to do a word search of the
        questions in the Perl FAQs.

    Check the other standard Perl docs (*.pod)
        The perl distribution comes with much more documentation than is
        available for most other newsgroups, so in clpmisc you should also
        see if you can find an answer in the other (non-FAQ) standard docs
        before posting.

    It is *not* required, or even expected, that you actually *read* all of
    Perl's standard docs, only that you spend a few minutes searching them
    before posting.

    Try doing a word-search in the standard docs for some words/phrases
    taken from your problem statement or from your very carefully worded
    "Subject:" header.

  Really Really Should
    This section describes things that you *really should* do before posting
    to clpmisc.

    Lurk for a while before posting
        This is very important and expected in all newsgroups. Lurking means
        to monitor a newsgroup for a period to become familiar with local
        customs. Each newsgroup has specific customs and rituals. Knowing
        these before you participate will help avoid embarrassing social
        situations. Consider yourself to be a foreigner at first!

    Search a Usenet archive
        There are tens of thousands of Perl programmers. It is very likely
        that your question has already been asked (and answered). See if you
        can find where it has already been answered.

        One such searchable archive is:

         http://groups.google.com/advanced_search

  If You Like
    This section describes things that you *can* do before posting to
    clpmisc.

    Check Other Resources
        You may want to check in books or on web sites to see if you can
        find the answer to your question.

        But you need to consider the source of such information: there are a
        lot of very poor Perl books and web sites, and several good ones
        too, of course.

Posting to comp.lang.perl.misc
    There can be 200 messages in clpmisc in a single day. Nobody is going to
    read every article. They must decide somehow which articles they are
    going to read, and which they will skip.

    Your post is in competition with 199 other posts. You need to "win"
    before a person who can help you will even read your question.

    These sections describe how you can help keep your article from being
    one of the "skipped" ones.

  Is there a better place to ask your question?
    Question should be about Perl, not about the application area
        It can be difficult to separate out where your problem really is,
        but you should make a conscious effort to post to the most
        applicable newsgroup. That is, after all, where you are the most
        likely to find the people who know how to answer your question.

        Being able to "partition" a problem is an essential skill for
        effectively troubleshooting programming problems. If you don't get
        that right, you end up looking for answers in the wrong places.

        It should be understood that you may not know that the root of your
        problem is not Perl-related (the two most frequent ones are CGI and
        Operating System related), so off-topic postings will happen from
        time to time. Be gracious when someone helps you find a better place
        to ask your question by pointing you to a more applicable newsgroup.

  How to participate (post) in the clpmisc community
    Carefully choose the contents of your Subject header
        You have 40 precious characters of Subject to win out and be one of
        the posts that gets read. Don't waste them. Take care while
        composing them, they are the key that opens the door to getting an
        answer.

        Spend them indicating what aspect of Perl others will find if they
        should decide to read your article.

        Do not spend them indicating "experience level" (guru, newbie...).

        Do not spend them pleading (please read, urgent, help!...).

        Do not spend them on non-Subjects (Perl question, one-word
        Subject...)

        For more information on choosing a Subject see "Choosing Good
        Subject Lines":

         http://www.cpan.org/authors/id/D/DM/DMR/subjects.post

        Part of the beauty of newsgroup dynamics, is that you can contribute
        to the community with your very first post! If your choice of
        Subject leads a fellow Perler to find the thread you are starting,
        then even asking a question helps us all.

    Use an effective followup style
        When composing a followup, quote only enough text to establish the
        context for the comments that you will add. Always indicate who
        wrote the quoted material. Never quote an entire article. Never
        quote a .signature (unless that is what you are commenting on).

        Intersperse your comments *following* each section of quoted text to
        which they relate. Unappreciated followup styles are referred to as
        "top-posting", "Jeopardy" (because the answer comes before the
        question), or "TOFU" (Text Over, Fullquote Under).

        Reversing the chronology of the dialog makes it much harder to
        understand (some folks won't even read it if written in that style).
        For more information on quoting style, see:

         http://web.presby.edu/~nnqadmin/nnq/nquote.html

    Speak Perl rather than English, when possible
        Perl is much more precise than natural language. Saying it in Perl
        instead will avoid misunderstanding your question or problem.

        Do not say: I have variable with "foo\tbar" in it.

        Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
        or I have $var = <DATA> (and show the data line).

    Ask perl to help you
        You can ask perl itself to help you find common programming mistakes
        by doing two things: enable warnings (perldoc warnings) and enable
        "strict"ures (perldoc strict).

        You should not bother the hundreds/thousands of readers of the
        newsgroup without first seeing if a machine can help you find your
        problem. It is demeaning to be asked to do the work of a machine. It
        will annoy the readers of your article.

        You can look up any of the messages that perl might issue to find
        out what the message means and how to resolve the potential mistake
        (perldoc perldiag). If you would like perl to look them up for you,
        you can put "use diagnostics;" near the top of your program.

    Do not re-type Perl code
        Use copy/paste or your editor's "import" function rather than
        attempting to type in your code. If you make a typo you will get
        followups about your typos instead of about the question you are
        trying to get answered.

    Provide enough information
        If you do the things in this item, you will have an Extremely Good
        chance of getting people to try and help you with your problem!
        These features are a really big bonus toward your question winning
        out over all of the other posts that you are competing with.

        First make a short (less than 20-30 lines) and *complete* program
        that illustrates the problem you are having. People should be able
        to run your program by copy/pasting the code from your article. (You
        will find that doing this step very often reveals your problem
        directly. Leading to an answer much more quickly and reliably than
        posting to Usenet.)

        Describe *precisely* the input to your program. Also provide example
        input data for your program. If you need to show file input, use the
        __DATA__ token (perldata.pod) to provide the file contents inside of
        your Perl program.

        Show the output (including the verbatim text of any messages) of
        your program.

        Describe how you want the output to be different from what you are
        getting.

        If you have no idea at all of how to code up your situation, be sure
        to at least describe the 2 things that you *do* know: input and
        desired output.

    Do not provide too much information
        Do not just post your entire program for debugging. Most especially
        do not post someone *else's* entire program.

    Do not post binaries, HTML, or MIME
        clpmisc is a text only newsgroup. If you have images or binaries
        that explain your question, put them in a publically accessible
        place (like a Web server) and provide a pointer to that location. If
        you include code, cut and paste it directly in the message body.
        Don't attach anything to the message. Don't post vcards or HTML.
        Many people (and even some Usenet servers) will automatically filter
        out such messages. Many people will not be able to easily read your
        post. Plain text is something everyone can read.

  Social faux pas to avoid
    The first two below are symptoms of lots of FAQ asking here in clpmisc.
    It happens so often that folks will assume that it is happening yet
    again. If you have looked but not found, or found but didn't understand
    the docs, say so in your article.

    Asking a Frequently Asked Question
        It should be understood that you may have missed the applicable FAQ
        when you checked, which is not a big deal. But if the Frequently
        Asked Question is worded similar to your question, folks will assume
        that you did not look at all. Don't become indignant at pointers to
        the FAQ, particularly if it solves your problem.

    Asking a question easily answered by a cursory doc search
        If folks think you have not even tried the obvious step of reading
        the docs applicable to your problem, they are likely to become
        annoyed.

        If you are flamed for not checking when you *did* check, then just
        shrug it off (and take the answer that you got).

    Asking for emailed answers
        Emailed answers benefit one person. Posted answers benefit the
        entire community. If folks can take the time to answer your
        question, then you can take the time to go get the answer in the
        same place where you asked the question.

        It is OK to ask for a *copy* of the answer to be emailed, but many
        will ignore such requests anyway. If you munge your address, you
        should never expect (or ask) to get email in response to a Usenet
        post.

        Ask the question here, get the answer here (maybe).

    Beware of saying "doesn't work"
        This is a "red flag" phrase. If you find yourself writing that,
        pause and see if you can't describe what is not working without
        saying "doesn't work". That is, describe how it is not what you
        want.

    Sending a "stealth" Cc copy
        A "stealth Cc" is when you both email and post a reply without
        indicating *in the body* that you are doing so.

  Be extra cautious when you get upset
    Count to ten before composing a followup when you are upset
        This is recommended in all Usenet newsgroups. Here in clpmisc, most
        flaming sub-threads are not about any feature of Perl at all! They
        are most often for what was seen as a breach of netiquette. If you
        have lurked for a bit, then you will know what is expected and won't
        make such posts in the first place.

        But if you get upset, wait a while before writing your followup. I
        recommend waiting at least 30 minutes.

    Count to ten after composing and before posting when you are upset
        After you have written your followup, wait *another* 30 minutes
        before committing yourself by posting it. You cannot take it back
        once it has been said.

AUTHOR
    Tad McClellan and many others on the comp.lang.perl.misc newsgroup.

-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Tue, 21 Apr 2009 09:37:03 +0200 (CEST)
From: January Weiner <january.weiner@gmail.com>
Subject: Problem in parsing from a pipe
Message-Id: <gsjt2v$mnv$2@sagnix.uni-muenster.de>

Hello there,

I have a small problem, which I can actually solve quite easily, but I am
looking for a more elegant solution.

I am reading from a pipe
  open( my $if, "$cmd|" ) or die "Cannot run $cmd: $!\n" ;

The output from this command is a series of records. Each record starts
with a recognizable line (e.g. I could catch it with /^Name=(\S+)/), but
does not have a "record end" marker. That is, I can only tell that a record
ended when a new record starts or when EOF is reached.

Now, I want to process the records one by one in one subroutine, calling
another one ("parse_record") to read exactly one record and return it:

  while( my $record = parse_record( $if ) ) {

    # ... do something with $record

  }

Normally, when reading a regular file, I do something like this in the
parse_record() function (see below[1] for example code): whenever I read a
line from $if, I store the position in file returned by tell() ; if I find
the beginning of the next record, I seek to the position prior to the
current line and return the current record.

Unfortunately, I can't seek in a pipe.  What I do instead is to return two
records ( the "current one", completely read, and the "next one", with a
stub from parsing the "record start" line), and then pass the "next record"
information to the parse_record() subroutine.

This is not elegant, as I would like to have the while() loop above to be
completely unaware of details of the parsing (e.g. I want to use it with
different parsers and file types).

One other solution that I was thinking of is to store this "next record"
line in a static variable. For example, I could make the whole parser OO,
and stored this "buffer" in a private variable.

Any other thing that I could do?

j.

[1] Example code 1:

  sub parse_record {
    my ( $if ) = @_ ;

    my $cur_record ;
    my $fpos ;

    while( <$if> ) {
      if( /^Name=(\S+)/ ) {
        if( $cur_record ) {    # we already have a record defined
          seek $if, $fpos, 0 ; # rewind so that the next instance of
                               # parse_record 
                               # we know $fpos is defined, because we have
                               # a previous record
          return $cur_record ;
        }

        $cur_record = { name => $1 } ;
        $fpos = tell $if ;
        next ;
      }

      next unless $cur_record ;
      $fpos = $cur_record ;

      # read the rest of the record here...
    }

    return $cur_record ;
  }





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

Date: Tue, 21 Apr 2009 10:42:53 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Problem in parsing from a pipe
Message-Id: <t1h0c6-mfi2.ln1@osiris.mauzo.dyndns.org>


Quoth January Weiner <january.weiner@gmail.com>:
> Hello there,
> 
> I have a small problem, which I can actually solve quite easily, but I am
> looking for a more elegant solution.
> 
> I am reading from a pipe
>   open( my $if, "$cmd|" ) or die "Cannot run $cmd: $!\n" ;
> 
> The output from this command is a series of records. Each record starts
> with a recognizable line (e.g. I could catch it with /^Name=(\S+)/), but
> does not have a "record end" marker. That is, I can only tell that a record
> ended when a new record starts or when EOF is reached.
> 
> Now, I want to process the records one by one in one subroutine, calling
> another one ("parse_record") to read exactly one record and return it:

If the "\nName=" part is unique (that is, the part which is a fixed
string rather than a pattern), the usual solution would be to treat the
separator as coming at the end rather than the beginning, and set $/ =
"\nName=". Reading 'lines' with <$if> will then give you records ending
with the delimiter, which are easy to convert into the 'expected' format
if you need that for the rest of the program.

>   while( my $record = parse_record( $if ) ) {
> 
>     # ... do something with $record
> 
>   }
> 
> Normally, when reading a regular file, I do something like this in the
> parse_record() function (see below[1] for example code): whenever I read a
> line from $if, I store the position in file returned by tell() ; if I find
> the beginning of the next record, I seek to the position prior to the
> current line and return the current record.
> 
> Unfortunately, I can't seek in a pipe.  What I do instead is to return two
> records ( the "current one", completely read, and the "next one", with a
> stub from parsing the "record start" line), and then pass the "next record"
> information to the parse_record() subroutine.
> 
> This is not elegant, as I would like to have the while() loop above to be
> completely unaware of details of the parsing (e.g. I want to use it with
> different parsers and file types).
> 
> One other solution that I was thinking of is to store this "next record"
> line in a static variable. For example, I could make the whole parser OO,
> and stored this "buffer" in a private variable.

If you don't want to use an object, you can easily create a 'static'
variable in Perl. If you have 5.10 you can use 'state', which is exactly
for this situation, otherwise you will need an extra block arond your
sub with a 'my' variable in it like

    {
        my $static;
        sub parse_record { ... }
    }

Ben



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

Date: Tue, 21 Apr 2009 09:42:31 +0200
From: Frank Seitz <devnull4711@web.de>
Subject: Re: What does `my' do?!
Message-Id: <755bn3F164rloU1@mid.individual.net>

Ben Morrow wrote:
> Quoth Frank Seitz <devnull4711@web.de>:
>> Tim McDaniel wrote:
>>> In article <753q48F15pqqlU1@mid.individual.net>,
>>> Frank Seitz  <devnull4711@web.de> wrote:
>>>> The scope of a lexical (my) variable begins AFTER the expression in
>>>> which it is declared, NOT inside the expression.
>>> I've seen that statement before, but it now seems unclear to me.  If
>>> it were strictly and completely true, I don't see how you could assign
>>> to a variable in a "my" [...]
>> Okay, I try to be more precise:
>>
>>     STMT;
>>
>> You can declare a lexical variable in STMT and - optionally -
>> assign a value to it, but nothing else. Within STMT you can't read it's value,
>> nor can you (re-)assign another value. The (real?) scope of the
>> variable begins after STMT.
> 
> You just *know* I have to argue with that, don't you :)?
> 
>     my $x;
>     $x = \(my $y = 3), 
>         # $y isn't in scope yet
>         $$x = 4;
>     say $y;
> 
> gives '4'

Oh no! What a dirty trick! ;)

> so you *can* assign to $y before the statement has ended. You
> just can't use the *name* $y to refer to it, as the name isn't in scope
> yet.

> Names have different scopes from variables. [1] The scope of the name begins
> at the end of the statement and ends at the end of the innermost
> containing block. [2] The scope of the variable begins when the 'my'
> expression is reached at runtime and ends when the last ref to it is
> removed

What you describe is - in computer science terminology - the difference
between the scope and the lifetime of a variable: [1] is the definition
of the *scope* and [2] is the definition of the *lifetime* of a
lexical varibale in Perl. As we see, this distinction is important.
The concepts should not be confused with one another.
When I say "scope", I mean [1].

> (it gets a temporary free pass for the remainder of its first
> statement, otherwise it would immediately vanish (actually, it always
> gets a free pass for the remainder of the statement in which it loses
> all refs. Consider
> 
>     use Scalar::Util qw/weaken/;
>     
>     my $x = [4];
>     my $wr = $x;
>     weaken $wr;
> 
>     $x = undef, my $y = $wr;
> 
>     say $wr;
> 
> and then replace that , with a ; .)).

I understand what happens, I think. But I don't understand what
this has to do with the scope (or the lifetime) of the
variables $x, $y or $wr.

Frank
-- 
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel


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

Date: Tue, 21 Apr 2009 10:50:21 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: What does `my' do?!
Message-Id: <tfh0c6-mfi2.ln1@osiris.mauzo.dyndns.org>


Quoth Frank Seitz <devnull4711@web.de>:
> Ben Morrow wrote:
> 
> > (it gets a temporary free pass for the remainder of its first
> > statement, otherwise it would immediately vanish (actually, it always
> > gets a free pass for the remainder of the statement in which it loses
> > all refs. Consider
> > 
> >     use Scalar::Util qw/weaken/;
> >     
> >     my $x = [4];
> >     my $wr = $x;
> >     weaken $wr;
> > 
> >     $x = undef, my $y = $wr;
> > 
> >     say $wr;
> > 
> > and then replace that , with a ; .)).
> 
> I understand what happens, I think. But I don't understand what
> this has to do with the scope (or the lifetime) of the
> variables $x, $y or $wr.

Sorry, it wasn't very clear. The 'variable' ('container', since Ilya'd
rather I call them that) of interest here is the anon array. A better
example (since it uses a 'real' named variable) might be

    my $y = do {
        my $wr = \my $x;
        weaken $wr;
        $wr;
    };
    say $y;

where $x isn't freed at the end of the 'do' block, despite only having
weak refs in scope at that point, as the freeing is delayed until the
final ';'. By that point it has acquired another strong ref (in $y) so
it isn't freed at all.

Ben



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

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 V11 Issue 2357
***************************************


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