What's wrong with my script

What’s wrong with it

#!/usr/bin/perl -w

use CGI qw(:all);;
use Fcntl qw(:flock);

my $mldata=“onemoretime.txt”;
my $semaphore_file=“onemoretime.txt”;

$file=‘SnPmaster.txt’;
open(INFO, $file) or die(“Could not open file.”);

$count = 0;
foreach $line (<INFO>) {
print $line;
if ($++counter == 2){
last;
}
}
close(INFO);

sub get_lock {
open(SEM, “$onemoretime.txt”) || die “Cannot open $onemoretime.txt : $!”;
flock SEM, LOCK_EX;
}

sub release_lock {
close(SEM);
}

get_lock();
open(GB, “>>$mldata”) || die “Cannot open $mldata: $!”;
print GB "address: ", param(’_ADDRESSVARIABLE’), "
";
close(GB);
release_lock();
}

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Um… that’s not the world’s best title. Still, I guess you
get what you pay for:

You are unnecessarily using double-quotes for static strings.
You have hard-coded files.
You’re not using variable messages about why things die before they die.
Your incrementing of ‘counter’ is invalid.
No comments in your code.
I don’t like underscores in function names; camelCase rules.
Random dollar sign before a filename as if it’s a variable.
No parentheses after ‘die’ around the string in at least one case.
Methods should come first in code.
Inconsistent use of spaces around the assignment operator.
No ‘use strict’.

Maybe that’s what you were after… but I doubt it. Next time explain
what you’re seeing, and what should happen, and why.

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJQLYXZAAoJEF+XTK08PnB5KDgQAKxdevbjqs8jJpdMcnVfD+7S
EAdAkJliWq9QFg0NviXLvNUT2x9SxLSUiwDEieSNYbGtRz08BEgwW1sy3ziGGhhh
9UEm/7sN8kAoWQQoqafM+zAUDLgkwWxcPzFi1TR0QFO6AIkJzOiCpCRk2zdTgUMI
hb2nHj57+dED31xcfHiq/AlXcD1eKOlEwFutj5W70OQ7jjbXZ6kPJhekNqb//9dX
CATId9Hx+JKD+95Vx8n4JdVG9fN1rnFH2OHqDIP0bIhMtyac8+/i6Jwes/lIvzTo
riKNzz+PKeewztCP/yhgsvi5NbNlkcth2y4gQNcEBFAlb7Xaiqgxkl2txUSAgJxD
T4+lgHGyxVgaHfhLRdAElWp1/eoNP3+h7BnhKUWHEf1HT3sxfdxujTISdMGcspXe
G4987E+iNlqbq5ey8w6QKEtnXHRikIUENIlcObYyTTIlsbi9aTrajeZko/EnY3qX
wUMyugyv94Is9jA+PAbG+ayR/AMzhBC5u3DcKaOq8uL/XgLxElnEuhcf8riWUXXd
CHDZtzo5SkLod8/GWB2uXnFdgsqc2TEXWYIFGQeLa/nogU50R45DxnX+CA9zBM/R
sXu2N8jerg0U1TFq612vB0dIh0EGlz1SN/SNh0MEobHRab2MZ6auRAelfNTXgMLi
Bc1kyhj2bdbr2b6fvX+G
=+PsL
-----END PGP SIGNATURE-----

Hi
Lots of syntax errors…

You need to;

  1. Set a counter variable
  2. Create a main while loop <file to read>
  3. Open the file
  4. Create an inner while loop to count
  5. Close the loop
  6. Print the total
  7. Close the file
  8. Open the file appendable
  9. Append your text
  10. Close the file
  11. Close the main loop


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 3.0.34-0.7-default
up 18 days 21:12, 4 users, load average: 0.16, 0.18, 0.15
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU

And please, why you are at cleaning up your piece of code, before posting it here again read this: http://forums.opensuse.org/english/information-new-users/advanced-how-faq-read-only/451526-posting-code-tags-guide.html

I personaly do not even read it when not posted between CODE tags. To many chances for misunderstanding.