0

can someone help me to exclude below the error.

Thanks in advance

Can't locate XML/Writer.pm in @INC (@INC contains: /home/svceln/usr/lib/perl5/site_perl/5.16.2/x86_64-linux /home/svceln/usr/lib/perl5/site_perl/5.16.2 /home/svceln/usr/lib/perl5/5.16.2/x86_64-linux /home/svceln/usr/lib/perl5/5.16.2 .) at /opt/apps/tomcat_scripts/allocate_ports.pl line 7. BEGIN failed--compilation aborted at /opt/apps/tomcat_scripts/allocate_ports.pl line 7. Error in allocating ports, server.xml cannot run`

The script i am using

#!/home/svceln/usr/bin/perl -w
# allocate_ports.pl

# allocate ports, create port_config.xml and write to stdout

use strict;
use XML::Writer;
use IO::File;enter code here
use File::Basename;

my ($increment) = 0;
my ($execDir) = dirname($0);

$#ARGV eq 0 or die "Usage: allocate_ports.pl server_name\n";

my ($port_read) = new IO::File ("$execDir/port_increment.txt");
if (defined $port_read) {
  while (<$port_read>) {
    chomp;
    $increment = $_;
  }
  $port_read->close() or die "Can't close port_increment.txt: $!";
} else {
  $increment = 0;
}
Ragu
  • 11
  • 1
  • 6
  • 3
    Looks like `XML::Writer` isn't installed. – melpomene Jul 08 '17 at 18:56
  • i just followed the below steps to install perl. anything wrong? https://perlmaven.com/download-and-install-perl – Ragu Jul 08 '17 at 19:18
  • 2
    @Ragu XML::Writer is not part of perl. It must be installed separately. –  Jul 08 '17 at 19:27
  • XML::Writer is not a part of Perls core modules ("built in" modules that almost always follows an installation of Perl). There are many ways to install additional modules. Among others, this might be a good start: https://www.thoughtco.com/installing-perl-modules-from-cpan-2641120 Also try command: locate XML/Writer.pm And then add this as line 2 in your program: use lib 'path'; #where path is the result of locate up to but not including the string "XML/Writer.pm" itself. – Kjetil S. Jul 09 '17 at 09:13

1 Answers1

1

It might be in a package, say libxml-writer-perl, assuming Debian.

apt-cache search XML::Writer gives a list of packages if your system uses apt.

Depends on how you are getting your perl modules.

jwal
  • 630
  • 6
  • 16
  • 1
    That won't work here. Judging from the list of directories in `@INC` this is a custom built perl, not system perl. `cpan XML::Writer` ought to work, though. – melpomene Jul 08 '17 at 19:30