DML T-Shirts

From: Aaron Braun (zanphier@bellsouth.net)
Date: Sun Oct 24 1999 - 22:19:43 EDT


Well the idea is ready to roll, just need to see the interest and the
feedback script which 'splits' output into two streams, such
         as

             open(OUT,">$ARGV[0]") or die "Can't write to $ARGV[0]: $!";
             while (<STDIN>) {
                 print;
                 print OUT;
             }
             close OUT;

27/Feb/96 Last change: perl 45
none

PERLDSC(1) Perl Programmers Reference Guide PERLDSC(1)

NNNNAAAAMMMMEEEE
     perldsc - Perl Data Structures Cookbook

DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
     The single feature most sorely lacking in the Perl
     programming language prior to its 5.0 release was complex
     data structures. Even without direct language support, some
     valiant programmers did manage to emulate them, but it was
     hard work and not for the faint of heart. You could
     occasionally get away with the $m{$LoL,$b} notation borrowed
     from _a_w_k in which the keys are actually more like a single
     concatenated string "$LoL$b", but traversal and sorting were
     difficult. More desperate programmers even hacked Perl's
     internal symbol table directly, a strategy that proved hard
     to develop and maintain--to put it mildly.

     The 5.0 release of Perl let us have complex data structures.
     You may now write something like this and all of a sudden,
     you'd have a array with three dimensions!

         for $x (1 .. 10) {
             for $y (1 .. 10) {
                 for $z (1 .. 10) {
                     $LoL[$x][$y][$z] =
                         $x ** $y + $z;
                 }
             }
         }

     Alas, however simple this may appear, underneath it's a much
     more elaborate construct than meets the eye!

     How do you print it out? Why can't you just say print @LoL?
     How do you sort it? How can you pass it to a function or
     get one of these back from a function? Is is an object?
     Can you save it to disk to read back later? How do you
     access whole rows or columns of that matrix? Do all the
     values have to be numeric?

     As you see, it's quite easy to become confused. While some
     small portion of the blame for this can be attributed to the
     reference-based implementation, it's really more due to a
     lack of existing documentation with examples designed for
     the beginner.

     This document is meant to be a detailed but understandable
     treatment of the many different sorts of data structures you
     might want to develop. It should also serve as a cookbook
     of examples. That way, when you need to create one of these
     complex data structures, you can just pinch, pilfer, or
     purloin a drop-in example from here.

30/Jan/96 Last change: perl 1

PERLDSC(1) Perl Programmers Reference Guide PERLDSC(1)

     Let's look at each of these possible constructs in detail.
     There are separate documents on each of the following:

     +o arrays of arrays

     +o hashes of arrays

     +o arrays of hashes

     +o hashes of hashes

     +o more elaborate constructs

     +o recursive and self-referential data structures

     +o objects

     But for now, let's look at some of the general issues common
     to all of these types of data structures.

RRRREEEEFFFFEEEERRRREEEENNNNCCCCEEEESSSS
     The most important thing to understand about all data
     structures in Perl -- including multidimensional arrays--is
     that even though they might appear otherwise, Perl @ARRAYs
     and %HASHes are all internally one-dimensional. They can
     only hold scalar values (meaning a string, number, or a
     reference). They cannot directly contain other arrays or
     hashes, but instead contain _r_e_f_e_r_e_n_c_e_s to other arrays or
     hashes.

     You can't use a reference to a array or hash in quite the
     same way that you would a real array or hash. For C or C++
     programmers unused to distinguishing between arrays and
     pointers to the same, this can be confusing. If so, just
     think of it as the difference between a structure and a
     pointer to a structure.

     You can (and should) read more about references in the
     _p_e_r_l_r_e_f(1) man page. Briefly, references are rather like
     pointers that know what they point to. (Objects are also a
     kind of reference, but we won't be needing them right away-
     -if ever.) That means that when you have something that
     looks to you like an access to two-or-more-dimensional array
     and/or hash, that what's really going on is that in all
     these cases, the base type is merely a one-dimensional
     entity that contains references to the next level. It's
     just that you can _u_s_e it as though it were a two-dimensional
     one. This is actually the way almost all C multidimensional
     arrays work as well.

30/Jan/96 Last change: perl 2

PERLDSC(1) Perl Programmers Reference Guide PERLDSC(1)

         $list[7][12] # array of arrays
         $list[7]{string} # array of hashes
         $hash{string}[7] # hash of arrays
         $hash{string}{'another string'} # hash of hashes

     Now, because the top level only contains references, if you
     try to print out your array in with a simple _p_r_i_n_t()
     function, you'll get something that doesn't look very nice,
     like this:

         @LoL = ( [2, 3], [4, 5, 7], [0] );
         print $LoL[1][2];
       7
         print @LoL;
       ARRAY(0x83c38)ARRAY(0x8b194)ARRAY(0x8b1d0)

     That's because Perl doesn't (ever) implicitly dereference
     your variables. If you want to get at the thing a reference
     is referring to, then you have to do this yourself using
     either prefix typing indicators, like ${$blah}, @{$blah},
     @{$blah[$i]}, or else postfix pointer arrows, like $a->[3],
     $h->{fred}, or even $ob->_m_e_t_h_o_d()->[3].

CCCCOOOOMMMMMMMMOOOONNNN MMMMIIIISSSSTTTTAAAAKKKKEEEESSSS
     The two most common mistakes made in constructing something
     like an array of arrays is either accidentally counting the
     number of elements or else taking a reference to the same
     memory location repeatedly. Here's the case where you jus kicked
> it at about 35 so it dropped to first and then instead of shifting at 48
> mph, it kicked the rev limiter. Oops. That wasnt too impressive. I
> remember some of you had that problem, is it that front band. Man I dont
> want to have to pull the pan off again. The guy that put it in for me
> thinks it is the tranny cable that comes off of the TB. I cant remember
> which one it was ya'll said to adjust. Yes, I finally let someone else
work
> on my truck. I am doing some big time hours now and dont have the time I
> did in collage. Oh well.
>
> Bill
> '97 SS/T
> '81 Honda CB900F
> '75 Suzuki RE5 (still for sale, get it while its hot...)
>
>
> >From: Bob Tom <tigers@bserv.com>
> >Reply-To: dakota-truck@buffnet.net
> >To: dakota-truck@buffnet.net
> >Subject: Re: DML: new member, sort of
> >Date: Sun, 24 Oct 1999 07:01:54
> >
> >At 10:52 PM 10/23/99 EDT, you wrote:
> > > < S N I P > I just put a Transgo shift kit in my SS/T.
> > >Anyone else notice the 2/3 shift being a little harsh? < S N I P >
> >
> >Welcome back, Bill. I haven't noticed the 2/3 shift being a little
> >harsh either on the streets or at the track ... only that there
> >is a lot less slippage.
> >
> >Bob. Southern Ontario, Canada.
> >'97 FR CC Sport, 5.2L, 3.55 SG, auto.
> >Racing weight: 4,350lb ET: 14.934 Trap speed: 90.78 mph
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com



This archive was generated by hypermail 2b29 : Fri Jun 20 2003 - 12:18:15 EDT