Hi,
just a few comments.
You should add the following pragmas:
Perl Code:
Original
- Perl Code |
|
|
|
and correct the warnings and errors that will be issued by the compiler (that will force you, among other things, to declare all your variables and to decide explicitly their scope).
You should remove useless code (that will make your intent clearer), for example:
Code:
my $content = $file ->slurp();
The $content variable is never used, so the code is useless.
Similarly, the @mynumbers array is never used.
In:
Perl Code:
Original
- Perl Code |
|
|
|
the two first lines are useless, since the value of $l is immediately overridden in the fourth line.
Code:
open (MYFILE,'>>G:\perl\samp.txt');
This is an old and somewhat deprecated way to open a file. It is considered better practice to use this three-argument syntax:
Perl Code:
Original
- Perl Code |
|
|
|
my $out_file = "output.txt";
open(my $out_fh,
'>>',
$out_file) or die "could not open $out_file $! \n";
(The "or die ..." part is not mandatory since you are using autodie, but, as a matter of personal taste, I would tend to prefer to control the error message that will be printed if the open instruction fails.)
I am not sure what you really want to do with the $a, $b, $c and $l variables, but the way you use them looks quite clumsy and some of them are probably useless. Especially, $a and $c seem to be used only to iterate through your array, a foreach loop (rather than the while loop) would most probably be clearer and far more "perlish".
There are probably many other things to say, but if you make the proposed changes and post your corrected code with the appropriate CODE tags in order to preserve the formatting (line indentation), it will be easier for us to read your code and understand what you are trying to do.