G
grocery_stocker
How are references and aliases in perl different than references in
aliases in C++?
aliases in C++?
grocery_stocker said:How are references and aliases in perl different than references in
aliases in C++?
Some differences (not exhaustive):
Aliases in Perl are like references in C++: a different way of
accessing the same object.
References in Perl are like pointers in C/C++: indirect access to an
object. However, in Perl you cannot do arithmetic on references the way
you can for C/C++ pointers (e.g. *(p++) = getchar()
In Perl, references are scalars, not separate pointer types as in C/C++.
In C/C++, arrays are really pointers to the first element in a
contiguous set of elements. In Perl, arrays are separate objects. A
reference to an array in Perl is different than a reference to one of
the members of the array.
In C/C++, arrays are really pointers to the first element in a
contiguous set of elements.
In Perl, arrays are separate objects. A
reference to an array in Perl is different than a reference to one of
the members of the array.
How are references and aliases in perl different than references in
aliases in C++?
And going off on a tanget, given something like
#!/usr/bin/perl -w
# global array definition
my @array = ("a","b","c");
sub print_array {
foreach my $element (@array) {
$element .= "9";
print $element . "\n";
}
}
for ($i = 0; $i < 3; $i++) {
&print_array();
}
How would I prevent $elment from modifying @array?
grocery_stocker said:my @array = ("a","b","c"); [...]
foreach my $element (@array) {
$element .= "9"; [...]
How would I prevent $elment from modifying @array?
Everytime I ask a question on the newsgroup, i keep on thinking "I'm
sure things would have been a lot easier if I would have taken more
than 6 week of FORTRAN."
I don't care what anyone says.
Learning to program on your own.
http://en.wikipedia.org/wiki/Sentence_(linguistics)
mastering the core concepts without formal
schooling, and then actually making it as a programmer takes a certain
level of skill and internal drive.
Not everyone has it.
True.
I think I only know a few people with no more than a high school
education that are doing the same kind of work, for the exact same
pay, as a person with an advanced degree in the sciences.
[ snip Jim's explanation ]
[ Do *NOT* quote sigs ]
Everytime I ask a question on the newsgroup, i keep on thinking "I'm
sure things would have been a lot easier if I would have taken more
than 6 week of FORTRAN."
I did do some FORTRAN programming almost 20 years ago. I am not sure
what you are getting at though.
Well, I am reminded of
http://www.catb.org/~esr/faqs/hacker-howto.html#believe5
Are you referring to yourself here?
I am not sure what "making it as a programmer" means above. On the other
hand, almost everyday at work is an opportunity for me to run into
someone who thinks he/she has made it as a programmer. I am not sure I
agree with those people's self-assessments.
The only thing that shows me is that the person with the advanced degree
in the sciences has chosen not to work in the field in which he/she
earned the degree.
Clearly, once one has a certain mental capability, whether one chooses
to invest time in an advanced degree is a matter of preference. Another
person with even superior mental capacity may choose not to "waste" five
to seven years toiling on a project which is of interest to only a few
people and which, as a norm, do not generate huge monetary returns on
that investment. This is why I do not put much stock in letters before
or after a person's name.
Achieving that goal also takes a certain level of skill and drive.
If I were you, I would not be so quick to pat myself on the back for
this particular reason until I were able to compete with Physics Ph.D.'s
in the fields in which they earned their degrees.
You can be proud of your achievements without resorting to this silly
argument.
Switching back to discussing Perl ... now.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.