> I still don't know how to declare arrays using only '$' instead of '@'
You can't. But you can store a *reference* to an array in a scalar. This will work: # the backslash ("\") returns a reference to the # variable, so this doesn't actually pass the array, # it passes a reference (pointer sort of) to the array. goodsub([EMAIL PROTECTED], $scalar); sub goodsub() { my ($array_ref,$scalar) = @_; # turns the ref back to an actual array. my @array = @{$array_ref}; # or use the array directly through the ref. # note that changes made through a ref will change # the original array. print $array_ref->[0]; } > Is it possible to write scripts using only '$' > instead of other prefix symbols? No, not the way you intend. You could use only references, but that wouldn't make sense. Rob -----Original Message----- From: gohaku [mailto:[EMAIL PROTECTED] Sent: Sunday, July 18, 2004 8:59 PM To: Perl Beginners Subject: Another Perl datatype headache ( scalars $, hashes %, and arrays @ ) Hi everyone, after writing perl scripts for about 3 years now, I still have trouble with the basic datatypes. I know that variables that start with '$' are scalars. This covers Hashes ($HASH{$key}), Arrays ( $_[0] ), and regular scalar values ( $foobar ); The code I write as well other's code is still unreadable to me even though I have followed examples from the Camel book, many other Perl books from O'Reilly and online references. I have also used perldoc on many occasions. There are still some things that haven't sunk in, such as: If I want to add Hash keys to another Hash, I do the following: %HASH = ( 1 => 'one' ); #NO BRACES OR ELSE.... %HASH2 = ( 2 => 'two' ); AGAIN, NO BRACES OR ELSE... @HASH2{ keys %HASH } = ""; #confusing, considering it's the symbol used for arrays To get the length of an array, it's $#array, not [EMAIL PROTECTED] or #$array. Usually, I use scalar @array; Problems with subroutines where the array is the first argument sub badsub() { my (@array,$scalar) = @_; #Pass Array last! #my ($scalar,@array) = @_: ... } I still don't know how to declare arrays using only '$' instead of '@' anyway, Is it possible to write scripts using only '$' instead of other prefix symbols? In other words, a php-style script written in perl Thanks in advance. -gohaku -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>