Nov 17, 2009, 8:25 AM
Post #2 of 3
A) Use code tags around your code.
Re: [sarasudu] syntax error at File.pl line 3, near ". eq"
[In reply to]
B) Declare your variables using 'my' on first use.
C) Put the following lines at the top of every perl program:
1) Use the 3 argument version of open().
2) In perl, when you have an array like this:
my @arr = (10, 20, 30);
you do not retrieve an element of the array using syntax like this:
Instead, perl makes you use a syntax that indicates what type of value you are retrieving:
The $ sign indicates that the value at @arr is a single value, not an array(@) nor a hash(%). Because an element of an array can only be a single value--not an array and not a hash--you will always use the syntax: $arr[n].
3) eq is not a method of an array element, so you can't use the "dot operator" like that. Even if eq were a method, in perl you use '->' to call an object's methods. Instead, eq is an operator--just like + or -.
4) Use shift to get the first element of an array, and use pop to get the last element of an array when you don't care if the array gets modified. If you know you want to get the first three elements of an array, you can do this:
my ($arg1, $arg2, $arg3) = @ARGV;
5) close() your files when you are done with them.
6) Use code tags around your code.
7) Use code tags around your code.
(This post was edited by 7stud on Nov 17, 2009, 9:30 AM)