[25171] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7420 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 18 18:05:54 2004

Date: Thu, 18 Nov 2004 15: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           Thu, 18 Nov 2004     Volume: 10 Number: 7420

Today's topics:
    Re: Complex datastructure documentation? <uri@stemsystems.com>
    Re: Complex datastructure documentation? <postmaster@castleamber.com>
    Re: Complex datastructure documentation? <dkoleary@olearycomputers.com>
    Re: Complex datastructure documentation? <dkoleary@olearycomputers.com>
    Re: Complex datastructure documentation? <uri@stemsystems.com>
    Re: Complex datastructure documentation? <1usa@llenroc.ude.invalid>
    Re: Complex datastructure documentation? <lawshouse.public@btconnect.com>
    Re: Complex datastructure documentation? <dkoleary@olearycomputers.com>
    Re: Complex datastructure documentation? <dkoleary@olearycomputers.com>
    Re: Complex datastructure documentation? <1usa@llenroc.ude.invalid>
    Re: Complex datastructure documentation? <uri@stemsystems.com>
    Re: Complex datastructure documentation? <autismuk@autismuk.muralichucks.freeserve.co.uk>
    Re: Complex datastructure documentation? <postmaster@castleamber.com>
    Re: Complex datastructure documentation? <uri@stemsystems.com>
    Re: die and write to log file (gumby)
        FAQ 7.1: Can I get a BNF/yacc/RE for the Perl language? <comdog@panix.com>
    Re: Hash of hash in perl (gumby)
    Re: how to get data from POST? <lawshouse.public@btconnect.com>
        Image Magick - Exception 445: pixel cache not open <tom.tingdale@sbcglobal.net>
    Re: perldoc problem on linux (Zhiliang Hu)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Nov 2004 19:09:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <x7hdnndlex.fsf@mail.sysarch.com>

>>>>> "DO" == Doug O'Leary <dkoleary@olearycomputers.com> writes:

  DO> Hey all;
  DO> I just finished a script for a client and will be working on the
  DO> documentation shortly.  The script uses a fairly complex data
  DO> structure that looks like:

  DO> #####################################################################
  DO> # Redesigned data structure.
  DO> #####################################################################
  DO> # %$hash:
  DO> # ${$hash}{Datalist} = \%datalist:
  DO> #    ${${$hash}{Datalist}}{$dl} = \%
  DO> #    ${${${$hash}{Datalist}}{$dl}}{host}  = $host
  DO> #    ${${${$hash}{Datalist}}{$dl}}{sid}  = $sid
  DO> #    ${${${$hash}{Datalist}}{$dl}}{suffix}  = $suffix
  DO> #    ${${${$hash}{Datalist}}{$dl}}{stream}  = $stream
  DO> #--------------------------------------------------------------------
  DO> # ${$hash}{Host}     = \%host_list;
  DO> #    ${${$hash}{Host}}{$host} = [ \@dls, \%sids ]
  DO> #    ${${${$hash}{Host}}{$host}}[0] = \@dls
  DO> #    ${${${$hash}{Host}}{$host}}[1] = \%sids
  DO> #    ${${${${$hash}{Host}}{$host}}[1]}{$sid}  = [ @dls, %lvs ]
  DO> #####################################################################

  DO> Does anyone have any tips on how I could document that 
  DO> clearly - for people that aren't used to complex data
  DO> structures in perl?


GACK!!

don't use that deref style in the docs or the code. that is impossible
to read. use something like this (untested):

	$hash->{Host}{$host}[0] = 'foo' ;

note how much more readable that is for both coding and documentation
purposes? no one uses the other deref style for anything more than 1
deep as it is impossible to parse out visually.

  DO> Any formatting/other hints/tips greatly appreciated.

use Data::Dumper to dump out example trees.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 18 Nov 2004 19:34:32 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <Xns95A58A0FA39D2castleamber@130.133.1.4>

Uri Guttman wrote:

>>>>>> "DO" == Doug O'Leary <dkoleary@olearycomputers.com> writes:

>   DO> #    ${${${$hash}{Datalist}}{$dl}}{stream}  = $stream
 
> GACK!!

>   DO> Any formatting/other hints/tips greatly appreciated.
> 
> use Data::Dumper to dump out example trees.

Rewrite it, to use OO programming.

Also, documentation should be your first step in design, not last.

I think with 3 or 4 classes you can make it way more readable and less 
error prone.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Thu, 18 Nov 2004 20:21:09 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <slrncpq11c.ci7.dkoleary@x1-6-00-b0-d0-c1-44-09.comcast.net>

On 2004-11-18, John Bokma <postmaster@castleamber.com> wrote:
>
> Rewrite it, to use OO programming.
>
> Also, documentation should be your first step in design, not last.
>
> I think with 3 or 4 classes you can make it way more readable and less 
> error prone.

Wow; I can only aspire to being good enough to critique code without
seeing it... That's truly impressive.  I will be certain to give your
thoughts all the consideration they're due.

Doug

-- 
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume:  http://home.comcast.net/~dkoleary/resume.html



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

Date: Thu, 18 Nov 2004 20:24:23 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <slrncpq171.cid.dkoleary@x1-6-00-b0-d0-c1-44-09.comcast.net>

On 2004-11-18, Uri Guttman <uri@stemsystems.com> wrote:
>
> GACK!!
>
> don't use that deref style in the docs or the code. that is impossible
> to read. use something like this (untested):
>
> 	$hash->{Host}{$host}[0] = 'foo' ;
>
> note how much more readable that is for both coding and documentation
> purposes? no one uses the other deref style for anything more than 1
> deep as it is impossible to parse out visually.
>

I've gotten used to it after all this time.  I'll try that way
though.  Thanks.

>  DO> Any formatting/other hints/tips greatly appreciated.
>
> use Data::Dumper to dump out example trees.

I'll look into it; thanks again.

Doug

-- 
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume:  http://home.comcast.net/~dkoleary/resume.html



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

Date: Thu, 18 Nov 2004 20:36:00 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <x7vfc2dhe7.fsf@mail.sysarch.com>

>>>>> "DO" == Doug O'Leary <dkoleary@olearycomputers.com> writes:

  DO> On 2004-11-18, Uri Guttman <uri@stemsystems.com> wrote:
  >> 
  >> GACK!!
  >> 
  >> don't use that deref style in the docs or the code. that is impossible
  >> to read. use something like this (untested):
  >> 
  >> $hash->{Host}{$host}[0] = 'foo' ;
  >> 
  >> note how much more readable that is for both coding and documentation
  >> purposes? no one uses the other deref style for anything more than 1
  >> deep as it is impossible to parse out visually.
  >> 

  DO> I've gotten used to it after all this time.  I'll try that way
  DO> though.  Thanks.

but no one else uses that style. think about it. code for yourself or
for others - which is more professional?

  DO> Any formatting/other hints/tips greatly appreciated.
  >> 
  >> use Data::Dumper to dump out example trees.

  DO> I'll look into it; thanks again.

anyone who does perl data structure stuff without using data::dumper as
a debugging tool is not doing it right. (YAML can be used too but it
isn't standard in the perl core).

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 18 Nov 2004 20:54:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Complex datastructure documentation?
Message-Id: <Xns95A5A1D619BAasu1cornelledu@132.236.56.8>

Doug O'Leary <dkoleary@olearycomputers.com> wrote in 
news:slrncpq11c.ci7.dkoleary@x1-6-00-b0-d0-c1-44-09.comcast.net:

> On 2004-11-18, John Bokma <postmaster@castleamber.com> wrote:
>>
>> Rewrite it, to use OO programming.
>>
>> Also, documentation should be your first step in design, not last.
>>
>> I think with 3 or 4 classes you can make it way more readable and less 
>> error prone.
> 
> Wow; I can only aspire to being good enough to critique code without
> seeing it... That's truly impressive.  I will be certain to give your
> thoughts all the consideration they're due.

I am not sure if you intended this to be a sarcastic remark but it does 
come accross that way.

There is no way you came up with the data structure you came up with 
through "good" design. Take John's recommendation to heart, figure out the 
relevant abstractions.

Sinan.


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

Date: Thu, 18 Nov 2004 21:03:59 +0000
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <5g3qp0hnu8diktu68cunvq69boqjv7ccl9@4ax.com>

On Thu, 18 Nov 2004 20:24:23 GMT, Doug O'Leary
<dkoleary@olearycomputers.com> wrote:

>I've gotten used to it after all this time.  

But surely the point that is being made in comments about this is that
*other* people aren't used to it, and by definition they are the ones
that are the target for your documentation?
-- 

Henry Law       <><     Manchester, England 


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

Date: Thu, 18 Nov 2004 21:16:14 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <slrncpq481.cm8.dkoleary@x1-6-00-b0-d0-c1-44-09.comcast.net>

On 2004-11-18, Uri Guttman <uri@stemsystems.com> wrote:
>
> but no one else uses that style. think about it. code for yourself or
> for others - which is more professional?

Actually, I usually code for other UNIX administrators.  This script,
for instance, talks to oracle databases, obtains a list of logical
volumes its using, then verifies/updates Omniback datalists to ensure
the databases are getting backed up correctly.

Another script, more complex code, but less complex data structure,
hits up to 1800 routers/switches via snmp every 5 minutes and runs a user
specified command if a user specified formula evaulates to true.

### Config file snip
IP = 1.1.1.1
Node  = rtr-01
Comm  = not_real_string
Formula = ((delta_Outqdrop.1) > CSCOoutbw.1 * .03) \
      || ((delta_Outqdrop.2) > CSCOoutbw.2 * .03) \
      || ((delta_Outqdrop.4) > CSCOoutbw.4 * .03)
Command = `$opcmsg node=$Node app=SNMP obj=SNMP msg_grp=SNMP severity=warning msg_text="Output queue drops > 3% bandwidth."`
### 

That client is still using that script - at least they were
two months ago when I talked to them last...

> anyone who does perl data structure stuff without using data::dumper as
> a debugging tool is not doing it right. (YAML can be used too but it
> isn't standard in the perl core).

I'm not sure I buy that 100%.  After figuring out what was needed, 
I was able to generate this data structure w/o errors first time running.
It read the config fiie, created the structure, then read it back out
again using simple loops and print statements..

######################################################################
#### Code to read hashes from hash_ref
######################################################################
# foreach my $dl (sort keys %{${$hash}{'Datalist'}})
# {   print "$dl\n\t";
#  printf ("\t%-8s  %-7s %-4s %d\n",
#     ${${${$hash}{'Datalist'}}{$dl}}{'Host'},
#     ${${${$hash}{'Datalist'}}{$dl}}{'Sid'},
#     ${${${$hash}{'Datalist'}}{$dl}}{'Suffix'} || "N/A",
#     ${${${$hash}{'Datalist'}}{$dl}}{'Stream'} || 1);
# }
# print "-" x 35 . "\n";
# foreach my $host (sort keys %{${$hash}{'Host'}})
# {   print "$host\n\tDatalists\n";
#  my $array_ref = \@{${${${$hash}{'Host'}}{$host}}[0]};
#  foreach my $dl (sort @{$array_ref})
#  {  print "\t\t$dl\n";   }
#  print "\tSids\n";
#  my $hash_ref = \%{${${${$hash}{'Host'}}{$host}}[1]};
#  foreach my $sid (sort keys %{$hash_ref})
#  {  print "\t\t$sid\n";
#     foreach my $dl (sort @{${${$hash_ref}{$sid}}[0]})
#     {  print "\t\t\t$dl\n"; }
#  }
# }
# print "-" x 35 . "\n";

data::dumper may do all that work for me; dunno.  I'll look into
it though.  So far, though, I haven't *needed* it - and all my 
scripts work the way they're supposed to..

Thanks again for the input, though.  I like learning new ways
to do things.

Doug


-- 
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume:  http://home.comcast.net/~dkoleary/resume.html



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

Date: Thu, 18 Nov 2004 21:29:28 GMT
From: Doug O'Leary <dkoleary@olearycomputers.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <slrncpq50f.cp6.dkoleary@x1-6-00-b0-d0-c1-44-09.comcast.net>

On 2004-11-18, A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
>
> I am not sure if you intended this to be a sarcastic remark but it does 
> come accross that way.
>
> There is no way you came up with the data structure you came up with 
> through "good" design. Take John's recommendation to heart, figure out the 
> relevant abstractions.

To be blatantly clear - Yes, it was meant to be sarcastic.  It was meant
that way and meant to be taken that way.  He has no logical basis for 
critiquing code he hasn't seen.  His attempt to do so, to me, proves 
that he jumps to conclusions without analyzing facts.  Therefore,
his opinions on this subject are ignored - and any further opinions
that I run into will be strenuously verified before being considered.

Much like you have no basis in logic for concluding that I developed 
this data structure through poor design.  You have no idea what process
was followed or not followed.  The only thing you have is a
complex datastructure implemented in a manner that, although not 
common, is, at least according to the  perl books, perfectly acceptable.
Proof, they say,  is in the fact that the code works.  Therefore,
your opinions, like John's, are now suspect.

As I've mentioned to Uri, I will examine rewriting the code to use
the C-style pointer syntax. Who know, I may like it better.  I may 
not, but still force myself to use it in order to make more easily
supported code.  But, no; I will  not take John's recommendation to heart.
Nor, will I listen to pedantic pinheads who critique code or procedures 
they haven't seen.

Have a nice day.

Doug


-- 
--------
Senior UNIX Admin
O'Leary Computer Enterprises
dkoleary@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume:  http://home.comcast.net/~dkoleary/resume.html



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

Date: 18 Nov 2004 21:38:46 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Complex datastructure documentation?
Message-Id: <Xns95A5A9552FF9asu1cornelledu@132.236.56.8>

Doug O'Leary <dkoleary@olearycomputers.com> wrote in
news:slrncpq50f.cp6.dkoleary@x1-6-00-b0-d0-c1-44-09.comcast.net: 

> On 2004-11-18, A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
>>
>> I am not sure if you intended this to be a sarcastic remark but it
>> does come accross that way.
>>
>> There is no way you came up with the data structure you came up with 
>> through "good" design. Take John's recommendation to heart, figure
>> out the relevant abstractions.
> 
> To be blatantly clear - Yes, it was meant to be sarcastic.  It was
> meant that way and meant to be taken that way.  He has no logical
> basis for critiquing code he hasn't seen.

You don't have to see the fish to smell that it is rotten.

> Nor, will I listen to pedantic pinheads who critique code or
> procedures they haven't seen.

Yup, that's me.

Sinan.


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

Date: Thu, 18 Nov 2004 21:39:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <x7fz36degi.fsf@mail.sysarch.com>

>>>>> "DO" == Doug O'Leary <dkoleary@olearycomputers.com> writes:

  DO> On 2004-11-18, Uri Guttman <uri@stemsystems.com> wrote:
  >> 
  >> but no one else uses that style. think about it. code for yourself or
  >> for others - which is more professional?

  DO> Actually, I usually code for other UNIX administrators.  This
  DO> script, for instance, talks to oracle databases, obtains a list of
  DO> logical volumes its using, then verifies/updates Omniback
  DO> datalists to ensure the databases are getting backed up correctly.

so do they do code review for you? i do it professionally and teach perl
and refactor it. no one uses that style of data structure code in any
depth.

  DO> Another script, more complex code, but less complex data
  DO> structure, hits up to 1800 routers/switches via snmp every 5
  DO> minutes and runs a user specified command if a user specified
  DO> formula evaulates to true.

so what if it works? it is not maintainable by anyone but you. sure some
could hack it but it is harder to work with than it needs to be.

  DO> Command = `$opcmsg node=$Node app=SNMP obj=SNMP msg_grp=SNMP severity=warning msg_text="Output queue drops > 3% bandwidth."`
  DO> ### 

  DO> That client is still using that script - at least they were
  DO> two months ago when I talked to them last...

so what? lots of bad code it used all the time. it is still bad code.


  >> anyone who does perl data structure stuff without using data::dumper as
  >> a debugging tool is not doing it right. (YAML can be used too but it
  >> isn't standard in the perl core).

  DO> I'm not sure I buy that 100%.  After figuring out what was needed,
  DO> I was able to generate this data structure w/o errors first time
  DO> running.  It read the config fiie, created the structure, then
  DO> read it back out again using simple loops and print statements..

fine. i can do that too. big deal. it is still not the best way to do
it.
  DO> #  printf ("\t%-8s  %-7s %-4s %d\n",
  DO> #     ${${${$hash}{'Datalist'}}{$dl}}{'Host'},
	    $hash->{'Datalist'}{$dl}{'Host'}

if you don't think the latter is clearer and easier to read, you must
have braces tattooed on your eyelids. it is shorter too.

  DO> data::dumper may do all that work for me; dunno.  I'll look into
  DO> it though.  So far, though, I haven't *needed* it - and all my 
  DO> scripts work the way they're supposed to..

dunno?? what about dumper wouldn't do? it dumps perl data structures. it
does it accurately. it is flexible. it is easy to use. its output can be
postprocessed easily. it can be eval'ed back into perl later.

  DO> Thanks again for the input, though.  I like learning new ways
  DO> to do things.

that is good. your structure skills do need you to learn more.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 18 Nov 2004 22:23:43 +0000
From: Paul Robson <autismuk@autismuk.muralichucks.freeserve.co.uk>
Subject: Re: Complex datastructure documentation?
Message-Id: <pan.2004.11.18.22.23.43.142707@autismuk.muralichucks.freeserve.co.uk>

On Thu, 18 Nov 2004 18:52:08 +0000, Doug O'Leary wrote:

> #####################################################################
> # Redesigned data structure.
> #####################################################################
> # %$hash:
> # ${$hash}{Datalist} = \%datalist:
> #    ${${$hash}{Datalist}}{$dl} = \%
> #    ${${${$hash}{Datalist}}{$dl}}{host}  = $host
> #    ${${${$hash}{Datalist}}{$dl}}{sid}  = $sid
> #    ${${${$hash}{Datalist}}{$dl}}{suffix}  = $suffix
> #    ${${${$hash}{Datalist}}{$dl}}{stream}  = $stream
> #--------------------------------------------------------------------
> # ${$hash}{Host}     = \%host_list;
> #    ${${$hash}{Host}}{$host} = [ \@dls, \%sids ]
> #    ${${${$hash}{Host}}{$host}}[0] = \@dls
> #    ${${${$hash}{Host}}{$host}}[1] = \%sids
> #    ${${${${$hash}{Host}}{$host}}[1]}{$sid}  = [ @dls, %lvs ]
> #####################################################################
> 
> Does anyone have any tips on how I could document that 
> clearly - for people that aren't used to complex data
> structures in perl?
> 
> Any formatting/other hints/tips greatly appreciated.

Err.... write it in English ? 

The documentation is uninformative and duplicates itself :-

{stream} = $stream could read 

{stream} the input stream, type is scalar, etc. i.e. explain what it is

Use the -> notation and remove the superfluous duplication :-

$hash->{DataList}->{<DataList Key>}->
					{host}	the host reference comment
					{sid}	the sid etc.
					{suffix} the suffix
					{stream} the stream




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

Date: 18 Nov 2004 22:28:51 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <Xns95A5A7A538156castleamber@130.133.1.4>

Doug O'Leary wrote:

> On 2004-11-18, John Bokma <postmaster@castleamber.com> wrote:
>>
>> Rewrite it, to use OO programming.
>>
>> Also, documentation should be your first step in design, not last.
>>
>> I think with 3 or 4 classes you can make it way more readable and
>> less error prone.
> 
> Wow; I can only aspire to being good enough to critique code without
> seeing it... That's truly impressive.  I will be certain to give your
> thoughts all the consideration they're due.

Things like:

${${${${$hash}{Host}}{$host}}[1]}{$sid}  = [ @dls, %lvs ]

Even if you write them using the -> notation are a pain in the lower
part to maintain and to read. 

You can just ignore my remarks however, I don't care.

But if interested, clarify what 

${${${${$hash}{Host}}{$host}}[1]}{$sid}  = [ @dls, %lvs ]

means, and I try to come up with an OO design. Maybe others can chip in
a bit too. 

And my other remark, regarding documentation is certainly valid. I just
finished a small OO thingy, which took more time on paper than to
actually implement :-) 

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Thu, 18 Nov 2004 22:56:42 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Complex datastructure documentation?
Message-Id: <x7r7mqbwba.fsf@mail.sysarch.com>

>>>>> "JB" == John Bokma <postmaster@castleamber.com> writes:

  JB> ${${${${$hash}{Host}}{$host}}[1]}{$sid}  = [ @dls, %lvs ]

  JB> means, and I try to come up with an OO design. Maybe others can chip in
  JB> a bit too. 

  JB> And my other remark, regarding documentation is certainly valid. I just
  JB> finished a small OO thingy, which took more time on paper than to
  JB> actually implement :-) 

i agree with your comments on the coding style but OO has absolutely
nothing to do with this. you could do OO stuff with the same clumsy
syntax he uses and it won't help. the design of the data structure and
its access syntax is orthogonal to OO design.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 18 Nov 2004 12:12:04 -0800
From: georgeziv@hotmail.com (gumby)
Subject: Re: die and write to log file
Message-Id: <878baabf.0411181212.4c0ce2ac@posting.google.com>

eight02645999@yahoo.com (justme) wrote in message news:<c0837966.0411180208.69ca8ac1@posting.google.com>...
> hi
> 
> usually when opening a file, we should check whether it can be opened
> open(FILE,"textfile.txt") or die "Cannot open for reading:$!\n";
> 
> how can i also pipe a error message to a log file ? Something like "tee" ?
> 
> thanks...

Assuming the user can access the log file:

unless(open FILE, "textfile.txt")
{
   my $error = $!;
   appendErrorLog($error);
}

################
sub appendErrorLog
{
  my $error = @_;
   
  unless(open ERRORFILE ">>errorLog.txt")
  {
      #Cant even access the errorLog.  
  }

  print ERRORFILE "$error\n";
  close ERRORFILE;

}

You will want to customize this a bit.  For example getting the userid
would be a start.  Also there are cpan things that will do the same
thing.


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

Date: Thu, 18 Nov 2004 23:03:03 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 7.1: Can I get a BNF/yacc/RE for the Perl language?
Message-Id: <cnj9n7$q4k$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

7.1: Can I get a BNF/yacc/RE for the Perl language?

    There is no BNF, but you can paw your way through the yacc grammar in
    perly.y in the source distribution if you're particularly brave. The
    grammar relies on very smart tokenizing code, so be prepared to venture
    into toke.c as well.

    In the words of Chaim Frenkel: "Perl's grammar can not be reduced to
    BNF. The work of parsing perl is distributed between yacc, the lexer,
    smoke and mirrors."



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: 18 Nov 2004 12:44:32 -0800
From: georgeziv@hotmail.com (gumby)
Subject: Re: Hash of hash in perl
Message-Id: <878baabf.0411181244.21a4badd@posting.google.com>

Shashank Khanvilkar <shashank@mia.ece.uic.edu> wrote in message news:<cngjth$7h1$1@newsx.cc.uic.edu>...
> Hi,
> Any help is appreciated.
> I have data in the following format
> 
> A
>    B=2
>    C=3
> B
>    S=2
>    T=10
> ...
> 
> 
> I need to populate a hash data structure (%graph) in perl so that %graph 
> will have the form
> %graph = ( 
> 
> 	A => {B=>2,C=>3}, 
> 
> 	B => {S=>2,T=>10}
> }
> 
> Assume that I have a program that has read A in $A, B in $B and so on 
> and the integers in $int. Can I Do the following:
> 
> %graph{$A}{$B} = $int
> 
> to populate the above hash of the hash.
> Thanks
> Shashank

If you could give an example snipit of the code you are writing to
show how you are using the hash of hash.
I use these alot.  

The question will this work ? 
%graph{$A}{$B} = $int
Yes but you should do it like this
$graph{$A}{$B} = $int;
Extracting the keys might be the only speed bump.  
my @akeys = keys %graph;
my @bkeys = keys % {$graph{$A}};

Hope this helps


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

Date: Thu, 18 Nov 2004 19:17:46 +0000
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: how to get data from POST?
Message-Id: <8atpp0h1p98l0l8vdunkfg1oa164vtaev1@4ax.com>

On Thu, 18 Nov 2004 19:19:26 +0800, sam <sam.wun@authtec.net> wrote:

>Does anyone know how to use perl(CGI) script to retrieve data from POST 
>when the user click the Submit button in html form?

Yes!
-- 

Henry Law       <><     Manchester, England 


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

Date: Thu, 18 Nov 2004 22:51:45 GMT
From: Tom Tingdale <tom.tingdale@sbcglobal.net>
Subject: Image Magick - Exception 445: pixel cache not open
Message-Id: <e59qp0p7apiohulub87ifefslpvc4p48o1@4ax.com>

Hi, 

I am using Image Magick to process some image files. It has worked
very well for several weeks, but now I am getting an error "Exception
445: pixel cache not open". 

I think that I may need to manually set the cache to more than the
default 80MB, because these particular files are larger than the files
I have processed when it was working properly. They are 140-150MB in
size. I saw a parameter called "cache_size" (not exact name) that you
can set when reading the image file. I haven't tried it yet, but
thought maybe someone here could help me.

Thanks for any direction you can offer.

Tom


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

Date: 18 Nov 2004 14:43:09 -0800
From: zhilianghu@yahoo.com (Zhiliang Hu)
Subject: Re: perldoc problem on linux
Message-Id: <1daf0582.0411181443.31e51a18@posting.google.com>

James Willmore <jwillmore@fastmail.us> wrote in message news:<pan.2004.11.17.14.46.12.514340@fastmail.us>...
> (Please DON'T top-post - it's considered rude)
> On Wed, 17 Nov 2004 06:21:50 -0800, Zhiliang Hu wrote:
> <snip>
> > James Willmore's suggestion works: "perldoc -t WWW::Search | less"
>  --
> > Returns normal ducumentation.  However, without "less" it still returns
> > nothing except login prompt (i.e. "perldoc -t WWW::Search").
> > 
> > I don't seem to comprehend where the problem is (is "pager" a utility to
> > dispaly text like "less"/"more"?), could you suggest further?
> 
> If you're on a *nix system, there is an environment setting for which
> pager (more, less, some other paging application) to use for viewing
> documents.  
> 
> To find out if this variable is set, type:
> echo $PAGER
> 
> If you get just the command line back, this setting is missing and *may*
> cause a problem with viewing Perl documentation.  To set the variable to
> something "sane", type:
> (for BASH)
> export PAGER=`which less`
> (for CSH - I think ... I always seem to mess up the syntax because I try
> to avoid using C-Shell)
> setenv PAGER `which less`
> 
> This sets the environment variable to use `less` as your pager.
> 
> If this environment setting *is* set, then I'm not real sure what's going
> on :-(  My thinking is to check your permissions again - just to be sure. 
> On my system, they are set to ...
> 
> -r-xr-xr-x  1 root root 203 Oct 17 00:15 /usr/bin/perldoc
> 
> Past these directions, I'm not sure what else might be going on.
> 
> HTH
> 
> Jim

I am sorry I didn't know the difference posting on top or bottom - 
I learn some custom here.  Thanks Jim.

Here is what I did:

1.
UNIX> echo $PAGER
PAGER: Undefined variable. (1st glitch seems to be here)

2.
Put in my .cshrc: "setenv PAGER less" and sourced it.
=> "perldoc WWW::Search" still produced nothing but login prompt.
Same with full path "setenv PAGER /usr/bin/less", while I see
-rwxr-xr-x   1 root    root     131724 Sep  1  2003 /usr/bin/less

3.
I then tried to use "less" to see a file:
UNIX> less my_txt_file
=> it shows nothing but login prompt :0 (2nd glitch seems to be here)

But why "perldoc WWW:Search -t | less" works?  Hmm.. Interesting.

4.
Put in my .cshrc: "setenv PAGER more"
=> Now it works fine.

Thanks everyone for great helps and I appreciate this learning curve.
Something more to learn...

Zhiliang


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

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


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