how do i make a Multi Dimensional array? 
Author Message
 how do i make a Multi Dimensional array?

hiya

just wondering if everyone ever used one of these , and could shake some
code to explain it to me..

couldn't find anything in perlref & perldata :(

tnx in advance!
--
Bastiaan v/d Berg ; aka buZz
Internet Specialist
Account Software Consultancy




Sat, 01 Dec 2001 03:00:00 GMT  
 how do i make a Multi Dimensional array?
On Tue, 15 Jun 1999 09:15:34 +0200, "Bastiaan S van den Berg"

Quote:

>hiya

>just wondering if everyone ever used one of these , and could shake some
>code to explain it to me..

>couldn't find anything in perlref & perldata :(

Try perldsc (the Data Structures Cookbook), as well as "Programming
Perl".

HTH

Marcel



Sat, 01 Dec 2001 03:00:00 GMT  
 how do i make a Multi Dimensional array?


Quote:
> just wondering if everyone ever used one of these , and could shake some
> code to explain it to me..

> couldn't find anything in perlref & perldata :(

Try pod/perlol (lists of lists) :)

from that very document

"A list of lists, or an array of an array if you would, is just a regular

Here's a declaration of the array:

    # assign to our array a list of list references

           [ "fred", "barney" ],
           [ "george", "jane", "elroy" ],
           [ "homer", "marge", "bart" ],
    );

    print $LoL[2][2];
  bart

" ... and ..."



"

and so on



Sat, 01 Dec 2001 03:00:00 GMT  
 how do i make a Multi Dimensional array?
great , found it , tnx :)

you wouldn't be any chance know why this does work

$config = substr($ENV{'HTTP_COOKIE'},7) || print "Set-Cookie: config=1\n";

and this doesn't ?

$config = substr($ENV{'HTTP_COOKIE'},7) or { print "Set-Cookie: config=1\n";
                                             $config=1;
                                           };
i really need $config to be set
and i can't seem to be able to use

if !defined $config {$config=1};

--
Bastiaan v/d Berg ; aka buZz
Internet Specialist
Account Software Consultancy




Sat, 01 Dec 2001 03:00:00 GMT  
 how do i make a Multi Dimensional array?


Quote:
> you wouldn't be any chance know why this does work

> $config = substr($ENV{'HTTP_COOKIE'},7) || print "Set-Cookie: config=1\n";

> and this doesn't ?

> $config = substr($ENV{'HTTP_COOKIE'},7) or { print "Set-Cookie: config=1\n";
>                                              $config=1;
>                                            };

Something to do with the relative binding strengths of || and 'or' possibly

Look at

ftp://ftp.spu.edu/pub/CPAN/doc/manual/html/pod/perlop.html#C_style_Lo...

"
As more readable alternatives to && and || when used for control flow, Perl
provides and and or operators (see below). The short-circuit behavior is
identical. The precedence of ``and'' and ``or'' is much lower, however, so that
you can safely use them after a list operator without the need for parentheses:

    unlink "alpha", "beta", "gamma"
            or gripe(), next LINE;

With the C-style operators that would have been written like this:

    unlink("alpha", "beta", "gamma")
            || (gripe(), next LINE);

Use ``or'' for assignment is unlikely to do what you want.

"



Sat, 01 Dec 2001 03:00:00 GMT  
 how do i make a Multi Dimensional array?

Quote:
> great , found it , tnx :)

> you wouldn't be any chance know why this does work

> $config = substr($ENV{'HTTP_COOKIE'},7) || print "Set-Cookie: config=1\n";

> and this doesn't ?

> $config = substr($ENV{'HTTP_COOKIE'},7) or { print "Set-Cookie: config=1\n";
>                                              $config=1;
>                                            };

                                           ^
                                           |
                                       or do
/J\
--
"Two or three of our staff were stoned on their way to work" - British
Airways Spokesman


Sat, 01 Dec 2001 03:00:00 GMT  
 how do i make a Multi Dimensional array?

Quote:
>Something to do with the relative binding strengths of || and 'or' possibly

nope , that's not it , it doesn't work with || either , nor with or

hmm , maybe.. i'll get back to you :)

--
Bastiaan v/d Berg ; aka buZz
Internet Specialist
Account Software Consultancy




Sat, 01 Dec 2001 03:00:00 GMT  
 how do i make a Multi Dimensional array?

Quote:
>i really need $config to be set
>and i can't seem to be able to use

>if !defined $config {$config=1};

Maybe because you forgot the parentheses around the condition?

        Bart.



Sat, 01 Dec 2001 03:00:00 GMT  
 how do i make a Multi Dimensional array?


Quote:

> > you wouldn't be any chance know why this does work

> > $config = substr($ENV{'HTTP_COOKIE'},7) || print "Set-Cookie: config=1\n";

> > and this doesn't ?

> > $config = substr($ENV{'HTTP_COOKIE'},7) or { print "Set-Cookie: config=1\n";
> >                                              $config=1;
> >                                            };

> Something to do with the relative binding strengths of || and 'or' possibly

Not at all.  It has to do with basic syntax.  You cannot dump a BLOCK
arbitrarily in the middle of an expression.

   config = substr($ENV{'HTTP_COOKIE'},7) or do {
                                     print "Set-Cookie: config=1\n";
                                     $config=1;
                                   };

--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/



Sat, 01 Dec 2001 03:00:00 GMT  
 how do i make a Multi Dimensional array?

Quote:
> Not at all.  It has to do with basic syntax.  You cannot dump a BLOCK
> arbitrarily in the middle of an expression.

>    config = substr($ENV{'HTTP_COOKIE'},7) or do {
>                                      print "Set-Cookie: config=1\n";
>                                      $config=1;
>                                    };

Whoops, shudl have looked at the code more closley :(
--

Simon Wistow                      Developement

Phone:0171 700 9960        Fax:  0171 700 9961



Sat, 01 Dec 2001 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. arrays, multi-dimensional arrays, pointers and such

2. Associative arrays and multi-dimensional arrays.

3. Multi-Dimensional arrays, DBMs, and Assoc. Arrays

4. Extracting an array out of a multi-dimensional associative array

5. Multi-dimensional arrays.

6. multi-dimensional arrays in Perl 5

7. Multi dimensional arrays

8. Multi-Dimensional Arrays

9. Multi-dimensional arrays

10. MULTI-DIMENSIONAL Arrays

11. Multi-dimensional arrays

12. Linked list/multi-dimensional array emulation

 

 
Powered by phpBB® Forum Software