Xah Lee ([EMAIL PROTECTED]) wrote on MMMMCLII September MCMXCIII in <URL:news:[EMAIL PROTECTED]>: :: :: # in perl, list is done with paren ().
Wrong. Except in a few cases, parens don't make lists. Parens are used from precedence. *Context* makes lists. :: # the at sign in front of variable is necessary. The at sign in front of a variable means the variable is an array. Arrays are *NOT* lists. :: # it tells perl that it is a list. :: @a = (0,1,2,'three',4,5,6,7,8,9); :: :: # perl can't print lists. To show a list content, :: # load the package Data::Dumper, e.g. :: use Data::Dumper; :: print '@a is:', Dumper([EMAIL PROTECTED]); Utter bullshit. Perl's print statement has no problem accepting a list. In fact, YOUR EXAMPLE PASSES A LIST to print. But this works fine too: @a = ('Xah ', 'Lee ', 'does ', 'not ', 'know ', 'Perl'); print @a; __END__ Xah Lee does not know Perl :: # the backslash in front of @a is to tell Perl :: # that "get the "address" of the "array" @a". Wrong. Perl is not C. You get a reference, not a pointer. :: # it is necessary in Dumper because Dumper is :: # a function that takes a memory address. Wrong. Perl functions don't take memory addresses. Perl doesn't allow the programmer to do direct memory access. :: # see perldoc -t Data::Dumper for the intricacies :: # of the module. Please do so yourself. :: # to join two lists, just enclose them with () :: @b = (3,4); :: @c = (@a,@b); :: print '[EMAIL PROTECTED] is', Dumper [EMAIL PROTECTED]; :: # note: this does not create nested list. There is no such thing as "nested lists". :: # to extrat list element, append with [index] :: # the index can be multiple for multiple elements :: @b = @a[3,1,5]; :: print Dumper [EMAIL PROTECTED]; Why are you printing to the Dumper filehandle? :: # to replace parts, do :: $a[3]= 333; :: print ' is', Dumper [EMAIL PROTECTED]; :: # note the dollar sign. :: # this tells Perl that this data is a scalar :: # as opposed to a multiple. :: # in perl, variable of scalars such as numbers and strings :: # starts with a dollar sign, while arrays (lists) starts with Again, arrays are NOT lists. :: # a at @ sign. (and harshes/dictionaries starts with %) :: # all perl variables must start with one of $,@,%. Or *, or &. And some variables don't have a sigil in front of them. :: # one creates nested list by :: # embedding the memory address into the parent list :: @a=(1,2,3); :: @b = (4,5, [EMAIL PROTECTED], 7); :: print 'nested list is', Dumper [EMAIL PROTECTED]; Rubbish. That's not a nested list. @b is an *ARRAY*, whose third element is a *REFERENCE* to another *ARRAY*. :: # to extrat element from nested list, :: $c = $b[2]->[1]; :: print '$b[2]=>[1] is', $c; :: :: # the syntax of nested lists in perl is quite arty, see :: # perldoc -t perldata :: Xah Please Xah, do the Perl and Python communities a favour, and stop posting bullshit. Abigail -- perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %; BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}' -- http://mail.python.org/mailman/listinfo/python-list