ITTips
How to use CPAN?
CPAN install module: to install a module
How to run a bash command in a Perl program:
http://perl.about.com/od/programmingperl/qt/perlexecsystem.htm∞
system("myCommand"); i.e.: system("/bin/ls");
How to get the file size:
http://www.perlmeme.org/faqs/file_io/filesize.html∞
$size =
(-
s 'ddserver.log');
print $size;
String comparison
if ($ticketList ne
)
ne: non equal
eq: equal
Pass array to sub-routines
Normally it is not possible to pass array to sub routines.
The only way to do so is to pass a reference to the array when calling the sub-routine and then to use it in the sub-routine
WriteChangesTofile
($new_configuration_file,\
@changed_file);
sub WriteChangesTofile
{
# Does not return anything. It OVERwrites the file
my $new_configuration_file=
$_[0];
my @changed_file = @
{$_[1]};
# This is the way to handle array passed to sub-routines. The array is passed as a reference
print "Updating: ".
$new_configuration_file.
"\n";
open(NEW_CONF_FILE,
">$new_configuration_file");
print (NEW_CONF_FILE
@changed_file);
close(NEW_CONF_FILE
);
}
There are no comments on this page. [Add comment]