I believe in the above sample, you would need to chomp the $_ firat or you would end up with a comma on its own line. I would do it this way:
open (IN, $file);
open (OUT, >$temp);
while (<IN>) {
s/\n/,\n/;
print OUT;
}
close (IN);
close(OUT);
unlink ($file);
rename ($temp, $file);
To shell out system commands, there are two options:
1) Use the system keyword. ex: system ("command");
2) Use backticks (`). ex: `command`;
As for file compare, there are several perl modules for file comparison. What specifically do you use FC for?
when using
my $numberoflines = @array;
it is not necessary to call the sub you use. To give a more complete view, this code should do what you want:
use strict;
use warnings;
open (DATABASE, "$database");
my @db = <DATABASE>;
my $number = @db;
Assigning an array to a scalar (my...
Does anyone know of a way to programatically change drive letters? Preferably with vbs/wmi. I have found a registry hack, but it is a devil to get to work right and leaves me feeling somehow soiled .
If your perl install was from activestate, then you should have ppm. If this is the case, you can:
1) Open a command prompt
2) type ppm <return>
3) type install Win32-GuiTest <return>
This should install the package for you.
Else, you can do it through CPAN, but it is more involved.
I will explain it to the best of my ability:
use strict;
my @array = ('1','2','3','blue','red');
my $array_reference = \@array; # a reference to the array
-- After the line above, $array_reference will hold a scalar value that points to the location of @array in memory...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.