[28573] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9937 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 7 06:05:54 2006

Date: Tue, 7 Nov 2006 03:05:08 -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           Tue, 7 Nov 2006     Volume: 10 Number: 9937

Today's topics:
    Re: force IV to NV <attn.steven.kuo@gmail.com>
    Re: force IV to NV <attn.steven.kuo@gmail.com>
    Re: force IV to NV <attn.steven.kuo@gmail.com>
    Re: force IV to NV <abigail@abigail.be>
        Help in regular expression <shafa.fahad@gmail.com>
    Re: Huge Memory Load for reading into memory xhoster@gmail.com
    Re: Huge Memory Load for reading into memory (reading news)
    Re: Keep getting error with email validation script <cdalten@gmail.com>
        new CPAN modules on Tue Nov  7 2006 (Randal Schwartz)
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
        process subregions on an image/matrix <alexxx.magni@gmail.com>
    Re: Putting a line in a specific place in a file (reading news)
    Re: Putting a line in a specific place in a file <rvtol+news@isolution.nl>
    Re: Question on having the hash not butt plug my comput <cdalten@gmail.com>
        TokeParser kjhjhjhjadsasda@urbanhabit.com
    Re: warnings or -w ? <josef.moellers@fujitsu-siemens.com>
    Re: What is more detailled than $^O ? <ynl@nsparks.net>
    Re: What is more detailled than $^O ? <ynl@nsparks.net>
    Re: What is more detailled than $^O ? <emschwar@pobox.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 6 Nov 2006 18:37:09 -0800
From: "attn.steven.kuo@gmail.com" <attn.steven.kuo@gmail.com>
Subject: Re: force IV to NV
Message-Id: <1162867029.493400.206340@f16g2000cwb.googlegroups.com>

Martin Mohr wrote:
> Hello,
>
> to work around a problem I'm having with SDL::OpenGL (see earlier
> thread), I'd like to know a way to force an integer value (IV) to become
> a double value (NV). It's not as easy as I first thought:
>
> perl -MDevel::Peek -e "$a = 1;$a+=0.0; Dump $a"
>
> This shows that $a remains IV. How can I achive this cast?



I suspect that is due to 0.0 having an exact
binary representation.  You can try another
operand for addition -- one that doesn't
have an exact binary representation:

$ perl -MDevel::Peek -le '$z = 1; $z = $z - 0.1 + 0.1; Dump $z;'
SV = PVNV(0x147398) at 0x1291d8
  REFCNT = 1
  FLAGS = (NOK,pNOK)
  IV = 1
  NV = 1
  PV = 0

or

$  perl -MDevel::Peek -le '$z = 1; map sprintf("%0.2f",$_), ($z); Dump
$z;'
SV = PVNV(0x147380) at 0x1291d8
  REFCNT = 1
  FLAGS = (IOK,NOK,pIOK,pNOK)
  IV = 1
  NV = 1
  PV = 0

In the latter I'm using map in void context for the side-effect.

In any case, I don't think having an explicit "cast" is needed; perl
knows when it needs a NV and acts accordingly.

-- 
Hope this helps,
Steven



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

Date: 6 Nov 2006 18:50:02 -0800
From: "attn.steven.kuo@gmail.com" <attn.steven.kuo@gmail.com>
Subject: Re: force IV to NV
Message-Id: <1162865203.283565.320410@m7g2000cwm.googlegroups.com>

Martin Mohr wrote:
> Hello,
>
> to work around a problem I'm having with SDL::OpenGL (see earlier
> thread), I'd like to know a way to force an integer value (IV) to become
> a double value (NV). It's not as easy as I first thought:
>
> perl -MDevel::Peek -e "$a = 1;$a+=0.0; Dump $a"
>
> This shows that $a remains IV. How can I achive this cast?



I suspect that is due to 0.0 having an exact
binary representation.  You can try another
operand for addition -- one that doesn't
have an exact binary represenation:

$ perl -MDevel::Peek -le '$z = 1; $z = $z - 0.1 + 0.1; Dump $z;'
SV = PVNV(0x147398) at 0x1291d8
  REFCNT = 1
  FLAGS = (NOK,pNOK)
  IV = 1
  NV = 1
  PV = 0

or

$  perl -MDevel::Peek -le '$z = 1; map sprintf("%0.2f",$_), ($z); Dump
$z;'
SV = PVNV(0x147380) at 0x1291d8
  REFCNT = 1
  FLAGS = (IOK,NOK,pIOK,pNOK)
  IV = 1
  NV = 1
  PV = 0

In the latter I'm using map in void context for the side-effect.

In any case, I don't think having an explicit "cast" is needed; perl
knows when it needs a NV and acts accordingly.

-- 
Hope this helps,
Steven



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

Date: 6 Nov 2006 19:29:25 -0800
From: "attn.steven.kuo@gmail.com" <attn.steven.kuo@gmail.com>
Subject: Re: force IV to NV
Message-Id: <1162870165.768288.80350@e3g2000cwe.googlegroups.com>

attn.steven.kuo@gmail.com wrote:

>
> I suspect that is due to 0.0 having an exact
> binary representation.  You can try another
> operand for addition -- one that doesn't
> have an exact binary represenation:


Bah -- let me retract that.  I should
have said that 0.0 is more simply
represented as an integer and
perl somehow uses an integer there
instead of a floating point number.  Whether a floating
point number has an exact binary
representation or not has nothing to do with
it as I get the same results with:

$ perl -MDevel::Peek -le '$z = 1; $z + 0.5 - 0.5; Dump $z;'
SV = PVNV(0x1803880) at 0x1800f70
  REFCNT = 1
  FLAGS = (IOK,NOK,pIOK,pNOK)
  IV = 1
  NV = 1
  PV = 0



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

Date: 07 Nov 2006 06:47:58 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: force IV to NV
Message-Id: <slrnel0avv.rtp.abigail@alexandra.abigail.be>

Martin Mohr (mm@mohr.de) wrote on MMMMDCCCXV September MCMXCIII in
<URL:news:eioh4h$ruk$02$1@news.t-online.com>:
!!  Hello,
!!  
!!  to work around a problem I'm having with SDL::OpenGL (see earlier 
!!  thread), I'd like to know a way to force an integer value (IV) to become 
!!  a double value (NV). It's not as easy as I first thought:
!!  
!!  perl -MDevel::Peek -e "$a = 1;$a+=0.0; Dump $a"
!!  
!!  This shows that $a remains IV. How can I achive this cast?


There's no need to change an IV to an NV when adding two integers.
But there is on division:

  
  $ perl -MDevel::Peek -e '$a = 1;$a/=1; Dump $a'
  SV = PVNV(0x8182828) at 0x817fed4
    REFCNT = 1
    FLAGS = (NOK,pNOK)
    IV = 1
    NV = 1
    PV = 0


Abigail
-- 
BEGIN {my $x = "Knuth heals rare project\n";
       $^H {integer} = sub {my $y = shift; $_ = substr $x => $y & 0x1F, 1;
       $y > 32 ? uc : lc}; $^H = hex join "" => 2, 1, 1, 0, 0}
print 52,2,10,23,16,8,1,19,3,6,15,12,5,49,21,14,9,11,36,13,22,32,7,18,24;


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

Date: 7 Nov 2006 02:58:16 -0800
From: "Kimi" <shafa.fahad@gmail.com>
Subject: Help in regular expression
Message-Id: <1162897096.720736.109300@m73g2000cwd.googlegroups.com>

Hi,

I relatively new to perl and hence the regular expressions as well....

Can somebody help me understanding this re syntax, To be precise i need
to know what and all pattern the below expression matches to

 if ($string =~ /^(ORA-[0-9]+):.*/ || $string =~ /.*[
]+(ORA-[0-9]+):.*/ || $string =~ /^(Corrupt block)/)

Thanks in advance
Fahad



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

Date: 07 Nov 2006 04:48:44 GMT
From: xhoster@gmail.com
Subject: Re: Huge Memory Load for reading into memory
Message-Id: <20061106234955.187$B0@newsreader.com>

"rahulthathoo" <rahul.thathoo@gmail.com> wrote:
> Hi
> I am trying to load a 600MB file into memory through the below code.
> But when I do a top on the system, I see that over the duration of the
> program run, the memory usage is 7.5 Gigs!! the top command says: VIRT:
> 7449m and Res: 7.289m - of course I have 8GB of RAM at my disposal. But
> the point is why is this happening for a file which is only 600MB in
> size. Here is the code:
>
> open UM, MAP_FILE or die "Can't open Usermap.\n";
> my %mapHash;
> while(<UM>){
>         @tokens = split(/:/, $_);
>         $zHashKey = $tokens[0];
>         @zMovArr = split(/\s/, $tokens[1]);
>         $mapHash{$zHashKey} = [@zMovArr];
> }
> close UM;

You are storing one array (with an unknown number of scalars) for every
line. Arrays have overhead.  So do scalars (but not as much as arrays).
For small arrays or small scalars, the overhead can easily be greater than
the actual user-data.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Tue, 07 Nov 2006 05:22:01 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: Huge Memory Load for reading into memory
Message-Id: <ZJU3h.3294$L6.2035@newsread3.news.pas.earthlink.net>

On 11/06/2006 06:10 PM, rahulthathoo wrote:
> Hi
> I am trying to load a 600MB file into memory through the below code.
> But when I do a top on the system, I see that over the duration of the
> program run, the memory usage is 7.5 Gigs!! the top command says: VIRT:
> 7449m and Res: 7.289m - of course I have 8GB of RAM at my disposal. But
> the point is why is this happening for a file which is only 600MB in
> size. Here is the code:
> [...]

On your system, there is a document that discusses keeping memory usage 
low in Perl:

Start->Run->"perldoc -q memory"

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


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

Date: 6 Nov 2006 19:23:12 -0800
From: "grocery_stocker" <cdalten@gmail.com>
Subject: Re: Keep getting error with email validation script
Message-Id: <1162869792.015713.236520@m7g2000cwm.googlegroups.com>

Tad McClellan wrote:
> grocery_stocker <cdalten@gmail.com> wrote:
> >
> > Tad McClellan wrote:
> >> grocery_stocker <cdalten@gmail.com> wrote:
> >>
> >> > I
> >> > also figures since the OP is & to invoke the subroutine,
> >>
> >>
> >> What effect does using & on the function call have for the
> >> function that is being discussed?
> >>
> >
> > I forgot. I think it was something to do with the fact the OP was
> > already screwing himself using &..
>
>
> How was using & screwing him up?
>

Okay, this is late at night. I need to cook dinner and such. Here is
the best thing my minimum wage mind can came up with in terms of having
& screw himself. Say I modify the code such that:

#!/usr/bin/perl
use warnings;

#test value;
 my $email = "cdalten\@eecs\.berkeley\.edu";
my $screw = "la";

 sub valid_address($){
     my ($addr) = @_;
     my ($domain, $name, $valid);
     ($name, $domain) = (split/@/,$addr);
     $valid = 0;

#yes I know I should used fork()/exec;
     system("nslookup $domain");
 }

&valid_address($email, $screw);

Notice that the number of arguments passed the function don't match.
I'm sure you could imagine someone accidently passing more args to the
function that necessary. When I run the code, I get

miss_xtc@linux:~/perl> ./val.pl
Note:  nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead.  Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
Server:         63.93.96.20
Address:        63.93.96.20#53

Non-authoritative answer:
Name:   eecs.berkeley.edu
Address: 169.229.60.27
Name:   eecs.berkeley.edu
Address: 169.229.60.161

The computer lets this code pass.

Now I remove the & from valid_address
#!/usr/bin/perl
use warnings;

#test value;
 my $email = "cdalten\@eecs\.berkeley\.edu";
my $screw = "la";

 sub valid_address($){
     my ($addr) = @_;
     my ($domain, $name, $valid);
     ($name, $domain) = (split/@/,$addr);
     $valid = 0;

#yes I know I should used fork()/exec;
     system("nslookup $domain");
 }

#note, no & thingy.
valid_address($email, $screw);

Now, when I run the code, I get
miss_xtc@linux:~/perl> ./val.pl
Too many arguments for main::valid_address at ./val.pl line 18, near
"$screw)"
Execution of ./val.pl aborted due to compilation errors.

Look, it won't pass. Maybe another time I'll take up more one the whole
system() thingy. Did I miss the point? Look at me from the side, does
the dress make my ass look big?



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

Date: Tue, 7 Nov 2006 05:42:10 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Nov  7 2006
Message-Id: <J8CIIA.1oLL@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.

Astro-SpaceTrack-0.026
http://search.cpan.org/~wyant/Astro-SpaceTrack-0.026/
Retrieve orbital data from www.space-track.org.
----
Business-CUSIP-1.03
http://search.cpan.org/~tayers/Business-CUSIP-1.03/
Verify Committee on Uniform Security Identification Procedures Numbers
----
CPAN-Reporter-0.30
http://search.cpan.org/~dagolden/CPAN-Reporter-0.30/
Provides Test::Reporter support for CPAN.pm
----
CPAN-Reporter-0.31
http://search.cpan.org/~dagolden/CPAN-Reporter-0.31/
Provides Test::Reporter support for CPAN.pm
----
Catalyst-Model-File-0.05
http://search.cpan.org/~ash/Catalyst-Model-File-0.05/
File based storage model for Catalyst.
----
Catalyst-Plugin-CGI-Untaint-0.03
http://search.cpan.org/~tjc/Catalyst-Plugin-CGI-Untaint-0.03/
Plugin for Catalyst
----
Catalyst-Plugin-Session-Store-File-0.10
http://search.cpan.org/~esskar/Catalyst-Plugin-Session-Store-File-0.10/
File storage backend for session data.
----
Catalyst-Runtime-5.7004
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7004/
Catalyst Runtime version
----
DBIx-Class-FormatColumns-0.02
http://search.cpan.org/~esskar/DBIx-Class-FormatColumns-0.02/
Creates format accessors for you
----
DBIx-Class-Tree-0.01000
http://search.cpan.org/~bluefeet/DBIx-Class-Tree-0.01000/
Manipulate and anaylze tree structured data. (EXPERIMENTAL)
----
DBIx-ORM-Declarative-0.13
http://search.cpan.org/~jschneid/DBIx-ORM-Declarative-0.13/
Perl extension for object-oriented database access
----
Data-Page-Tied-2.01
http://search.cpan.org/~smueller/Data-Page-Tied-2.01/
Tied interface for the Data::Page module
----
DateTime-TimeZone-0.55
http://search.cpan.org/~drolsky/DateTime-TimeZone-0.55/
Time zone object base class and factory
----
Drupal-Module-Starter-0.06
http://search.cpan.org/~smcnabb/Drupal-Module-Starter-0.06/
Create Drupal Module starter files
----
File-HomeDir-0.60_04
http://search.cpan.org/~adamk/File-HomeDir-0.60_04/
Find your home and other directories, on any platform
----
File-Remove-0.34
http://search.cpan.org/~adamk/File-Remove-0.34/
Remove files and directories
----
Geo-HelmertTransform-1.11
http://search.cpan.org/~mysociety/Geo-HelmertTransform-1.11/
----
HTML-Template-Compiled-0.82
http://search.cpan.org/~tinita/HTML-Template-Compiled-0.82/
Template System Compiles HTML::Template files to Perl code
----
HTML-Tested-0.19
http://search.cpan.org/~bosu/HTML-Tested-0.19/
Provides HTML widgets with the built-in means of testing.
----
HTTP-Server-Simple-Static-0.05
http://search.cpan.org/~sjquinney/HTTP-Server-Simple-Static-0.05/
Serve static files with HTTP::Server::Simple
----
Imager-Filter-Sepia-0.02
http://search.cpan.org/~kurihara/Imager-Filter-Sepia-0.02/
filter that convert to sepia tone.
----
Language-Mumps-1.08
http://search.cpan.org/~smueller/Language-Mumps-1.08/
Perl module to translate Mumps programs to perl scripts
----
Mail-Salsa-0.11
http://search.cpan.org/~hdias/Mail-Salsa-0.11/
An easy to use perl mailing list manager module.
----
Math-Polynom-0.01
http://search.cpan.org/~erwan/Math-Polynom-0.01/
Operations on polynoms
----
Nagios-Object-0.16
http://search.cpan.org/~tobeya/Nagios-Object-0.16/
----
Net-Z3950-ZOOM-1.13
http://search.cpan.org/~mirk/Net-Z3950-ZOOM-1.13/
Perl extension for invoking the ZOOM-C API.
----
ORM-0.84
http://search.cpan.org/~akimov/ORM-0.84/
Object relational mapper for Perl.
----
POE-Component-RSSAggregator-1.022
http://search.cpan.org/~jbisbee/POE-Component-RSSAggregator-1.022/
Watch Muliple RSS Feeds for New Headlines
----
PPM-2.1.8
http://search.cpan.org/~murray/PPM-2.1.8/
Perl Package Manager: locate, install, upgrade software packages.
----
Perl-Critic-Lax-0.001
http://search.cpan.org/~rjbs/Perl-Critic-Lax-0.001/
----
SWISH-API-More-0.04
http://search.cpan.org/~karman/SWISH-API-More-0.04/
do more with the SWISH::API
----
Sledge-View-0.06
http://search.cpan.org/~tokuhirom/Sledge-View-0.06/
abstract base class for Sledge's view(EXPERIMENTAL!!)
----
Sub-Assert-1.22
http://search.cpan.org/~smueller/Sub-Assert-1.22/
Design-by-contract like pre- and postconditions, etc.
----
Sub-PatternMatching-1.04
http://search.cpan.org/~smueller/Sub-PatternMatching-1.04/
Functional languages' Pattern Matching for Perl subs
----
Sub-Uplevel-0.14
http://search.cpan.org/~dagolden/Sub-Uplevel-0.14/
apparently run a function in a higher stack frame
----
Text-CSV-Separator-0.10
http://search.cpan.org/~enell/Text-CSV-Separator-0.10/
Determine the field separator of a CSV file
----
Text-Ngrams-1.9
http://search.cpan.org/~vlado/Text-Ngrams-1.9/
Flexible Ngram analysis (for characters, words, and more)
----
WWW-Translate-interNOSTRUM-0.01
http://search.cpan.org/~enell/WWW-Translate-interNOSTRUM-0.01/
Catalan < > Spanish machine translation
----
XML-RSS-Feed-2.212
http://search.cpan.org/~jbisbee/XML-RSS-Feed-2.212/
Persistant XML RSS Encapsulation
----
tidyview-1.11
http://search.cpan.org/~leif/tidyview-1.11/
a previewer for the effects of perltidy's plethora of options


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

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

print "Just another Perl hacker," # the original

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


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

Date: 07 Nov 2006 08:10:03 GMT
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.7 $)
Message-Id: <45503f5b$0$81350$ae4e5890@news.nationwide.net>

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.7 $)
    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.augustmail.com/~tadmc/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_group_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 <tadmc@augustmail.com> and many others on the
    comp.lang.perl.misc newsgroup.



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

Date: 7 Nov 2006 02:52:16 -0800
From: "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
Subject: process subregions on an image/matrix
Message-Id: <1162896736.818047.256000@f16g2000cwb.googlegroups.com>

Hi everybody, I need a bit of help on the programming side:

I'm trying to write a program to perform a filtering operation on an
image,
represented as a matrix of integers.
So I'm 1st thing writing a procedure that scans the image, and, when
finding a pixel in the color to be processed, it scans all the
neighboring pixels until all the cluster is processed (and, if its size
is in the correct range, it applies the transform).

Right now I perform this scanning of the cluster in the way I find most
elegant: recursion:

sub recurseinto
{
    my ($x,$y)=@_;
    my $c;

    $flag[$x][$y]=1;
    $c=1;

    if (($x-1>0)&&($flag[$x-1][$y]==0)&&($img[$x-1][$y]==$col)) { $c +=
recurseinto($x-1,$y) }
    if (($x+1<=$width)&&($flag[$x+1][$y]==0)&&($img[$x+1][$y]==$col)) {
$c += recurseinto($x+1,$y) }
    if (($y-1>0)&&($flag[$x][$y-1]==0)&&($img[$x][$y-1]==$col)) { $c +=
recurseinto($x,$y-1) }
    if (($y+1<=$height)&&($flag[$x][$y+1]==0)&&($img[$x][$y+1]==$col))
{ $c += recurseinto($x,$y+1) }
    return $c;

}

Well, it works, but - I hate to admit it - it's slow.

The question is: in which other way you would perform this task?

thanks for any info...

Alessandro Magni



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

Date: Tue, 07 Nov 2006 05:22:03 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: Putting a line in a specific place in a file
Message-Id: <%JU3h.3295$L6.2365@newsread3.news.pas.earthlink.net>

On 11/01/2006 07:39 AM, samasama wrote:
>   Hi... I need to place a line in a specific part of the file. I don't
> really know where to begin. Aside from feeding the file contents into
> an array?
> 
> 
> [base]
> name=CentOS-$releasever - Base
> mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
> #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
> gpgcheck=1
> gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
> exclude=httpd
> 
>  I need to find the [base] entry and then put the exclude= below the
> gpgkey=  line.
> 
> Any help is vastly appreciated. Any docs or turtorials about writing a
> parser would help too. 
> 
> Thanks
> 
> --
> samasama
> 

Read through the entire input file--writing it to a temporary output 
file as you go; keep track of what section you are in. When you get to 
the place where you need to add a line, print that line.

This demonstrates the reading and writing parts of the above:

#!/usr/bin/perl

use strict;
use warnings;

my $section;

while (my $line = <DATA>) {
     $section = $1 if $line =~ m/^\[(\w+)\]/;
     if (defined $section) {
         if ('management' eq $section) {
             if ($line =~ /^\s*$/) {
                 print "Treasurer=Mary Watson\n";
             }
         }
     }
     print $line;
}


__DATA__
[financial]
Assets=368,114
Liabilities=108,103
OwnersEquity=260,011

[management]
President=John Howard
VicePresident=John Orlando

[organization]
Name=Terrance Enterprises
Location=6192 Oak Blvd. Suite 616, Sydney, Australia


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


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

Date: Tue, 7 Nov 2006 11:33:52 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Putting a line in a specific place in a file
Message-Id: <eipqvj.1ho.1@news.isolution.nl>

Mumia W. (reading news) schreef:


>   my $section;
> 
>   while (my $line = <DATA>) {
>      $section = $1 if $line =~ m/^\[(\w+)\]/;

I guess you meant something like this:

      $section = ($line =~ m/^\[(\w+)\]/) ? $1 : undef ;

or even

      $section = ($line =~ m/^ \[ (\w+) \]/x)[0] ;

>      if (defined $section) {

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: 6 Nov 2006 19:53:05 -0800
From: "grocery_stocker" <cdalten@gmail.com>
Subject: Re: Question on having the hash not butt plug my computers memory
Message-Id: <1162871585.345331.150560@e3g2000cwe.googlegroups.com>


Brian McCauley wrote:
> On Nov 5, 6:27 pm, "grocery_stocker" <cdal...@gmail.com> wrote:
> > Given the following:
>
> [ object implementation ]
>
> > Okay, if modified the code to have something like:
>
> [ slightly different implementation ]
>
> > Would I still be creating more memory each time I invoked a new
> > instance of the object?
>
> Er, creating instanced of objects that store data will always occupy
> memory.
>
> What was your real question?

If I used gensym (via the Symbol package), then does each instance of
the object take up more memory. Say I create one object that takes up 3
things of memory via gensym. If I create another object via gensym,
would it create another three things of memory on top of the other
three things of memory (for a total of 6 things) like what an anonymous
hash would.



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

Date: 7 Nov 2006 00:49:14 -0800
From: kjhjhjhjadsasda@urbanhabit.com
Subject: TokeParser
Message-Id: <1162889353.926761.251190@f16g2000cwb.googlegroups.com>

Hi,

Im trying to use HTML::TokeParser to get all text with DIV tags, where
the DIV tag has class="x":

$stream=HTML::TokeParser->new(\$page);
while ($token=$stream->get_tag("div")) {
if ($token->[1]{class} eq "x") {
$text=$stream->get_trimmed_text("/div");
}
}

Problem with this is that it gives me the trimmed text obviously, eg
cleans away any html. I want everything with the DIV but cant find the
command for it in TokeParser...

Anyone know?

Thanks



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

Date: Tue, 07 Nov 2006 08:50:18 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: warnings or -w ?
Message-Id: <eipduu$8g8$2@nntp.fujitsu-siemens.com>

Yohan N Leder wrote:
> In article <Xns987369DDCC8DEasu1cornelledu@132.236.56.8>,=20
> 1usa@llenroc.ude.invalid says...
>=20
>>I see your plonk and raise you triple.
>>
>=20
>=20
> I'm beaten.

You could always shout "Ben Gurion", and reap all the money ;-)

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Tue, 7 Nov 2006 09:15:33 +0100
From: Yohan N Leder <ynl@nsparks.net>
Subject: Re: What is more detailled than $^O ?
Message-Id: <MPG.1fba5f141d4bd0f59898fa@news.tiscali.fr>

In article <g69k6281bu6.fsf@lifelogs.com>, tzz@lifelogs.com says...
> In non-Perl terms, this information is often in /etc.  The file
> /etc/issue in particular is often useful.
> 
> It's almost always better to test for tools and features than
> distributions anyhow.  If you need package X, don't assume it's
> installed, check.  For a web server, Apache for example, there's tools
> to tell you the version and compiled-in or loaded features.  Perl
> can't solve this problem in general terms AFAIK.
> 

Yes, but I don't want to test what feature is available or not. The fact 
is that some of the Perl CGI scripts we spread in our intranet and 
extranet have to proceed with reports from proprietaries logs in 
different trees depending of the specific linux distribution (actually : 
Ubuntu, Debian, Red Hat Ent, Fedora and Suse, but more in future). 

Also, some of these logs may have different signification depending of 
the current distribution (so, we can't simply check for file presence 
and deduct it's this or this distribution).

And, to facilitate the stuff, some of the servers may change from time 
to time (I mean, change of linux ditribution from multi-boot or raw 
change) and every admin has choice to keep of strip-out some parts of 
the logs tree I told about ; this without notice, so I can't maintain a 
simple database saying server #1 is under Debian, server #2 is under 
Fedora, etc.

Well, because of this specific context, I have to determinate what is 
the current linux ditribution (at least the 'main name' as said above, 
even if I can't know the version) up front of all. Never mind what are 
the available features or installed packages, it's not the information 
I'm looking for and our packages will run whatever be the config.


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

Date: Tue, 7 Nov 2006 09:16:13 +0100
From: Yohan N Leder <ynl@nsparks.net>
Subject: Re: What is more detailled than $^O ?
Message-Id: <MPG.1fba5f3d7cbb3e3f9898fb@news.tiscali.fr>

In article <slrnekvf09.rtp.abigail@alexandra.abigail.be>, 
abigail@abigail.be says...
> Then what? Just because it's Red Hat doesn't mean it has package X,
> and just it's Debian doesn't mean it doesn't have package X.
> 

Same reply as the one written for Ted :

Yes, but I don't want to test what feature is available or not. The fact 
is that some of the Perl CGI scripts we spread in our intranet and 
extranet have to proceed with reports from proprietaries logs in 
different trees depending of the specific linux distribution (actually : 
Ubuntu, Debian, Red Hat Ent, Fedora and Suse, but more in future). 

Also, some of these logs may have different signification depending of 
the current distribution (so, we can't simply check for file presence 
and deduct it's this or this distribution).

And, to facilitate the stuff, some of the servers may change from time 
to time (I mean, change of linux ditribution from multi-boot or raw 
change) and every admin has choice to keep of strip-out some parts of 
the logs tree I told about ; this without notice, so I can't maintain a 
simple database saying server #1 is under Debian, server #2 is under 
Fedora, etc.

Well, because of this specific context, I have to determinate what is 
the current linux ditribution (at least the 'main name' as said above, 
even if I can't know the version) up front of all. Never mind what are 
the available features or installed packages, it's not the information 
I'm looking for and our packages will run whatever be the config.


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

Date: 06 Nov 2006 16:24:49 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: What is more detailled than $^O ?
Message-Id: <874ptc2m66.fsf@aragorn.emschwar>

Abigail <abigail@abigail.be> writes:
> Yohan N Leder (ynl@nsparks.net) wrote on MMMMDCCCXV September MCMXCIII in
> <URL:news:MPG.1fb9c8bcec77a3639898f6@news.tiscali.fr>:
> __  In article <slrnekv9i1.rtp.abigail@alexandra.abigail.be>, 
> __  abigail@abigail.be says...
> __ > What is the "accurate linux distribution" anyway?
> __ > 
> __  
> __  At least something saying Red Hat, Fedora, Debian, Ubuntu, Suse, etc. 
> __  And better if it say also the major version number.
> 
> 
> Then what? Just because it's Red Hat doesn't mean it has package X,
> and just it's Debian doesn't mean it doesn't have package X.

If one is writing an installer, it might be useful to know if one is
to use yum, apt-get, or yast to install any dependencies, or which
package to prompt the user to install.  If one is writing a test
harness, it's often useful to be able to report to the person reading
the test results what distro was installed on the system under test.

> If you want to test for a specific feature, test for that feature.
> Don't assume that a specific Linux distro means something is available
> (or not available).

Generally I agree with you, and I wish more programs behaved that way,
but there are times it's simply not sufficient.

-=Eric



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

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


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