[23850] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6053 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 30 06:10:42 2004

Date: Fri, 30 Jan 2004 03:05:06 -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           Fri, 30 Jan 2004     Volume: 10 Number: 6053

Today's topics:
        Best Perl Compiler and Program To Use? (wm2004)
    Re: Freelance PHP/MySQL developer is looking for job (Vorxion)
    Re: help with arrays to hash <krahnj@acm.org>
        how to check for ip address that falls inside a range. (mike)
    Re: how to check for ip address that falls inside a ran (Walter Roberson)
    Re: how to check for ip address that falls inside a ran <usenet@morrow.me.uk>
    Re: how to check for ip address that falls inside a ran <noreply@gunnar.cc>
    Re: how to check for ip address that falls inside a ran <tony_curtis32@_SPAMTRAP_yahoo.com>
    Re: how to check for ip address that falls inside a ran <kha@rogers.com>
    Re: How to get a listing of module functions <jwillmore@remove.adelphia.net>
    Re: How to get a listing of module functions <usenet@morrow.me.uk>
    Re: How to get a listing of module functions <tassilo.parseval@rwth-aachen.de>
    Re: How to get a listing of module functions <jwillmore@remove.adelphia.net>
    Re: Perl Module for phone modem <jwillmore@remove.adelphia.net>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
        Programmer's notebook: a taxonomy of error handling <irving_kimura@lycos.com>
    Re: Programmer's notebook: a taxonomy of error handling <BLOCKSPAMfishfry@your-mailbox.com>
    Re: Programmer's notebook: a taxonomy of error handling <tassilo.parseval@rwth-aachen.de>
        script to find the current directory <kannan_technical@yahoo.com>
    Re: script to find the current directory <todd@tdegruyl.com>
    Re: script to find the current directory <jurgenex@hotmail.com>
    Re: {ipc - windows} -| no such command? <ufo.removethisspamnote@quicknet.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 30 Jan 2004 09:50:27 GMT
From: mystical@zapo.net (wm2004)
Subject: Best Perl Compiler and Program To Use?
Message-Id: <401a28c5.8614265@news.accessv.com>

Which is the best perl compiler and programming tools to use?

Get An Online Business and Make Money!
Learn the secrets of many ordinary people who quit their day jobs to
pursue an online business. There are many affiliate programs to choose
from, but choose an interest you are passionate about and sell it
online! 

Please subscribe to the newsletter below for updates and news:

Subject: Subscribe To Internet Catalog Business
mystical@zapo.net

Or Click Here If You Have HTML mail enabled:
mailto:mystical@zapo.net?subject=Subscribe To Internet Catalog
Business


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

Date: 29 Jan 2004 23:34:20 -0500
From: vorxion@knockingshopofthemind.com (Vorxion)
Subject: Re: Freelance PHP/MySQL developer is looking for job
Message-Id: <4019decc_1@news.iglou.com>

In article <rVfSb.6$%W.528@nnrp1.ozemail.com.au>, David VB wrote:
>Alex C. wrote:
>
>> http://www.flitejobs.com/
>
>Looks quite nice but you have work to do in the HTML, fixing 
>accessibility issues, using css, etc. I'm guessing you mainly use 
>DreamWeaver - don't - it isn't a tool any professional should use.

CSS is a moving target.  Actually, CSS is quite stationary, it's the
browsers that are lacking.  It -pains- me to say it, but IE 5.5 and 6 do
the best job.  I've had less than perfect results with Mozilla and Opera.

And shouldn't any professional be writing their HTML by hand in vi or
emacs?  :)

-- 
Vorxion - Member of The Vortexa Elite


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

Date: Fri, 30 Jan 2004 06:45:02 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: help with arrays to hash
Message-Id: <4019FD5F.6790E0B2@acm.org>

jm wrote:
> 
> Looking for guidance.
> I have multiple arrays with data, and each element is directly associated
> with the
> same element number in the other arrays.  I want to be able to access the
> information
> for each company by the account number in @acctnum.
> Looks like I should be able to use hash of  hash, which I don't quite
> understand.
> I Looked at perldsc and it doesn't make sense to me how to accomplish this.
> Tried various ways of using my %HOH and always get errors.
> If this can be done, please point me in the right direction, or explain.

You probably want somthing like this:

use strict;
use warnings;

my @acctnums  = ( '000101',             '000102',        
'000103',          '000104',          '000105' );
my @companies = ( 'Flower Mart',        'Amigos',        
'Lacy\'s',         'Good Dairy',      'Western Wear' );
my @addresses = ( '1100 Fashion Drive', '544 Grand Ave.', '636 Miller
Ave.', '1536 Ocean View', '111 Camino Dr.' );
my @cities    = ( 'San Francisco',      'San Mateo',     
'Belmont',         'San Francisco',   'Burlingame' );
my @phonenums = ( '415-555-1234',       '650-555-1234',  
'650-555-4567',    '415-555-9876',    '650-555-5432' );

my %HoH;

@HoH{ @acctnums } = map { Company => $companies[ $_ ],
                          Address => $addresses[ $_ ],
                          City    => $cities[ $_ ],
                          Phone   => $phonenums[ $_ ],
                        }, 0 .. $#companies;



John
-- 
use Perl;
program
fulfillment


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

Date: 29 Jan 2004 18:43:28 -0800
From: s99999999s2003@yahoo.com (mike)
Subject: how to check for ip address that falls inside a range.
Message-Id: <dfd17ef4.0401291843.9179d79@posting.google.com>

hi

i need to verify if an ip-address falls inside a range for example,
say 10.1.1.1 to 10.1.2.255.
So if a user keys in 10.1.2.2, it should fall inside this range and
then the program can do something.

How can i go about declaring the range, and how can i check the ip
whether it falls inside the range. ?
thanks.


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

Date: 30 Jan 2004 03:36:29 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <bvcjft$oql$1@canopus.cc.umanitoba.ca>

In article <dfd17ef4.0401291843.9179d79@posting.google.com>,
mike <s99999999s2003@yahoo.com> wrote:
:i need to verify if an ip-address falls inside a range for example,
:say 10.1.1.1 to 10.1.2.255.
:So if a user keys in 10.1.2.2, it should fall inside this range and
:then the program can do something.

:How can i go about declaring the range, and how can i check the ip
:whether it falls inside the range. ?

for each of the three IP addresses, split the IP address on '\.',
say into @ipd; then
  $iaddr = pack('C4', $ipd[0], $ipd[1], $ipd[2], $ipd[3]);
gives the binary equivilent of the IP. Once you have all three,
it's just a matter of testing that the test ip is numerically
between the other two values.
-- 
   "No one has the right to destroy another person's belief by
   demanding empirical evidence."            -- Ann Landers


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

Date: Fri, 30 Jan 2004 03:47:50 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <bvck56$60d$1@wisteria.csv.warwick.ac.uk>


roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:
> In article <dfd17ef4.0401291843.9179d79@posting.google.com>,
> mike <s99999999s2003@yahoo.com> wrote:
> :i need to verify if an ip-address falls inside a range for example,
> :say 10.1.1.1 to 10.1.2.255.
> :So if a user keys in 10.1.2.2, it should fall inside this range and
> :then the program can do something.
> 
> :How can i go about declaring the range, and how can i check the ip
> :whether it falls inside the range. ?
> 
> for each of the three IP addresses, split the IP address on '\.',
> say into @ipd;

Or, better, use Regexp::Common.

Ben

-- 
And if you wanna make sense / Whatcha looking at me for?          (Fiona Apple)
                            * ben@morrow.me.uk *


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

Date: Fri, 30 Jan 2004 04:41:40 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <bvck8u$kijvq$1@ID-184292.news.uni-berlin.de>

mike wrote:
> i need to verify if an ip-address falls inside a range for example,
> say 10.1.1.1 to 10.1.2.255.

One idea:

     my $test = '10.1.2.2';
     my $lower = '10.1.1.1';
     my $higher = '10.1.2.255';

     sub iptest {
         my @ip = @_;
         for ( @ip ) {
             $_ = join '', map { sprintf '%03s', $_ } split /\./, $_;
         }
         $ip[0] >= $ip[1] and $ip[0] <= $ip[2] ? 1 : 0;
     }

     if ( iptest($test, $lower, $higher) ) {
         print "$test falls inside the range $lower to $higher.\n";
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 29 Jan 2004 21:55:24 -0600
From: Tony Curtis <tony_curtis32@_SPAMTRAP_yahoo.com>
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <87u12e9jkj.fsf@limey.hpcc.uh.edu>

>> On 29 Jan 2004 18:43:28 -0800,
>> s99999999s2003@yahoo.com (mike) said:

> hi i need to verify if an ip-address falls inside a range
> for example, say 10.1.1.1 to 10.1.2.255.  So if a user keys
> in 10.1.2.2, it should fall inside this range and then the
> program can do something.

> How can i go about declaring the range, and how can i check
> the ip whether it falls inside the range. ?  thanks.

http://search.cpan.org/

Take a look at NetAddr::IP and Net::IP::Match, one or both
might do what you want.

hth
t


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

Date: Fri, 30 Jan 2004 03:57:37 GMT
From: Kien Ha <kha@rogers.com>
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <RCkSb.6281$ef.5373@twister01.bloor.is.net.cable.rogers.com>

mike wrote:
> hi
> 
> i need to verify if an ip-address falls inside a range for example,
> say 10.1.1.1 to 10.1.2.255.
> So if a user keys in 10.1.2.2, it should fall inside this range and
> then the program can do something.
> 
> How can i go about declaring the range, and how can i check the ip
> whether it falls inside the range. ?
> thanks.


#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket qw(inet_aton);
 

my @ip_range = qw{ 10.1.1.1 10.1.2.255 };
my ($lower, $upper) = map { inet_aton($_) } @ip_range;
 

for ( qw{ 10.1.2.2 10.1.2.10 10.1.3.222 } ) {
   my $packed_ip = inet_aton($_);
   if ( $packed_ip lt $lower or $packed_ip gt $upper ) {
     print "$_ is out of expected range ",
           "$ip_range[0] .. $ip_range[1].\n";
     next;
   }
 

   print "$_ is in range.\n";
}


--
Kien



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

Date: Fri, 30 Jan 2004 04:27:07 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: How to get a listing of module functions
Message-Id: <pan.2004.01.30.09.27.06.320181@remove.adelphia.net>

On Thu, 29 Jan 2004 11:13:00 -0600, Web Surfer wrote:

<snip>
> But, given this list of modules how can you determine the functions that 
> are "defined" in any one paticular module ?

Why?  Are you looking for something in particular?

After creating a reference to an object, the reference applies to *only*
that module.  So, if you have two modules that have a method that's the
same name, only one will be called.

For example:

use Foo;
use Bar;

my $foo = new Foo;
my $bar = new Bar;

$foo->method(); #calls to Foo::method
$bar->method(); #calls to Bar::method

This *may* not apply if you import the methods into your namespace.  In
most cases, AFAIK, Perl will let you know if there's a problem.  Or, you
just use a method call like ...

Foo::method();
Bar::method();

But I doubt there are too many situations in which you'll have an issue or
have a need to call methods in this manner.

I said all this because I get the impression that you are trying to avoid
using a method name that's already in use by another module.

If that's not the case, the best bet on seeing what methods are available
in a module is to RTM on the module.

Of course, you *could* fashion a script to read each files of the module
(as listed in the packing list) and search for each instance of 'sub' :-)
But, that will take a long time and, IMHO, it doesn't have any real payoff
in the end.

HTH and please, someone correct me if I'm wrong.

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
When God endowed human beings with brains, He did not intend to
guarantee them. 



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

Date: Fri, 30 Jan 2004 09:56:24 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: How to get a listing of module functions
Message-Id: <bvd9o8$fgp$1@wisteria.csv.warwick.ac.uk>


jwillmore@adelphia.net wrote:
> On Thu, 29 Jan 2004 11:13:00 -0600, Web Surfer wrote:
> 
> <snip>
> > But, given this list of modules how can you determine the functions that 
> > are "defined" in any one paticular module ?
> 
> Why?  Are you looking for something in particular?
> 
> After creating a reference to an object, the reference applies to *only*
> that module.  So, if you have two modules that have a method that's the
> same name, only one will be called.

module != package != class.

Modules are not necessarily OO.

> For example:
> 
> use Foo;
> use Bar;
> 
> my $foo = new Foo;
> my $bar = new Bar;
> 
> $foo->method(); #calls to Foo::method
> $bar->method(); #calls to Bar::method
> 
> This *may* not apply if you import the methods into your namespace.

You cannot import a method. You import a sub into your namespace.

> In most cases, AFAIK, Perl will let you know if there's a problem.

Nope. You will get the last to be imported.

> Or, you just use a method call like ...
> 
> Foo::method();
> Bar::method();

This is not a method call, it is a sub call.

> If that's not the case, the best bet on seeing what methods are available
> in a module is to RTM on the module.

Yes.

Ben

-- 
   Razors pain you / Rivers are damp
   Acids stain you / And drugs cause cramp.                    [Dorothy Parker]
Guns aren't lawful / Nooses give
  Gas smells awful / You might as well live.                   ben@morrow.me.uk


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

Date: 30 Jan 2004 10:37:42 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: How to get a listing of module functions
Message-Id: <bvdc5m$h3n$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Ben Morrow:

> jwillmore@adelphia.net wrote:

>> After creating a reference to an object, the reference applies to *only*
>> that module.  So, if you have two modules that have a method that's the
>> same name, only one will be called.

[...]

>> Or, you just use a method call like ...
>> 
>> Foo::method();
>> Bar::method();
> 
> This is not a method call, it is a sub call.

I haven't followed this thread very closely, but maybe it's a good time
to mention that also methods can be package qualified:

    ethan@ethan:~$ perl -l
    package p1;
    sub test { print __PACKAGE__ }
    package p2;
    sub test { print __PACKAGE__ }
    package main;
    my $o = bless {} => "p1";
    $o->test;
    $o->p2::test;
    __END__
    p1
    p2

As I said, I am not sure how useful this is in the context of this
thread.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 30 Jan 2004 05:48:54 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: How to get a listing of module functions
Message-Id: <pan.2004.01.30.10.48.52.655794@remove.adelphia.net>

On Fri, 30 Jan 2004 09:56:24 +0000, Ben Morrow wrote:


> jwillmore@adelphia.net wrote:
>> On Thu, 29 Jan 2004 11:13:00 -0600, Web Surfer wrote:
<snip>

>> After creating a reference to an object, the reference applies to
>> *only* that module.  So, if you have two modules that have a method
>> that's the same name, only one will be called.
> 
> module != package != class.
> 
> Modules are not necessarily OO.
> 
>> For example:
>> 
>> use Foo;
>> use Bar;
>> 
>> my $foo = new Foo;
>> my $bar = new Bar;
>> 
>> $foo->method(); #calls to Foo::method $bar->method(); #calls to
>> Bar::method
>> 
>> This *may* not apply if you import the methods into your namespace.
> 
> You cannot import a method. You import a sub into your namespace.
 
<snip>
 
>> Or, you just use a method call like ...
>> 
>> Foo::method();
>> Bar::method();
> 
> This is not a method call, it is a sub call.

Okay ... I'll go back and read some more.

I get the impression from your post I'm not alone in mixing terms.

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Mustgo, n.:  Any item of food that has been sitting in the
refrigerator so long it has become a science project.   --
Sniglets, "Rich Hall & Friends" 


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

Date: Fri, 30 Jan 2004 04:33:51 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Perl Module for phone modem
Message-Id: <pan.2004.01.30.09.33.49.735009@remove.adelphia.net>

On Thu, 29 Jan 2004 15:19:49 -0500, Mark J Fenbers wrote:

> I've been tasked with writing code to dial telemetry equipment through a phone
> modem as a backup means to our existing method of acquiring data.  My plan is to
> use Perl on a Linux box to do this, but the last time I did this sort of stuff
> was years ago when Procomm+ was popular and network cables were not.
> 
> Is there a Perl Module available to make this coding task a bit easier for me??

I think so ... you could search http://search.cpan.org/ using the keyword
of 'modem' or 'serial'.  I seem to remember seeing one or two that may fit
the bill.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Majority, n.:  That quality that distinguishes a crime from a
law. 



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

Date: Fri, 30 Jan 2004 02:22:19 -0600
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <htWdnUBqv96miYfdRVn-vg@august.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.5 $)
    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://mail.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 

    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: Fri, 30 Jan 2004 02:55:29 +0000 (UTC)
From: Irving Kimura <irving_kimura@lycos.com>
Subject: Programmer's notebook: a taxonomy of error handling
Message-Id: <bvch31$mc6$1@reader2.panix.com>



(Note to the impatient: The connection with Perl doesn't emerge
until the end of this post.)

I find that nothing complicates and obfuscates my code more than
the problem of dealing with errors: user errors, system errors,
algorithm-design errors...

Just checking for the occurrence of errors and doing something dumb
like aborting the program is bad enough, but trying to make my code
fault-tolerant and/or make it generate reasonably helpful error
messages, turns my code into a horror show.  (If on top of this I
add CGI as the context, I begin to contemplate seppuku as the only
way to avoid disgrace.)

The truth of the matter is that I have yet to find a good way to
architect my error handling.  Granted, there are many types/levels
of error (as mentioned above) and handling each of these may require
an entirely different architecture.  It doesn't matter: I haven't
hit upon a good formula for any of them.

Now I'm at the stage of learning good Perl programming, which
includes reading good Perl source, so I would like to study examples
of Perl modules (from CPAN) with well-designed error-handling
schemes.

Any recommendations would be greatly appreciated.

Irv



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

Date: Fri, 30 Jan 2004 07:20:03 GMT
From: fishfry <BLOCKSPAMfishfry@your-mailbox.com>
Subject: Re: Programmer's notebook: a taxonomy of error handling
Message-Id: <BLOCKSPAMfishfry-238D04.23200229012004@netnews.comcast.net>

In article <bvch31$mc6$1@reader2.panix.com>,
 Irving Kimura <irving_kimura@lycos.com> wrote:

> (Note to the impatient: The connection with Perl doesn't emerge
> until the end of this post.)
> 
> I find that nothing complicates and obfuscates my code more than
> the problem of dealing with errors: user errors, system errors,
> algorithm-design errors...
> 
> Just checking for the occurrence of errors and doing something dumb
> like aborting the program is bad enough, but trying to make my code
> fault-tolerant and/or make it generate reasonably helpful error
> messages, turns my code into a horror show.  (If on top of this I
> add CGI as the context, I begin to contemplate seppuku as the only
> way to avoid disgrace.)
> 
> The truth of the matter is that I have yet to find a good way to
> architect my error handling.  Granted, there are many types/levels
> of error (as mentioned above) and handling each of these may require
> an entirely different architecture.  It doesn't matter: I haven't
> hit upon a good formula for any of them.
> 
> Now I'm at the stage of learning good Perl programming, which
> includes reading good Perl source, so I would like to study examples
> of Perl modules (from CPAN) with well-designed error-handling
> schemes.
> 
> Any recommendations would be greatly appreciated.

The best I've seen is the concept of try/catch/throw, borrowed from Java 
and C++. I think there's a library that implements the concept of 
exceptions in perl. The idea is that when an error occurs, a piece of 
code (method, subroutine, etc.) can throw an error of a particular type. 
The caller can elect to catch the error, or if not, control reverts up 
the call stack to the first caller who has elected to catch that error. 

In this way each individual module only handles certain errors, and 
passes others on up. So each module can decide how much error handling 
and what type of recovery procedure, if any, to implement.


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

Date: 30 Jan 2004 07:55:30 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Programmer's notebook: a taxonomy of error handling
Message-Id: <bvd2li$6nu$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Irving Kimura:

> (Note to the impatient: The connection with Perl doesn't emerge
> until the end of this post.)
> 
> I find that nothing complicates and obfuscates my code more than
> the problem of dealing with errors: user errors, system errors,
> algorithm-design errors...
> 
> Just checking for the occurrence of errors and doing something dumb
> like aborting the program is bad enough, but trying to make my code
> fault-tolerant and/or make it generate reasonably helpful error
> messages, turns my code into a horror show.  (If on top of this I
> add CGI as the context, I begin to contemplate seppuku as the only
> way to avoid disgrace.)
> 
> The truth of the matter is that I have yet to find a good way to
> architect my error handling.  Granted, there are many types/levels
> of error (as mentioned above) and handling each of these may require
> an entirely different architecture.  It doesn't matter: I haven't
> hit upon a good formula for any of them.
> 
> Now I'm at the stage of learning good Perl programming, which
> includes reading good Perl source, so I would like to study examples
> of Perl modules (from CPAN) with well-designed error-handling
> schemes.

If you are willing to look at a very huge module, then I recommend Mark
Overmeer's Mail::Box. In his class hierarchy every package inherits from
Mail::Reporter which implements error and warnings handling with a
pretty sophisticated system of priorities which decides whether a
particular warning/error is ignored or shown.

This approach however might not be applicable under all circumstances.
Sometimes you need something different. What you called dumb (namely
aborting the program when an error has been detected) might not be that
dumb really. When properly documented, you give the user a chance to
catch the error with a BLOCK-eval. Throwing exceptions happens through
die() or - more preferably - through Carp::croak(). In either case you
can have them throw objects instead of error-strings. The thrown object
ends up in $@:

    sub method_that_potentially_croaks {
        my $self = shift;
        ....
        if ($error) {
            my $err_obj = MyError->new( "Something went wrong", __LINE__, ...);
            Carp::croak $err_obj;
        }
        ...
    }

And somewhere else where you use the module that contains the above:

    eval {
        $obj->method_that_potentially_croaks;
    }
    if ($@) {
        print "Error: ", $@->as_string;
        print "  at ", $@->lineno;
        etc.
    }

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 30 Jan 2004 11:40:38 +0530
From: Kannan Ekanath <kannan_technical@yahoo.com>
Subject: script to find the current directory
Message-Id: <aEmSb.30$Os2.305@news.oracle.com>

Hi,
stuck up with this real sitter. can someone tell me how to find the full 
path of the current directory inside a pearl script (because the script 
can be called from different directories i just wanted to know the full 
path of the directory i.e, the caller).

saw things like
my @filelist = global("*");
to get the file list...is there any way to get the current directory
Right now i am using the alternative of pwd >> somefile and picking it 
up from there

Thanks
Kannan



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

Date: Fri, 30 Jan 2004 06:17:47 GMT
From: Todd de Gruyl <todd@tdegruyl.com>
Subject: Re: script to find the current directory
Message-Id: <fGmSb.11065$bx.4143@nwrdny02.gnilink.net>

Kannan Ekanath wrote:

> can someone tell me how to find the full path of the current directory

Here are two ways:

   use Cwd;         # more portable
   my $dir = cwd;

or

   my $dir = `pwd`; # assuming unix-like os here
   chomp $dir;

-- 
Todd de Gruyl


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

Date: Fri, 30 Jan 2004 06:26:23 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: script to find the current directory
Message-Id: <jOmSb.9496$AI.1381@nwrddc01.gnilink.net>

Kannan Ekanath wrote:
> stuck up with this real sitter. can someone tell me how to find the
> full path of the current directory [...]

perldoc Cwd

jue




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

Date: Fri, 30 Jan 2004 11:39:30 +0100
From: Steven Mocking <ufo.removethisspamnote@quicknet.nl>
Subject: Re: {ipc - windows} -| no such command?
Message-Id: <101kd33rldk785e@corp.supernews.com>

Ben Morrow wrote:

> 
> Steven Mocking <ufo.removethisspamnote@quicknet.nl> wrote:
>> Ben Morrow wrote:
>> > Have you tried the most recent version of Perl? I think this has
>> > improved quite a lot on Win32 in 5.8.
>> 
>> I'm using 5.8 all along. The fork emulation works, but not this.
> 
> OK, right.
> 
>> > Alternatively, you can use Win32::Process to invoke a command with the
>> > same std filehandles as the current process.
>> 
>> Hm I don't think that would be a good idea. I actually need refs to the
>> STDOUTs of the children in an array:
> 
> I think it's the only answer. Hang on... you're not execing anything,
> just using forking open? Right, that's easier.
> 
>> for(my $i = 1; $i < 20; $i++)
>> {
>>   my $handle[$i] = new IO::File;
> 
> This is never going to work. IO::File is for *file*-handles, and what
> you have here is a pipe.
> 
>>   my $pid = ($handle[$i]->open("-|"));
>>   next if ($pid); # Parent? Next patient!
>>   # <snip>Scan a port on 192.168.1.$i for a certain server...
>> }
> 
> # untested:
> 
> my @handle;
> for my $i (1..20) {
>     {
>         my $TMP;
>         pipe $handle[$i], $TMP   or die "pipe failed: $!";
>         my $pid = fork;
>         defined $pid             or die "fork failed: $!";
>         next if $pid;
>         open STDOUT, ">&=", $TMP or die "dup2 failed: $!";
>     }
>     # scan for server
> }

That gives me:

Unknown open() mode '>&='

-- 
We don't know one millionth of one percent about anything.


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

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


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