it probably wasn't a good perl book if you learned all those poor perl
coding ideas. what book was it? there are tons of bad perl books and web
tutorials out there.
I've mentioned it several times in this thread, my book is "Learning
Perl" by Phoenix and Schwartz. One of the better solutions to my
problem (splitting code into more than one file), as it has been
recommended here a number of times, is the use of modules. In this book
modules are only mentioned as something prefabricated that one can use.
How to create them and in what situations to create them is not
mentioned in the book.
(I don't want to say modules are not important, I just want to say that
you can have read a decent book about Perl and don't know about the
importance of modules. And I know about it know, thanks to a lot of
helpful people in this thread.)
you have some major flaws in your perl understanding there. you don't
understand list vs scalar context and you don't 'call' an array.
That is exactly the kind of language that I appreciate in these kinds
of newsgroops and what keeps me coming back here...
'Calling an array' was figuratively speaking for using the name of an
array in some manner in one's code to access some kind of information
out of it or from it.
@array
is NOT reserved for anything. it is the array itself. but when it is
evaluated in a scalar context (see context is important in perl, very
important), it is the number of elements in the array.
Using the code '$variable = @array' and not '$variable = $array[0]' to
access the first variable of an array was an unneccessary mistake
(unneccessary in the sense that if I had been asked explicitly which of
the versions is the correct one I would have picked the correct one). I
do dozens of such mistakes every day, but in the end I find them all
(or find another way to code it), otherwise my code would not work and
produce correct results.
I was just trying to explain what my logic must have been that led me
to do such a mistake (I already knew a method to get the number of
entries in an array, $#array+1, thereby my ignorance of the fact that
'$variable = @array' gives you the number of elements was rather an
ignorance of the sort, 'I did not the other method to this'. Secondly,
Perl is such a wonderful language, in that almost always does something
whatever you code, not always what you want or expect, admittedly,
compared to other languages where compilation often fails when you try
to mix e.g. scalars and arrays. So, I sometimes guess what the correct
solution is and see what Perl makes out of it (Yes, I know, one might
call this the 'throw at the wall' technique), but I either go back to
my book and look up the correct notation or just run Perl. Both takes
time, debugging code or consulting a book.)