Variables interpolate directly in double-quoted strings, so you don't have to do anything extra for the filename. I prefer the three-argument form of open and error checking though:
use strict;
my $count = 0;
my $filename = "/home/mj/newlogs$count.log";
open my $filehandle, ">", $filename
or die "Couldn't create '$filename': $!";
... loop
print $filehandle $3;
...
close $filehandle;
$count++;
The operator for string concatenation is the dot (.) - see perlop for the various operators.
my $filename = "/home/mj/newlogs$count.log";
is equivalent to
my $filename = "/home/mj/newlogs" . $count . ".log";
Please read print again to see what syntax I used for the print statement. Much of your code was not syntactically valid - for example, Perl wants a semicolon at the end of each statement. Reading perlsyn will help much.
Also try to get in the habit of using strict and warnings to give Perl a chance to help you when you misspell variable names. |