well thanks for the explanation.. I asked because we saw pointer in my last C class (buy the way I hate ANSI C).. and was wondering, when sending an array of let's say 6 strings, if it would be faster to send the adress of this array, kind of like we do in C by using pointers.
Then the sub can modify the info at the location pointed by the adresse of the received pointer. So for now I think I'll stick with sending sub($value1, $value2); sub {my $foo, $bar) = @_ and if sometime I have something "big" to pass as an argument I'll check for using references.. Etienne Curtis Poe wrote: > > --- Etienne Marcotte <[EMAIL PROTECTED]> wrote: > > This is a very newbie question.. > > > > When sending arguments to a sub, is it preferable to send a pointer to > > this value or the value itself. Or after x arguments it's better to send > > references? > > > > Etienne > > Etienne, > > I think Brett W. McCoy gave an excellent answer to your question. I just have one >point to > clarify: in Perl, we do not have pointers (the analogue is called a reference) in >the sense that > you might see them in C. For example, in C, you can directly manipulate the value >of a pointer to > access other areas of memory. This is not possible in Perl: > > my @array = qw/ 1 2 3 4 /; > my $scalar_ref = \$var; > $scalar_ref++; # WRONG! > > Example of output: > > C:\>perl -e "$z=[qw/1 2 3 4/];print $z" > ARRAY(0x1a7f018) > > C:\>perl -e "$z=[qw/1 2 3 4/];print ++$z" > 27783193 > > I assume you know this, but I thought I would toss that out there, in case you >weren't. > > Cheers, > Curtis "Ovid" Poe > > ===== > Senior Programmer > Onsite! Technology (http://www.onsitetech.com/) > "Ovid" on http://www.perlmonks.org/ > > __________________________________________________ > Do You Yahoo!? > Find the one for you at Yahoo! Personals > http://personals.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]